Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 193 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Approve | 19837369 | 182 days ago | IN | 0 ETH | 0.00012709 | ||||
Deposit | 19589606 | 217 days ago | IN | 0 ETH | 0.00855114 | ||||
Withdraw | 19589568 | 217 days ago | IN | 0 ETH | 0.00678527 | ||||
Withdraw All | 19022379 | 296 days ago | IN | 0 ETH | 0.01473391 | ||||
Withdraw | 18566302 | 360 days ago | IN | 0 ETH | 0.01426211 | ||||
Withdraw | 18451933 | 376 days ago | IN | 0 ETH | 0.00385831 | ||||
Withdraw | 18127665 | 421 days ago | IN | 0 ETH | 0.01241962 | ||||
Approve | 18117292 | 423 days ago | IN | 0 ETH | 0.00056691 | ||||
Deposit | 18117171 | 423 days ago | IN | 0 ETH | 0.0048598 | ||||
Withdraw | 18094299 | 426 days ago | IN | 0 ETH | 0.00562019 | ||||
Approve | 17851045 | 460 days ago | IN | 0 ETH | 0.00044011 | ||||
Approve | 17241609 | 546 days ago | IN | 0 ETH | 0.00287971 | ||||
Transfer | 17241518 | 546 days ago | IN | 0 ETH | 0.00300149 | ||||
Withdraw | 17188090 | 553 days ago | IN | 0 ETH | 0.03969003 | ||||
Withdraw All | 17135698 | 561 days ago | IN | 0 ETH | 0.01283283 | ||||
Deposit | 17134171 | 561 days ago | IN | 0.12 ETH | 0.02279379 | ||||
Withdraw | 16942002 | 588 days ago | IN | 0 ETH | 0.01542908 | ||||
Deposit | 16899835 | 594 days ago | IN | 0 ETH | 0.01465528 | ||||
Deposit | 16814348 | 606 days ago | IN | 0 ETH | 0.01246589 | ||||
Approve | 16811906 | 607 days ago | IN | 0 ETH | 0.00092574 | ||||
Deposit | 16811900 | 607 days ago | IN | 0.00306778 ETH | 0.009989 | ||||
Approve | 16747297 | 616 days ago | IN | 0 ETH | 0.00050927 | ||||
Withdraw | 16647215 | 630 days ago | IN | 0 ETH | 0.00791771 | ||||
Withdraw | 16556926 | 642 days ago | IN | 0 ETH | 0.00976377 | ||||
Withdraw | 16556891 | 642 days ago | IN | 0 ETH | 0.01202669 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
17134171 | 561 days ago | 0.00086419 ETH | ||||
17134171 | 561 days ago | 0.00086419 ETH | ||||
17134171 | 561 days ago | 0.12 ETH | ||||
16811900 | 607 days ago | 0.00274208 ETH | ||||
16811900 | 607 days ago | 0.00274208 ETH | ||||
16811900 | 607 days ago | 0.00306778 ETH | ||||
16198795 | 692 days ago | 0.07074789 ETH | ||||
16198795 | 692 days ago | 0.07074789 ETH | ||||
16198795 | 692 days ago | 3.17949614 ETH | ||||
16198791 | 692 days ago | 0.06897895 ETH | ||||
16198791 | 692 days ago | 0.06897895 ETH | ||||
16198791 | 692 days ago | 3.10071908 ETH | ||||
16097748 | 706 days ago | 0.18206868 ETH | ||||
16097742 | 706 days ago | 0.20268022 ETH | ||||
16024774 | 717 days ago | 0.06462701 ETH | ||||
16024774 | 717 days ago | 0.06462701 ETH | ||||
16024774 | 717 days ago | 0.54128231 ETH | ||||
15726910 | 758 days ago | 0.02735048 ETH | ||||
15726910 | 758 days ago | 0.02735048 ETH | ||||
15726910 | 758 days ago | 3 ETH | ||||
15726896 | 758 days ago | 0.02822607 ETH | ||||
15726896 | 758 days ago | 0.02822607 ETH | ||||
15726896 | 758 days ago | 3 ETH | ||||
15367852 | 812 days ago | 0.04558353 ETH | ||||
15367852 | 812 days ago | 0.04558353 ETH |
Loading...
Loading
Contract Name:
PickleJarUniV3
Compiler Version
v0.6.12+commit.27d51765
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; // ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── // ─██████████████─██████████─██████████████─██████──████████─██████─────────██████████████────────────██████─██████████████─████████████████─── // ─██░░░░░░░░░░██─██░░░░░░██─██░░░░░░░░░░██─██░░██──██░░░░██─██░░██─────────██░░░░░░░░░░██────────────██░░██─██░░░░░░░░░░██─██░░░░░░░░░░░░██─── // ─██░░██████░░██─████░░████─██░░██████████─██░░██──██░░████─██░░██─────────██░░██████████────────────██░░██─██░░██████░░██─██░░████████░░██─── // ─██░░██──██░░██───██░░██───██░░██─────────██░░██──██░░██───██░░██─────────██░░██────────────────────██░░██─██░░██──██░░██─██░░██────██░░██─── // ─██░░██████░░██───██░░██───██░░██─────────██░░██████░░██───██░░██─────────██░░██████████────────────██░░██─██░░██████░░██─██░░████████░░██─── // ─██░░░░░░░░░░██───██░░██───██░░██─────────██░░░░░░░░░░██───██░░██─────────██░░░░░░░░░░██────────────██░░██─██░░░░░░░░░░██─██░░░░░░░░░░░░██─── // ─██░░██████████───██░░██───██░░██─────────██░░██████░░██───██░░██─────────██░░██████████────██████──██░░██─██░░██████░░██─██░░██████░░████─── // ─██░░██───────────██░░██───██░░██─────────██░░██──██░░██───██░░██─────────██░░██────────────██░░██──██░░██─██░░██──██░░██─██░░██──██░░██───── // ─██░░██─────────████░░████─██░░██████████─██░░██──██░░████─██░░██████████─██░░██████████────██░░██████░░██─██░░██──██░░██─██░░██──██░░██████─ // ─██░░██─────────██░░░░░░██─██░░░░░░░░░░██─██░░██──██░░░░██─██░░░░░░░░░░██─██░░░░░░░░░░██────██░░░░░░░░░░██─██░░██──██░░██─██░░██──██░░░░░░██─ // ─██████─────────██████████─██████████████─██████──████████─██████████████─██████████████────██████████████─██████──██████─██████──██████████─ // ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── import "./interfaces/controllerv2.sol"; import "./lib/erc20.sol"; import "./lib/univ3/PoolActions.sol"; import "./lib/reentrancy-guard.sol"; import "./lib/safe-math.sol"; import "./interfaces/univ3/IUniswapV3PositionsNFT.sol"; import "./interfaces/univ3/IUniswapV3Pool.sol"; import "./interfaces/univ3/ISwapRouter02.sol"; import "./interfaces/weth.sol"; contract PickleJarUniV3 is ERC20, ReentrancyGuard { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; using SafeMath for uint128; using PoolVariables for IUniswapV3Pool; address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address public constant univ3Router = 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45; address public governance; address public timelock; address public controller; bool public paused; IUniswapV3Pool public pool; IERC20 public token0; IERC20 public token1; constructor( string memory _name, string memory _symbol, address _pool, address _governance, address _timelock, address _controller ) public ERC20(_name, _symbol) { pool = IUniswapV3Pool(_pool); token0 = IERC20(pool.token0()); token1 = IERC20(pool.token1()); governance = _governance; timelock = _timelock; controller = _controller; paused = false; } function totalLiquidity() public view returns (uint256) { return liquidityOfThis().add( IControllerV2(controller).liquidityOf(address(pool)) ); } function liquidityOfThis() public view returns (uint256) { uint256 _balance0 = token0.balanceOf(address(this)); uint256 _balance1 = token1.balanceOf(address(this)); return uint256( pool.liquidityForAmounts( _balance0, _balance1, getLowerTick(), getUpperTick() ) ); } function getUpperTick() public view returns (int24) { return IControllerV2(controller).getUpperTick(address(pool)); } function getLowerTick() public view returns (int24) { return IControllerV2(controller).getLowerTick(address(pool)); } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function setTimelock(address _timelock) public { require(msg.sender == timelock, "!timelock"); timelock = _timelock; } function setController(address _controller) public { require(msg.sender == timelock, "!timelock"); controller = _controller; } event JarPaused(uint256 block, uint256 timestamp); function setPaused(bool _paused) external { require(msg.sender == governance, "!governance"); paused = _paused; emit JarPaused(block.number, block.timestamp); } function earn() public { require(liquidityOfThis() > 0, "no liquidity here"); uint256 balance0 = token0.balanceOf(address(this)); uint256 balance1 = token1.balanceOf(address(this)); token0.safeTransfer(controller, balance0); token1.safeTransfer(controller, balance1); IControllerV2(controller).earn(address(pool), balance0, balance1); } function deposit( uint256 token0Amount, uint256 token1Amount, bool _swap ) external payable nonReentrant whenNotPaused { bool _ethUsed; (token0Amount, token1Amount, _ethUsed) = _convertEth( token0Amount, token1Amount ); uint256 _liquidity; _swap ? _liquidity = _depositSwap(token0Amount, token1Amount, _ethUsed) : _liquidity = _depositExact(token0Amount, token1Amount, _ethUsed); uint256 shares = 0; if (totalSupply() == 0) { shares = _liquidity; } else { shares = (_liquidity.mul(totalSupply())).div( IControllerV2(controller).liquidityOf(address(pool)) ); } _mint(msg.sender, shares); earn(); } function getProportion() public view returns (uint256) { (uint256 a1, uint256 a2) = pool.amountsForLiquidity( 1e18, getLowerTick(), getUpperTick() ); return (a2 * (10**18)) / a1; } function _getCorrectAmounts(uint256 _token0Amount, uint256 _token1Amount) internal returns (uint256, uint256) { uint256 amount0ForAmount1 = _token1Amount.mul(1e18).div( getProportion() ); uint256 amount1ForAmount0 = _token0Amount.mul(getProportion()).div( 1e18 ); if (_token0Amount > amount0ForAmount1) { _token0Amount = amount0ForAmount1; } else { _token1Amount = amount1ForAmount0; } return (_token0Amount, _token1Amount); } function withdrawAll() external { withdraw(balanceOf(msg.sender)); } function withdraw(uint256 _shares) public nonReentrant whenNotPaused { uint256 r = (totalLiquidity().mul(_shares)).div(totalSupply()); (uint256 _expectA0, uint256 _expectA1) = pool.amountsForLiquidity( uint128(r), getLowerTick(), getUpperTick() ); _burn(msg.sender, _shares); // Check balance uint256[2] memory _balances = [ token0.balanceOf(address(this)), token1.balanceOf(address(this)) ]; uint256 b = liquidityOfThis(); if (b < r) { uint256 _withdraw = r.sub(b); (uint256 _a0, uint256 _a1) = IControllerV2(controller).withdraw( address(pool), _withdraw ); _expectA0 = _balances[0].add(_a0); _expectA1 = _balances[1].add(_a1); } token0.safeTransfer(msg.sender, _expectA0); token1.safeTransfer(msg.sender, _expectA1); } function getRatio() public view returns (uint256) { if (totalSupply() == 0) return 0; return totalLiquidity().mul(1e18).div(totalSupply()); } function _depositSwap( uint256 token0Amount, uint256 token1Amount, bool _ethUsed ) internal returns (uint256) { if ( !(token0.balanceOf(address(this)) >= token0Amount) && (token0Amount != 0) ) token0.safeTransferFrom(msg.sender, address(this), token0Amount); if ( !(token1.balanceOf(address(this)) >= token1Amount) && (token1Amount != 0) ) token1.safeTransferFrom(msg.sender, address(this), token1Amount); _balanceProportion(getLowerTick(), getUpperTick()); return _refundUnused(_ethUsed); } function _depositExact( uint256 _token0AmountDesired, uint256 _token1AmountDesired, bool _ethUsed ) internal returns (uint256) { (uint256 _token0Amount, uint256 _token1Amount) = _getCorrectAmounts( _token0AmountDesired, _token1AmountDesired ); if (_token0Amount > 0) token0.safeTransferFrom(msg.sender, address(this), _token0Amount); if (_token1Amount > 0) token1.safeTransferFrom(msg.sender, address(this), _token1Amount); if (_ethUsed) { if ((address(token0) == address(weth))) { uint256 refundAmt = _token0AmountDesired.sub(_token0Amount); if (refundAmt > 0) _refundEth(refundAmt); } if ((address(token1) == address(weth))) { uint256 refundAmt = _token1AmountDesired.sub(_token1Amount); if (refundAmt > 0) _refundEth(refundAmt); } } return pool.liquidityForAmounts( _token0Amount, _token1Amount, getLowerTick(), getUpperTick() ); } function _convertEth(uint256 token0Amount, uint256 token1Amount) internal returns ( uint256, uint256, bool ) { bool _ethUsed = false; uint256 _eth = msg.value; if (_eth > 0) { WETH(weth).deposit{value: _eth}(); if (address(token0) == weth) { token0Amount = _eth; _ethUsed = true; } else if (address(token1) == weth) { token1Amount = _eth; _ethUsed = true; } } return (token0Amount, token1Amount, _ethUsed); } function _refundEth(uint256 _refund) internal { WETH(weth).withdraw(_refund); (bool sent, bytes memory data) = (msg.sender).call{value: _refund}(""); require(sent, "Failed to refund Eth"); } function _refundUnused(bool _ethUsed) internal returns (uint256) { PoolVariables.Info memory _cache; _cache.amount0Desired = token0.balanceOf(address(this)); _cache.amount1Desired = token1.balanceOf(address(this)); (uint160 sqrtPriceX96, , , , , , ) = pool.slot0(); uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(getLowerTick()); uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(getUpperTick()); _cache.liquidity = uint128( LiquidityAmounts .getLiquidityForAmount0( sqrtRatioAX96, sqrtRatioBX96, _cache.amount0Desired ).add( LiquidityAmounts.getLiquidityForAmount1( sqrtRatioAX96, sqrtRatioBX96, _cache.amount1Desired ) ) ); (_cache.amount0, _cache.amount1) = LiquidityAmounts .getAmountsForLiquidity( sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, _cache.liquidity ); if (_cache.amount0Desired > _cache.amount0) if ((address(token0) == address(weth)) && _ethUsed) _refundEth(_cache.amount0Desired.sub(_cache.amount0)); else { token0.safeTransfer( msg.sender, _cache.amount0Desired.sub(_cache.amount0) ); } if (_cache.amount1Desired > _cache.amount1) if ((address(token1) == address(weth)) && _ethUsed) _refundEth(_cache.amount1Desired.sub(_cache.amount1)); else { token1.safeTransfer( msg.sender, _cache.amount1Desired.sub(_cache.amount1) ); } return _cache.liquidity; } function _balanceProportion(int24 _tickLower, int24 _tickUpper) internal { PoolVariables.Info memory _cache; _cache.amount0Desired = token0.balanceOf(address(this)); _cache.amount1Desired = token1.balanceOf(address(this)); (uint160 sqrtPriceX96, , , , , , ) = pool.slot0(); uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(_tickLower); uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(_tickUpper); _cache.liquidity = uint128( LiquidityAmounts .getLiquidityForAmount0( sqrtRatioAX96, sqrtRatioBX96, _cache.amount0Desired ).add( LiquidityAmounts.getLiquidityForAmount1( sqrtRatioAX96, sqrtRatioBX96, _cache.amount1Desired ) ) ); (_cache.amount0, _cache.amount1) = LiquidityAmounts .getAmountsForLiquidity( sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, _cache.liquidity ); //Determine Trade Direction bool _zeroForOne = _cache.amount0Desired > _cache.amount0 ? true : false; //Determine Amount to swap uint256 _amountSpecified = _zeroForOne ? (_cache.amount0Desired.sub(_cache.amount0)) : (_cache.amount1Desired.sub(_cache.amount1)); if (_amountSpecified > 0) { //Determine Token to swap address _inputToken = _zeroForOne ? address(token0) : address(token1); IERC20(_inputToken).safeApprove(univ3Router, 0); IERC20(_inputToken).safeApprove(univ3Router, _amountSpecified); //Swap the token imbalanced ISwapRouter02(univ3Router).exactInputSingle( ISwapRouter02.ExactInputSingleParams({ tokenIn: _inputToken, tokenOut: _zeroForOne ? address(token1) : address(token0), fee: pool.fee(), recipient: address(this), amountIn: _amountSpecified, amountOutMinimum: 0, sqrtPriceLimitX96: 0 }) ); } } modifier whenNotPaused() { require(paused == false, "paused"); _; } function onERC721Received( address, address, uint256, bytes memory ) public pure returns (bytes4) { return this.onERC721Received.selector; } fallback() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; interface IControllerV2 { function jars(address) external view returns (address); function devfund() external view returns (address); function treasury() external view returns (address); function liquidityOf(address) external view returns (uint256); function withdraw(address, uint256) external returns (uint256, uint256); function earn( address, uint256, uint256 ) external; function strategies(address) external view returns (address); function getUpperTick(address) external view returns (int24); function getLowerTick(address) external view returns (int24); }
// File: contracts/GSN/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "./safe-math.sol"; import "./context.sol"; // File: contracts/token/ERC20/IERC20.sol /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: contracts/utils/Address.sol /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: contracts/token/ERC20/ERC20.sol /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } /** * @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 SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: Unlicense pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "../../interfaces/univ3/IUniswapV3Pool.sol"; import "./PoolVariables.sol"; import "./SafeCast.sol"; /// @title This library is created to conduct a variety of burn liquidity methods library PoolActions { using PoolVariables for IUniswapV3Pool; using LowGasSafeMath for uint256; using SafeCast for uint256; /** * @notice Withdraws liquidity in share proportion to the Sorbetto's totalSupply. * @param pool Uniswap V3 pool * @param tickLower The lower tick of the range * @param tickUpper The upper tick of the range * @param totalSupply The amount of total shares in existence * @param share to burn * @param to Recipient of amounts * @return amount0 Amount of token0 withdrawed * @return amount1 Amount of token1 withdrawed */ function burnLiquidityShare( IUniswapV3Pool pool, int24 tickLower, int24 tickUpper, uint256 totalSupply, uint256 share, address to ) internal returns (uint256 amount0, uint256 amount1) { require(totalSupply > 0, "TS"); uint128 liquidityInPool = pool.positionLiquidity(tickLower, tickUpper); uint256 liquidity = uint256(liquidityInPool).mul(share) / totalSupply; if (liquidity > 0) { (amount0, amount1) = pool.burn(tickLower, tickUpper, liquidity.toUint128()); if (amount0 > 0 || amount1 > 0) { // collect liquidity share (amount0, amount1) = pool.collect(to, tickLower, tickUpper, amount0.toUint128(), amount1.toUint128()); } } } /** * @notice Withdraws exact amount of liquidity * @param pool Uniswap V3 pool * @param tickLower The lower tick of the range * @param tickUpper The upper tick of the range * @param liquidity to burn * @param to Recipient of amounts * @return amount0 Amount of token0 withdrawed * @return amount1 Amount of token1 withdrawed */ function burnExactLiquidity( IUniswapV3Pool pool, int24 tickLower, int24 tickUpper, uint128 liquidity, address to ) internal returns (uint256 amount0, uint256 amount1) { uint128 liquidityInPool = pool.positionLiquidity(tickLower, tickUpper); require(liquidityInPool >= liquidity, "TML"); (amount0, amount1) = pool.burn(tickLower, tickUpper, liquidity); if (amount0 > 0 || amount1 > 0) { // collect liquidity share including earned fees (amount0, amount0) = pool.collect(to, tickLower, tickUpper, amount0.toUint128(), amount1.toUint128()); } } /** * @notice Withdraws all liquidity in a range from Uniswap pool * @param pool Uniswap V3 pool * @param tickLower The lower tick of the range * @param tickUpper The upper tick of the range */ function burnAllLiquidity( IUniswapV3Pool pool, int24 tickLower, int24 tickUpper ) internal { // Burn all liquidity in this range uint128 liquidity = pool.positionLiquidity(tickLower, tickUpper); if (liquidity > 0) { pool.burn(tickLower, tickUpper, liquidity); } // Collect all owed tokens pool.collect(address(this), tickLower, tickUpper, type(uint128).max, type(uint128).max); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "./IERC721.sol"; // Originally INonfungiblePositionManager interface IUniswapV3PositionsNFT is IERC721 { struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @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, // [0] address operator, // [1] address token0, // [2] address token1, // [3] uint24 fee, // [4] int24 tickLower, // [5] int24 tickUpper, // [6] uint128 liquidity, // [7] uint256 feeGrowthInside0LastX128, // [8] uint256 feeGrowthInside1LastX128, // [9] uint128 tokensOwed0, // [10] uint128 tokensOwed1 // [11] ); 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); /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); function multicall(bytes[] calldata data) external payable returns (bytes[] memory results); function mint(MintParams calldata params) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); function burn(uint256 tokenId) external payable; function refundETH() external payable; function unwrapWETH9(uint256 amountMinimum, address recipient) external payable; function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import "./pool/IUniswapV3PoolImmutables.sol"; import "./pool/IUniswapV3PoolState.sol"; import "./pool/IUniswapV3PoolDerivedState.sol"; import "./pool/IUniswapV3PoolActions.sol"; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions { function fee() external view returns (uint24); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter02 { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance, /// and swap the entire amount, enabling contracts to send tokens before calling this function. /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance, /// and swap the entire amount, enabling contracts to send tokens before calling this function. /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// that may remain in the router after the swap. /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// that may remain in the router after the swap. /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface WETH { function name() external view returns (string memory); function approve(address guy, uint256 wad) external returns (bool); function totalSupply() external view returns (uint256); function transferFrom( address src, address dst, uint256 wad ) external returns (bool); function withdraw(uint256 wad) external; function decimals() external view returns (uint8); function balanceOf(address) external view returns (uint256); function symbol() external view returns (string memory); function transfer(address dst, uint256 wad) external returns (bool); function deposit() external payable; function allowance(address, address) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import "./LiquidityAmounts.sol"; import "../../interfaces/univ3/IUniswapV3Pool.sol"; import "./TickMath.sol"; import "./PositionKey.sol"; import "./LowGasSafeMath.sol"; import "./SqrtPriceMath.sol"; /// @title Liquidity and ticks functions /// @notice Provides functions for computing liquidity and ticks for token amounts and prices library PoolVariables { using LowGasSafeMath for uint256; // Cache struct for calculations struct Info { uint256 amount0Desired; uint256 amount1Desired; uint256 amount0; uint256 amount1; uint128 liquidity; int24 tickLower; int24 tickUpper; } /// @dev Wrapper around `LiquidityAmounts.getAmountsForLiquidity()`. /// @param pool Uniswap V3 pool /// @param liquidity The liquidity being valued /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return amounts of token0 and token1 that corresponds to liquidity function amountsForLiquidity( IUniswapV3Pool pool, uint128 liquidity, int24 _tickLower, int24 _tickUpper ) internal view returns (uint256, uint256) { //Get current price from the pool (uint160 sqrtRatioX96, , , , , , ) = pool.slot0(); return LiquidityAmounts.getAmountsForLiquidity( sqrtRatioX96, TickMath.getSqrtRatioAtTick(_tickLower), TickMath.getSqrtRatioAtTick(_tickUpper), liquidity ); } /// @dev Wrapper around `LiquidityAmounts.getLiquidityForAmounts()`. /// @param pool Uniswap V3 pool /// @param amount0 The amount of token0 /// @param amount1 The amount of token1 /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return The maximum amount of liquidity that can be held amount0 and amount1 function liquidityForAmounts( IUniswapV3Pool pool, uint256 amount0, uint256 amount1, int24 _tickLower, int24 _tickUpper ) internal view returns (uint128) { //Get current price from the pool (uint160 sqrtRatioX96, , , , , , ) = pool.slot0(); return LiquidityAmounts.getLiquidityForAmounts( sqrtRatioX96, TickMath.getSqrtRatioAtTick(_tickLower), TickMath.getSqrtRatioAtTick(_tickUpper), amount0, amount1 ); } /// @dev Amounts of token0 and token1 held in contract position. /// @param pool Uniswap V3 pool /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return amount0 The amount of token0 held in position /// @return amount1 The amount of token1 held in position function positionAmounts( IUniswapV3Pool pool, int24 _tickLower, int24 _tickUpper ) internal view returns (uint256 amount0, uint256 amount1) { //Compute position key bytes32 positionKey = PositionKey.compute(address(this), _tickLower, _tickUpper); //Get Position.Info for specified ticks (uint128 liquidity, , , uint128 tokensOwed0, uint128 tokensOwed1) = pool.positions(positionKey); // Calc amounts of token0 and token1 including fees (amount0, amount1) = amountsForLiquidity(pool, liquidity, _tickLower, _tickUpper); amount0 = amount0.add(uint256(tokensOwed0)); amount1 = amount1.add(uint256(tokensOwed1)); } /// @dev Amount of liquidity in contract position. /// @param pool Uniswap V3 pool /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return liquidity stored in position function positionLiquidity( IUniswapV3Pool pool, int24 _tickLower, int24 _tickUpper ) internal view returns (uint128 liquidity) { //Compute position key bytes32 positionKey = PositionKey.compute(address(this), _tickLower, _tickUpper); //Get liquidity stored in position (liquidity, , , , ) = pool.positions(positionKey); } /// @dev Common checks for valid tick inputs. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range function checkRange(int24 tickLower, int24 tickUpper) internal pure { require(tickLower < tickUpper, "TLU"); require(tickLower >= TickMath.MIN_TICK, "TLM"); require(tickUpper <= TickMath.MAX_TICK, "TUM"); } /// @dev Rounds tick down towards negative infinity so that it's a multiple /// of `tickSpacing`. function floor(int24 tick, int24 tickSpacing) internal pure returns (int24) { int24 compressed = tick / tickSpacing; if (tick < 0 && tick % tickSpacing != 0) compressed--; return compressed * tickSpacing; } /// @dev Gets ticks with proportion equivalent to desired amount /// @param pool Uniswap V3 pool /// @param amount0Desired The desired amount of token0 /// @param amount1Desired The desired amount of token1 /// @param baseThreshold The range for upper and lower ticks /// @param tickSpacing The pool tick spacing /// @return tickLower The lower tick of the range /// @return tickUpper The upper tick of the range function getPositionTicks( IUniswapV3Pool pool, uint256 amount0Desired, uint256 amount1Desired, int24 baseThreshold, int24 tickSpacing ) internal view returns (int24 tickLower, int24 tickUpper) { Info memory cache = Info(amount0Desired, amount1Desired, 0, 0, 0, 0, 0); // Get current price and tick from the pool (uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0(); //Calc base ticks (cache.tickLower, cache.tickUpper) = baseTicks(currentTick, baseThreshold, tickSpacing); //Calc amounts of token0 and token1 that can be stored in base range (cache.amount0, cache.amount1) = amountsForTicks( pool, cache.amount0Desired, cache.amount1Desired, cache.tickLower, cache.tickUpper ); //Liquidity that can be stored in base range cache.liquidity = liquidityForAmounts(pool, cache.amount0, cache.amount1, cache.tickLower, cache.tickUpper); //Get imbalanced token bool zeroGreaterOne = amountsDirection( cache.amount0Desired, cache.amount1Desired, cache.amount0, cache.amount1 ); //Calc new tick(upper or lower) for imbalanced token if (zeroGreaterOne) { uint160 nextSqrtPrice0 = SqrtPriceMath.getNextSqrtPriceFromAmount0RoundingUp( sqrtPriceX96, cache.liquidity, cache.amount0Desired, false ); cache.tickUpper = PoolVariables.floor(TickMath.getTickAtSqrtRatio(nextSqrtPrice0), tickSpacing); } else { uint160 nextSqrtPrice1 = SqrtPriceMath.getNextSqrtPriceFromAmount1RoundingDown( sqrtPriceX96, cache.liquidity, cache.amount1Desired, false ); cache.tickLower = PoolVariables.floor(TickMath.getTickAtSqrtRatio(nextSqrtPrice1), tickSpacing); } checkRange(cache.tickLower, cache.tickUpper); tickLower = cache.tickLower; tickUpper = cache.tickUpper; } /// @dev Gets amounts of token0 and token1 that can be stored in range of upper and lower ticks /// @param pool Uniswap V3 pool /// @param amount0Desired The desired amount of token0 /// @param amount1Desired The desired amount of token1 /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return amount0 amounts of token0 that can be stored in range /// @return amount1 amounts of token1 that can be stored in range function amountsForTicks( IUniswapV3Pool pool, uint256 amount0Desired, uint256 amount1Desired, int24 _tickLower, int24 _tickUpper ) internal view returns (uint256 amount0, uint256 amount1) { uint128 liquidity = liquidityForAmounts(pool, amount0Desired, amount1Desired, _tickLower, _tickUpper); (amount0, amount1) = amountsForLiquidity(pool, liquidity, _tickLower, _tickUpper); } /// @dev Calc base ticks depending on base threshold and tickspacing function baseTicks( int24 currentTick, int24 baseThreshold, int24 tickSpacing ) internal pure returns (int24 tickLower, int24 tickUpper) { int24 tickFloor = floor(currentTick, tickSpacing); tickLower = tickFloor - baseThreshold; tickUpper = tickFloor + baseThreshold; } /// @dev Get imbalanced token /// @param amount0Desired The desired amount of token0 /// @param amount1Desired The desired amount of token1 /// @param amount0 Amounts of token0 that can be stored in base range /// @param amount1 Amounts of token1 that can be stored in base range /// @return zeroGreaterOne true if token0 is imbalanced. False if token1 is imbalanced function amountsDirection( uint256 amount0Desired, uint256 amount1Desired, uint256 amount0, uint256 amount1 ) internal pure returns (bool zeroGreaterOne) { zeroGreaterOne = amount0Desired.sub(amount0).mul(amount1Desired) > amount1Desired.sub(amount1).mul(amount0Desired) ? true : false; } // Check price has not moved a lot recently. This mitigates price // manipulation during rebalance and also prevents placing orders // when it's too volatile. function checkDeviation( IUniswapV3Pool pool, int24 maxTwapDeviation, uint32 twapDuration ) internal view { (, int24 currentTick, , , , , ) = pool.slot0(); int24 twap = getTwap(pool, twapDuration); int24 deviation = currentTick > twap ? currentTick - twap : twap - currentTick; require(deviation <= maxTwapDeviation, "PSC"); } /// @dev Fetches time-weighted average price in ticks from Uniswap pool for specified duration function getTwap(IUniswapV3Pool pool, uint32 twapDuration) internal view returns (int24) { uint32 _twapDuration = twapDuration; uint32[] memory secondsAgo = new uint32[](2); secondsAgo[0] = _twapDuration; secondsAgo[1] = 0; (int56[] memory tickCumulatives, ) = pool.observe(secondsAgo); return int24((tickCumulatives[1] - tickCumulatives[0]) / _twapDuration); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Safe casting methods /// @notice Contains methods for safely casting between types library SafeCast { /// @notice Cast a uint256 to a uint160, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint160 function toUint160(uint256 y) internal pure returns (uint160 z) { require((z = uint160(y)) == y); } /// @notice Cast a uint256 to a uint128, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint128 function toUint128(uint256 y) internal pure returns (uint128 z) { require((z = uint128(y)) == y); } /// @notice Cast a int256 to a int128, revert on overflow or underflow /// @param y The int256 to be downcasted /// @return z The downcasted integer, now type int128 function toInt128(int256 y) internal pure returns (int128 z) { require((z = int128(y)) == y); } /// @notice Cast a uint256 to a int256, revert on overflow /// @param y The uint256 to be casted /// @return z The casted integer, now type int256 function toInt256(uint256 y) internal pure returns (int256 z) { require(y < 2**255); z = int256(y); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import "./FullMath.sol"; import "./FixedPoint96.sol"; /// @title Liquidity amount functions /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { /// @notice Downcasts uint256 to uint128 /// @param x The uint258 to be downcasted /// @return y The passed value, downcasted to uint128 function toUint128(uint256 x) private pure returns (uint128 y) { require((y = uint128(x)) == x); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96); return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1); liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1; } else { liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv( uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96 ) / sqrtRatioAX96; } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 < sqrtRatioBX96) { amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; library PositionKey { /// @dev Returns the key of the position in the core library function compute( address owner, int24 tickLower, int24 tickUpper ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(owner, tickLower, tickUpper)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.6.12; /// @title Optimized overflow and underflow safe math operations /// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost library LowGasSafeMath { /// @notice Returns x + y, reverts if sum overflows uint256 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(x == 0 || (z = x * y) / x == y); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub( uint256 x, uint256 y, string memory errorMessage ) internal pure returns (uint256 z) { require((z = x - y) <= x, errorMessage); } /// @notice Returns x + y, reverts if overflows or underflows /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(int256 x, int256 y) internal pure returns (int256 z) { require((z = x + y) >= x == (y >= 0)); } /// @notice Returns x - y, reverts if overflows or underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(int256 x, int256 y) internal pure returns (int256 z) { require((z = x - y) <= x == (y >= 0)); } /// @notice Returns x + y, reverts if sum overflows uint128 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add128(uint128 x, uint128 y) internal pure returns (uint128 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub128(uint128 x, uint128 y) internal pure returns (uint128 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul128(uint128 x, uint128 y) internal pure returns (uint128 z) { require(x == 0 || (z = x * y) / x == y); } /// @notice Returns x + y, reverts if sum overflows uint128 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add160(uint160 x, uint160 y) internal pure returns (uint160 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub160(uint160 x, uint160 y) internal pure returns (uint160 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul160(uint160 x, uint160 y) internal pure returns (uint160 z) { require(x == 0 || (z = x * y) / x == y); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "./LowGasSafeMath.sol"; import "./SafeCast.sol"; import "./FullMath.sol"; import "./UnsafeMath.sol"; import "./FixedPoint96.sol"; /// @title Functions based on Q64.96 sqrt price and liquidity /// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas library SqrtPriceMath { using LowGasSafeMath for uint256; using SafeCast for uint256; /// @notice Gets the next sqrt price given a delta of token0 /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the /// price less in order to not send too much output. /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96), /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount). /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token0 to add or remove from virtual reserves /// @param add Whether to add or remove the amount of token0 /// @return The price after adding or removing amount, depending on add function getNextSqrtPriceFromAmount0RoundingUp( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price if (amount == 0) return sqrtPX96; uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; if (add) { uint256 product; if ((product = amount * sqrtPX96) / amount == sqrtPX96) { uint256 denominator = numerator1 + product; if (denominator >= numerator1) // always fits in 160 bits return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator)); } return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount))); } else { uint256 product; // if the product overflows, we know the denominator underflows // in addition, we must check that the denominator does not underflow require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product); uint256 denominator = numerator1 - product; return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160(); } } /// @notice Gets the next sqrt price given a delta of token1 /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the /// price less in order to not send too much output. /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token1 to add, or remove, from virtual reserves /// @param add Whether to add, or remove, the amount of token1 /// @return The price after adding or removing `amount` function getNextSqrtPriceFromAmount1RoundingDown( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // if we're adding (subtracting), rounding down requires rounding the quotient down (up) // in both cases, avoid a mulDiv for most inputs if (add) { uint256 quotient = ( amount <= type(uint160).max ? (amount << FixedPoint96.RESOLUTION) / liquidity : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity) ); return uint256(sqrtPX96).add(quotient).toUint160(); } else { uint256 quotient = ( amount <= type(uint160).max ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity) : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity) ); require(sqrtPX96 > quotient); // always fits 160 bits return uint160(sqrtPX96 - quotient); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.4.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = -denominator & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math functions that do not check inputs or outputs /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks library UnsafeMath { /// @notice Returns ceil(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, ceil(x / y) function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := add(div(x, y), gt(mod(x, y), 0)) } } /// @notice Returns floor(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, floor(x / y) function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := div(x, y) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "./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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * 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 Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns 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); /** * @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; }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; /** * @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); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"_timelock","type":"address"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"block","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"JarPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"token0Amount","type":"uint256"},{"internalType":"uint256","name":"token1Amount","type":"uint256"},{"internalType":"bool","name":"_swap","type":"bool"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"earn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getLowerTick","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProportion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUpperTick","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"liquidityOfThis","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract IUniswapV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_timelock","type":"address"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timelock","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"univ3Router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162003dd838038062003dd8833981016040819052620000349162000389565b8551869086906200004d90600390602085019062000203565b5080516200006390600490602084019062000203565b50506005805460ff19166012179055506001600655600a80546001600160a01b038087166001600160a01b0319909216919091179182905560408051630dfe168160e01b815290519290911691630dfe168191600480820192602092909190829003018186803b158015620000d757600080fd5b505afa158015620000ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000112919062000364565b600b80546001600160a01b0319166001600160a01b03928316179055600a546040805163d21220a760e01b81529051919092169163d21220a7916004808301926020929190829003018186803b1580156200016c57600080fd5b505afa15801562000181573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001a7919062000364565b600c80546001600160a01b03199081166001600160a01b039384161790915560078054821695831695909517909455600880548516938216939093179092556009805490931691161760ff60a01b19169055506200043d915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200024657805160ff191683800117855562000276565b8280016001018555821562000276579182015b828111156200027657825182559160200191906001019062000259565b506200028492915062000288565b5090565b5b8082111562000284576000815560010162000289565b80516001600160a01b0381168114620002b757600080fd5b92915050565b600082601f830112620002ce578081fd5b81516001600160401b0380821115620002e5578283fd5b6040516020601f8401601f191682018101838111838210171562000307578586fd5b806040525081945083825286818588010111156200032457600080fd5b600092505b8383101562000348578583018101518284018201529182019162000329565b838311156200035a5760008185840101525b5050505092915050565b60006020828403121562000376578081fd5b6200038283836200029f565b9392505050565b60008060008060008060c08789031215620003a2578182fd5b86516001600160401b0380821115620003b9578384fd5b620003c78a838b01620002bd565b97506020890151915080821115620003dd578384fd5b50620003ec89828a01620002bd565b955050620003fe88604089016200029f565b93506200040f88606089016200029f565b92506200042088608089016200029f565b9150620004318860a089016200029f565b90509295509295509295565b61398b806200044d6000396000f3fe6080604052600436106102035760003560e01c806343a0d06611610118578063a9059cbb116100a0578063d33219b41161006f578063d33219b414610561578063d389800f14610576578063dd62ed3e1461058b578063ec1ebd7a146105ab578063f77c4791146105c057610203565b8063a9059cbb146104ec578063ab033ea91461050c578063bdacb3031461052c578063d21220a71461054c57610203565b806370a08231116100e757806370a0823114610462578063853828b61461048257806392eefe9b1461049757806395d89b41146104b7578063a457c2d7146104cc57610203565b806343a0d066146104105780635416da55146104235780635aa6e675146104385780635c975abb1461044d57610203565b806316f0115b1161019b5780632e1a7d4d1161016a5780632e1a7d4d14610384578063313ce567146103a457806339509351146103c65780633ced1929146103e65780633fc8cef3146103fb57610203565b806316f0115b1461032557806318160ddd1461033a57806323b872dd1461034f578063262c643b1461036f57610203565b80630dfe1681116101d75780630dfe1681146102a1578063150b7a02146102c357806315770f92146102f057806316c38b3c1461030557610203565b8062bf2b221461020557806306fdde031461023057806307fafb2814610252578063095ea7b314610274575b005b34801561021157600080fd5b5061021a6105d5565b6040516102279190613849565b60405180910390f35b34801561023c57600080fd5b5061024561071d565b60405161022791906133d0565b34801561025e57600080fd5b506102676107b3565b60405161022791906133c2565b34801561028057600080fd5b5061029461028f366004613137565b610840565b60405161022791906133a2565b3480156102ad57600080fd5b506102b661085e565b6040516102279190613316565b3480156102cf57600080fd5b506102e36102de36600461306f565b61086d565b60405161022791906133ad565b3480156102fc57600080fd5b5061021a61087e565b34801561031157600080fd5b50610203610320366004613162565b610916565b34801561033157600080fd5b506102b661099d565b34801561034657600080fd5b5061021a6109ac565b34801561035b57600080fd5b5061029461036a36600461302f565b6109b2565b34801561037b57600080fd5b5061021a610a3a565b34801561039057600080fd5b5061020361039f36600461326f565b610a8e565b3480156103b057600080fd5b506103b9610d56565b6040516102279190613860565b3480156103d257600080fd5b506102946103e1366004613137565b610d5f565b3480156103f257600080fd5b506102b6610dad565b34801561040757600080fd5b506102b6610dc5565b61020361041e3660046132c2565b610ddd565b34801561042f57600080fd5b50610267610f31565b34801561044457600080fd5b506102b6610f69565b34801561045957600080fd5b50610294610f78565b34801561046e57600080fd5b5061021a61047d366004612fdb565b610f88565b34801561048e57600080fd5b50610203610fa7565b3480156104a357600080fd5b506102036104b2366004612fdb565b610fb5565b3480156104c357600080fd5b50610245611001565b3480156104d857600080fd5b506102946104e7366004613137565b611062565b3480156104f857600080fd5b50610294610507366004613137565b6110ca565b34801561051857600080fd5b50610203610527366004612fdb565b6110de565b34801561053857600080fd5b50610203610547366004612fdb565b61112a565b34801561055857600080fd5b506102b6611176565b34801561056d57600080fd5b506102b6611185565b34801561058257600080fd5b50610203611194565b34801561059757600080fd5b5061021a6105a6366004612ff7565b61136d565b3480156105b757600080fd5b5061021a611398565b3480156105cc57600080fd5b506102b66113cd565b600b546040516370a0823160e01b815260009182916001600160a01b03909116906370a082319061060a903090600401613316565b60206040518083038186803b15801561062257600080fd5b505afa158015610636573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065a9190613287565b600c546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190610690903090600401613316565b60206040518083038186803b1580156106a857600080fd5b505afa1580156106bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e09190613287565b905061070c82826106ef6107b3565b6106f7610f31565b600a546001600160a01b0316939291906113dc565b6001600160801b0316925050505b90565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a95780601f1061077e576101008083540402835291602001916107a9565b820191906000526020600020905b81548152906001019060200180831161078c57829003601f168201915b5050505050905090565b600954600a546040516350314fd760e01b81526000926001600160a01b03908116926350314fd7926107eb9290911690600401613316565b60206040518083038186803b15801561080357600080fd5b505afa158015610817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083b919061319a565b905090565b600061085461084d611482565b8484611486565b5060015b92915050565b600b546001600160a01b031681565b630a85bd0160e11b5b949350505050565b600954600a54604051633c4750df60e01b815260009261083b926001600160a01b0391821692633c4750df926108b8921690600401613316565b60206040518083038186803b1580156108d057600080fd5b505afa1580156108e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109089190613287565b6109106105d5565b9061153a565b6007546001600160a01b031633146109495760405162461bcd60e51b815260040161094090613446565b60405180910390fd5b6009805460ff60a01b1916600160a01b831515021790556040517f531a84b8edb5c30911fd540c1446a6baf541a33418fcd124935d74f575dfc4c3906109929043904290613852565b60405180910390a150565b600a546001600160a01b031681565b60025490565b60006109bf84848461155f565b610a2f846109cb611482565b610a2a85604051806060016040528060288152602001613909602891396001600160a01b038a16600090815260016020526040812090610a09611482565b6001600160a01b031681526020810191909152604001600020549190611674565b611486565b5060015b9392505050565b6000806000610a6f670de0b6b3a7640000610a536107b3565b610a5b610f31565b600a546001600160a01b03169291906116a0565b915091508181670de0b6b3a76400000281610a8657fe5b049250505090565b60026006541415610ab15760405162461bcd60e51b815260040161094090613707565b6002600655600954600160a01b900460ff1615610ae05760405162461bcd60e51b81526004016109409061373e565b6000610b05610aed6109ac565b610aff84610af961087e565b90611749565b90611783565b9050600080610b1683610a536107b3565b91509150610b2433856117c5565b610b2c612f4d565b6040805180820191829052600b546370a0823160e01b9092529081906001600160a01b03166370a08231610b633060448501613316565b60206040518083038186803b158015610b7b57600080fd5b505afa158015610b8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb39190613287565b8152600c546040516370a0823160e01b81526020909201916001600160a01b03909116906370a0823190610beb903090600401613316565b60206040518083038186803b158015610c0357600080fd5b505afa158015610c17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3b9190613287565b905290506000610c496105d5565b905084811015610d1b576000610c5f86836118a7565b600954600a5460405163f3fef3a360e01b815292935060009283926001600160a01b039081169263f3fef3a392610c9e92909116908790600401613368565b6040805180830381600087803b158015610cb757600080fd5b505af1158015610ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cef919061329f565b9092509050610d07828660005b60200201519061153a565b9650610d1581866001610cfc565b95505050505b600b54610d32906001600160a01b031633866118e9565b600c54610d49906001600160a01b031633856118e9565b5050600160065550505050565b60055460ff1690565b6000610854610d6c611482565b84610a2a8560016000610d7d611482565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061153a565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc4581565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b60026006541415610e005760405162461bcd60e51b815260040161094090613707565b6002600655600954600160a01b900460ff1615610e2f5760405162461bcd60e51b81526004016109409061373e565b6000610e3b8484611944565b91955093509050600082610e5c57610e54858584611a28565b905080610e6b565b610e67858584611b2a565b9050805b506000610e766109ac565b610e81575080610f1f565b600954600a54604051633c4750df60e01b8152610f1c926001600160a01b0390811692633c4750df92610eba9290911690600401613316565b60206040518083038186803b158015610ed257600080fd5b505afa158015610ee6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0a9190613287565b610aff610f156109ac565b8590611749565b90505b610f293382611ca2565b610d49611194565b600954600a5460405163990ed59d60e01b81526000926001600160a01b039081169263990ed59d926107eb9290911690600401613316565b6007546001600160a01b031681565b600954600160a01b900460ff1681565b6001600160a01b0381166000908152602081905260409020545b919050565b610fb361039f33610f88565b565b6008546001600160a01b03163314610fdf5760405162461bcd60e51b8152600401610940906136e4565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a95780601f1061077e576101008083540402835291602001916107a9565b600061085461106f611482565b84610a2a856040518060600160405280602581526020016139316025913960016000611099611482565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611674565b60006108546110d7611482565b848461155f565b6007546001600160a01b031633146111085760405162461bcd60e51b815260040161094090613446565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6008546001600160a01b031633146111545760405162461bcd60e51b8152600401610940906136e4565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b600c546001600160a01b031681565b6008546001600160a01b031681565b600061119e6105d5565b116111bb5760405162461bcd60e51b815260040161094090613512565b600b546040516370a0823160e01b81526000916001600160a01b0316906370a08231906111ec903090600401613316565b60206040518083038186803b15801561120457600080fd5b505afa158015611218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123c9190613287565b600c546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190611272903090600401613316565b60206040518083038186803b15801561128a57600080fd5b505afa15801561129e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c29190613287565b600954600b549192506112e2916001600160a01b039081169116846118e9565b600954600c546112ff916001600160a01b039182169116836118e9565b600954600a546040516339ef272d60e01b81526001600160a01b03928316926339ef272d926113379291169086908690600401613381565b600060405180830381600087803b15801561135157600080fd5b505af1158015611365573d6000803e3d6000fd5b505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60006113a26109ac565b6113ae5750600061071a565b61083b6113b96109ac565b610aff670de0b6b3a7640000610af961087e565b6009546001600160a01b031681565b600080866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561141857600080fd5b505afa15801561142c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145091906131b5565b50505050505090506114758161146586611d56565b61146e86611d56565b898961206f565b9150505b95945050505050565b3390565b6001600160a01b0383166114ac5760405162461bcd60e51b81526004016109409061361f565b6001600160a01b0382166114d25760405162461bcd60e51b81526004016109409061346b565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061152d908590613849565b60405180910390a3505050565b600082820183811015610a335760405162461bcd60e51b8152600401610940906134ad565b6001600160a01b0383166115855760405162461bcd60e51b8152600401610940906135da565b6001600160a01b0382166115ab5760405162461bcd60e51b815260040161094090613403565b6115b683838361193f565b6115f3816040518060600160405280602681526020016138e3602691396001600160a01b0386166000908152602081905260409020549190611674565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611622908261153a565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061152d908590613849565b600081848411156116985760405162461bcd60e51b815260040161094091906133d0565b505050900390565b6000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156116de57600080fd5b505afa1580156116f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171691906131b5565b505050505050905061173a8161172b87611d56565b61173487611d56565b89612131565b92509250505b94509492505050565b60008261175857506000610858565b8282028284828161176557fe5b0414610a335760405162461bcd60e51b815260040161094090613558565b6000610a3383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506121cc565b6001600160a01b0382166117eb5760405162461bcd60e51b815260040161094090613599565b6117f78260008361193f565b611834816040518060600160405280602281526020016138c1602291396001600160a01b0385166000908152602081905260409020549190611674565b6001600160a01b03831660009081526020819052604090205560025461185a90826118a7565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061189b908590613849565b60405180910390a35050565b6000610a3383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611674565b61193f8363a9059cbb60e01b8484604051602401611908929190613368565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612203565b505050565b6000808080348015611a1c5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561199f57600080fd5b505af11580156119b3573d6000803e3d6000fd5b5050600b546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2141592506119ed9150505780965060019150611a1c565b600c546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611a1c57809550600191505b50949593949392505050565b6000806000611a378686612292565b90925090508115611a5a57600b54611a5a906001600160a01b03163330856122f6565b8015611a7857600c54611a78906001600160a01b03163330846122f6565b8315611b0a57600b546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611ac4576000611ab187846118a7565b90508015611ac257611ac28161231d565b505b600c546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611b0a576000611af786836118a7565b90508015611b0857611b088161231d565b505b611b1782826106ef6107b3565b6001600160801b03169695505050505050565b600b546040516370a0823160e01b815260009185916001600160a01b03909116906370a0823190611b5f903090600401613316565b60206040518083038186803b158015611b7757600080fd5b505afa158015611b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611baf9190613287565b108015611bbb57508315155b15611bd857600b54611bd8906001600160a01b03163330876122f6565b600c546040516370a0823160e01b815284916001600160a01b0316906370a0823190611c08903090600401613316565b60206040518083038186803b158015611c2057600080fd5b505afa158015611c34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c589190613287565b108015611c6457508215155b15611c8157600c54611c81906001600160a01b03163330866122f6565b611c99611c8c6107b3565b611c94610f31565b612405565b6108768261287f565b6001600160a01b038216611cc85760405162461bcd60e51b8152600401610940906137b4565b611cd46000838361193f565b600254611ce1908261153a565b6002556001600160a01b038216600090815260208190526040902054611d07908261153a565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061189b908590613849565b60008060008360020b12611d6d578260020b611d75565b8260020b6000035b9050620d89e8811115611d9a5760405162461bcd60e51b81526004016109409061353d565b600060018216611dae57600160801b611dc0565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615611df4576ffff97272373d413259a46990580e213a0260801c5b6004821615611e13576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615611e32576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611e51576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611e70576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611e8f576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611eae576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611ece576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615611eee576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615611f0e576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615611f2e576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611f4e576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611f6e576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611f8e576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611fae576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611fcf576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615611fef576e5d6af8dedb81196699c329225ee6040260801c5b6204000082161561200e576d2216e584f5fa1ea926041bedfe980260801c5b6208000082161561202b576b048a170391f7dc42444e8fa20260801c5b60008460020b131561204657806000198161204257fe5b0490505b64010000000081061561205a57600161205d565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b0316111561208f579293925b846001600160a01b0316866001600160a01b0316116120ba576120b3858585612ba0565b9050611479565b836001600160a01b0316866001600160a01b0316101561211c5760006120e1878686612ba0565b905060006120f0878986612c03565b9050806001600160801b0316826001600160801b0316106121115780612113565b815b92505050611479565b612127858584612c03565b9695505050505050565b600080836001600160a01b0316856001600160a01b03161115612152579293925b846001600160a01b0316866001600160a01b03161161217d57612176858585612c40565b9150611740565b836001600160a01b0316866001600160a01b031610156121b6576121a2868585612c40565b91506121af858785612ca9565b9050611740565b6121c1858585612ca9565b905094509492505050565b600081836121ed5760405162461bcd60e51b815260040161094091906133d0565b5060008385816121f957fe5b0495945050505050565b6060612258826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612cec9092919063ffffffff16565b80519091501561193f5780806020019051810190612276919061317e565b61193f5760405162461bcd60e51b81526004016109409061369a565b60008060006122b46122a2610a3a565b610aff86670de0b6b3a7640000611749565b905060006122d6670de0b6b3a7640000610aff6122cf610a3a565b8990611749565b9050818611156122e8578195506122ec565b8094505b5093949293505050565b612317846323b872dd60e01b85858560405160240161190893929190613344565b50505050565b604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90612354908490600401613849565b600060405180830381600087803b15801561236e57600080fd5b505af1158015612382573d6000803e3d6000fd5b5050505060006060336001600160a01b0316836040516123a19061071a565b60006040518083038185875af1925050503d80600081146123de576040519150601f19603f3d011682016040523d82523d6000602084013e6123e3565b606091505b50915091508161193f5760405162461bcd60e51b8152600401610940906134e4565b61240d612f6b565b600b546040516370a0823160e01b81526001600160a01b03909116906370a082319061243d903090600401613316565b60206040518083038186803b15801561245557600080fd5b505afa158015612469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248d9190613287565b8152600c546040516370a0823160e01b81526001600160a01b03909116906370a08231906124bf903090600401613316565b60206040518083038186803b1580156124d757600080fd5b505afa1580156124eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250f9190613287565b6020820152600a5460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b15801561255957600080fd5b505afa15801561256d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259191906131b5565b505050505050905060006125a485611d56565b905060006125b185611d56565b90506125ec6125c583838760200151612c03565b6001600160801b03166125dd84848860000151612ba0565b6001600160801b03169061153a565b6001600160801b03166080850181905261260b90849084908490612131565b60608601526040850181905284516000911061262857600061262b565b60015b905060008161264c5760608601516020870151612647916118a7565b61265c565b6040860151865161265c916118a7565b905080156128755760008261267c57600c546001600160a01b0316612689565b600b546001600160a01b03165b90506126b46001600160a01b0382167368b3465833fb72a70ecdf485e0e4c7bd8665fc456000612cfb565b6126dc6001600160a01b0382167368b3465833fb72a70ecdf485e0e4c7bd8665fc4584612cfb565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc456001600160a01b03166304e45aaf6040518060e00160405280846001600160a01b031681526020018661272f57600b546001600160a01b031661273c565b600c546001600160a01b03165b6001600160a01b03168152602001600a60009054906101000a90046001600160a01b03166001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561279857600080fd5b505afa1580156127ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d0919061324c565b62ffffff168152602001306001600160a01b031681526020018581526020016000815260200160006001600160a01b03168152506040518263ffffffff1660e01b815260040161282091906137eb565b602060405180830381600087803b15801561283a57600080fd5b505af115801561284e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128729190613287565b50505b5050505050505050565b6000612889612f6b565b600b546040516370a0823160e01b81526001600160a01b03909116906370a08231906128b9903090600401613316565b60206040518083038186803b1580156128d157600080fd5b505afa1580156128e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129099190613287565b8152600c546040516370a0823160e01b81526001600160a01b03909116906370a082319061293b903090600401613316565b60206040518083038186803b15801561295357600080fd5b505afa158015612967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298b9190613287565b6020820152600a5460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b1580156129d557600080fd5b505afa1580156129e9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a0d91906131b5565b50505050505090506000612a27612a226107b3565b611d56565b90506000612a36612a22610f31565b9050612a4a6125c583838760200151612c03565b6001600160801b031660808501819052612a6990849084908490612131565b60608601526040850181905284511115612af557600b546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015612aa85750855b15612acc5760408401518451612ac791612ac291906118a7565b61231d565b612af5565b60408401518451612af5913391612ae2916118a7565b600b546001600160a01b031691906118e9565b836060015184602001511115612b8a57600c546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015612b305750855b15612b5857612b53612ac2856060015186602001516118a790919063ffffffff16565b612b8a565b612b8a33612b77866060015187602001516118a790919063ffffffff16565b600c546001600160a01b031691906118e9565b505050608001516001600160801b031692915050565b6000826001600160a01b0316846001600160a01b03161115612bc0579192915b6000612be3856001600160a01b0316856001600160a01b0316600160601b612dbe565b9050611479612bfe84838888036001600160a01b0316612dbe565b612e6d565b6000826001600160a01b0316846001600160a01b03161115612c23579192915b610876612bfe83600160601b8787036001600160a01b0316612dbe565b6000826001600160a01b0316846001600160a01b03161115612c60579192915b836001600160a01b0316612c99606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316612dbe565b81612ca057fe5b04949350505050565b6000826001600160a01b0316846001600160a01b03161115612cc9579192915b610876826001600160801b03168585036001600160a01b0316600160601b612dbe565b60606108768484600085612e83565b801580612d835750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90612d31903090869060040161332a565b60206040518083038186803b158015612d4957600080fd5b505afa158015612d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d819190613287565b155b612d9f5760405162461bcd60e51b81526004016109409061375e565b61193f8363095ea7b360e01b8484604051602401611908929190613368565b6000808060001985870986860292508281109083900303905080612df45760008411612de957600080fd5b508290049050610a33565b808411612e0057600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b806001600160801b0381168114610fa257600080fd5b6060612e8e85612f47565b612eaa5760405162461bcd60e51b815260040161094090613663565b60006060866001600160a01b03168587604051612ec791906132fa565b60006040518083038185875af1925050503d8060008114612f04576040519150601f19603f3d011682016040523d82523d6000602084013e612f09565b606091505b50915091508115612f1d5791506108769050565b805115612f2d5780518082602001fd5b8360405162461bcd60e51b815260040161094091906133d0565b3b151590565b60405180604001604052806002906020820280368337509192915050565b6040518060e001604052806000815260200160008152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b81525090565b8051600281900b811461085857600080fd5b805161ffff8116811461085857600080fd5b600060208284031215612fec578081fd5b8135610a338161389a565b60008060408385031215613009578081fd5b82356130148161389a565b915060208301356130248161389a565b809150509250929050565b600080600060608486031215613043578081fd5b833561304e8161389a565b9250602084013561305e8161389a565b929592945050506040919091013590565b60008060008060808587031215613084578081fd5b843561308f8161389a565b93506020858101356130a08161389a565b935060408601359250606086013567ffffffffffffffff808211156130c3578384fd5b818801915088601f8301126130d6578384fd5b8135818111156130e4578485fd5b604051601f8201601f1916810185018381118282101715613103578687fd5b60405281815283820185018b1015613119578586fd5b81858501868301379081019093019390935250939692955090935050565b60008060408385031215613149578182fd5b82356131548161389a565b946020939093013593505050565b600060208284031215613173578081fd5b8135610a33816138b2565b60006020828403121561318f578081fd5b8151610a33816138b2565b6000602082840312156131ab578081fd5b610a338383612fb7565b600080600080600080600060e0888a0312156131cf578283fd5b87516131da8161389a565b96506131e98960208a01612fb7565b95506131f88960408a01612fc9565b94506132078960608a01612fc9565b93506132168960808a01612fc9565b925060a088015160ff8116811461322b578283fd5b60c089015190925061323c816138b2565b8091505092959891949750929550565b60006020828403121561325d578081fd5b815162ffffff81168114610a33578182fd5b600060208284031215613280578081fd5b5035919050565b600060208284031215613298578081fd5b5051919050565b600080604083850312156132b1578182fd5b505080516020909101519092909150565b6000806000606084860312156132d6578081fd5b833592506020840135915060408401356132ef816138b2565b809150509250925092565b6000825161330c81846020870161386e565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b901515815260200190565b6001600160e01b031991909116815260200190565b60029190910b815260200190565b60006020825282518060208401526133ef81604085016020870161386e565b601f01601f19169190910160400192915050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252600b908201526a21676f7665726e616e636560a81b604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526014908201527308cc2d2d8cac840e8de40e4cacceadcc8408ae8d60631b604082015260600190565b6020808252601190820152706e6f206c6971756964697479206865726560781b604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600990820152682174696d656c6f636b60b81b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600690820152651c185d5cd95960d21b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c092830151169181019190915260e00190565b90815260200190565b918252602082015260400190565b60ff91909116815260200190565b60005b83811015613889578181015183820152602001613871565b838111156123175750506000910152565b6001600160a01b03811681146138af57600080fd5b50565b80151581146138af57600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220ec5a3b2ca5cc5d942f64d29376d14eefe506ab01900bf9bc7c08bc2266eb5ede64736f6c634300060c003300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000000000000088e0120f9e6652cc058aec07564f69000000000000000000000000000000000088e0120f9e6652cc058aec07564f690000000000000000000000007b5916c61bceeaa2646cf49d9541ac6f5dce3637000000000000000000000000000000000000000000000000000000000000001b7069636b6c696e6720555344432f45544820302e303525204a6172000000000000000000000000000000000000000000000000000000000000000000000000087055534443455448000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106102035760003560e01c806343a0d06611610118578063a9059cbb116100a0578063d33219b41161006f578063d33219b414610561578063d389800f14610576578063dd62ed3e1461058b578063ec1ebd7a146105ab578063f77c4791146105c057610203565b8063a9059cbb146104ec578063ab033ea91461050c578063bdacb3031461052c578063d21220a71461054c57610203565b806370a08231116100e757806370a0823114610462578063853828b61461048257806392eefe9b1461049757806395d89b41146104b7578063a457c2d7146104cc57610203565b806343a0d066146104105780635416da55146104235780635aa6e675146104385780635c975abb1461044d57610203565b806316f0115b1161019b5780632e1a7d4d1161016a5780632e1a7d4d14610384578063313ce567146103a457806339509351146103c65780633ced1929146103e65780633fc8cef3146103fb57610203565b806316f0115b1461032557806318160ddd1461033a57806323b872dd1461034f578063262c643b1461036f57610203565b80630dfe1681116101d75780630dfe1681146102a1578063150b7a02146102c357806315770f92146102f057806316c38b3c1461030557610203565b8062bf2b221461020557806306fdde031461023057806307fafb2814610252578063095ea7b314610274575b005b34801561021157600080fd5b5061021a6105d5565b6040516102279190613849565b60405180910390f35b34801561023c57600080fd5b5061024561071d565b60405161022791906133d0565b34801561025e57600080fd5b506102676107b3565b60405161022791906133c2565b34801561028057600080fd5b5061029461028f366004613137565b610840565b60405161022791906133a2565b3480156102ad57600080fd5b506102b661085e565b6040516102279190613316565b3480156102cf57600080fd5b506102e36102de36600461306f565b61086d565b60405161022791906133ad565b3480156102fc57600080fd5b5061021a61087e565b34801561031157600080fd5b50610203610320366004613162565b610916565b34801561033157600080fd5b506102b661099d565b34801561034657600080fd5b5061021a6109ac565b34801561035b57600080fd5b5061029461036a36600461302f565b6109b2565b34801561037b57600080fd5b5061021a610a3a565b34801561039057600080fd5b5061020361039f36600461326f565b610a8e565b3480156103b057600080fd5b506103b9610d56565b6040516102279190613860565b3480156103d257600080fd5b506102946103e1366004613137565b610d5f565b3480156103f257600080fd5b506102b6610dad565b34801561040757600080fd5b506102b6610dc5565b61020361041e3660046132c2565b610ddd565b34801561042f57600080fd5b50610267610f31565b34801561044457600080fd5b506102b6610f69565b34801561045957600080fd5b50610294610f78565b34801561046e57600080fd5b5061021a61047d366004612fdb565b610f88565b34801561048e57600080fd5b50610203610fa7565b3480156104a357600080fd5b506102036104b2366004612fdb565b610fb5565b3480156104c357600080fd5b50610245611001565b3480156104d857600080fd5b506102946104e7366004613137565b611062565b3480156104f857600080fd5b50610294610507366004613137565b6110ca565b34801561051857600080fd5b50610203610527366004612fdb565b6110de565b34801561053857600080fd5b50610203610547366004612fdb565b61112a565b34801561055857600080fd5b506102b6611176565b34801561056d57600080fd5b506102b6611185565b34801561058257600080fd5b50610203611194565b34801561059757600080fd5b5061021a6105a6366004612ff7565b61136d565b3480156105b757600080fd5b5061021a611398565b3480156105cc57600080fd5b506102b66113cd565b600b546040516370a0823160e01b815260009182916001600160a01b03909116906370a082319061060a903090600401613316565b60206040518083038186803b15801561062257600080fd5b505afa158015610636573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065a9190613287565b600c546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190610690903090600401613316565b60206040518083038186803b1580156106a857600080fd5b505afa1580156106bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e09190613287565b905061070c82826106ef6107b3565b6106f7610f31565b600a546001600160a01b0316939291906113dc565b6001600160801b0316925050505b90565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a95780601f1061077e576101008083540402835291602001916107a9565b820191906000526020600020905b81548152906001019060200180831161078c57829003601f168201915b5050505050905090565b600954600a546040516350314fd760e01b81526000926001600160a01b03908116926350314fd7926107eb9290911690600401613316565b60206040518083038186803b15801561080357600080fd5b505afa158015610817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083b919061319a565b905090565b600061085461084d611482565b8484611486565b5060015b92915050565b600b546001600160a01b031681565b630a85bd0160e11b5b949350505050565b600954600a54604051633c4750df60e01b815260009261083b926001600160a01b0391821692633c4750df926108b8921690600401613316565b60206040518083038186803b1580156108d057600080fd5b505afa1580156108e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109089190613287565b6109106105d5565b9061153a565b6007546001600160a01b031633146109495760405162461bcd60e51b815260040161094090613446565b60405180910390fd5b6009805460ff60a01b1916600160a01b831515021790556040517f531a84b8edb5c30911fd540c1446a6baf541a33418fcd124935d74f575dfc4c3906109929043904290613852565b60405180910390a150565b600a546001600160a01b031681565b60025490565b60006109bf84848461155f565b610a2f846109cb611482565b610a2a85604051806060016040528060288152602001613909602891396001600160a01b038a16600090815260016020526040812090610a09611482565b6001600160a01b031681526020810191909152604001600020549190611674565b611486565b5060015b9392505050565b6000806000610a6f670de0b6b3a7640000610a536107b3565b610a5b610f31565b600a546001600160a01b03169291906116a0565b915091508181670de0b6b3a76400000281610a8657fe5b049250505090565b60026006541415610ab15760405162461bcd60e51b815260040161094090613707565b6002600655600954600160a01b900460ff1615610ae05760405162461bcd60e51b81526004016109409061373e565b6000610b05610aed6109ac565b610aff84610af961087e565b90611749565b90611783565b9050600080610b1683610a536107b3565b91509150610b2433856117c5565b610b2c612f4d565b6040805180820191829052600b546370a0823160e01b9092529081906001600160a01b03166370a08231610b633060448501613316565b60206040518083038186803b158015610b7b57600080fd5b505afa158015610b8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb39190613287565b8152600c546040516370a0823160e01b81526020909201916001600160a01b03909116906370a0823190610beb903090600401613316565b60206040518083038186803b158015610c0357600080fd5b505afa158015610c17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3b9190613287565b905290506000610c496105d5565b905084811015610d1b576000610c5f86836118a7565b600954600a5460405163f3fef3a360e01b815292935060009283926001600160a01b039081169263f3fef3a392610c9e92909116908790600401613368565b6040805180830381600087803b158015610cb757600080fd5b505af1158015610ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cef919061329f565b9092509050610d07828660005b60200201519061153a565b9650610d1581866001610cfc565b95505050505b600b54610d32906001600160a01b031633866118e9565b600c54610d49906001600160a01b031633856118e9565b5050600160065550505050565b60055460ff1690565b6000610854610d6c611482565b84610a2a8560016000610d7d611482565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061153a565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc4581565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b60026006541415610e005760405162461bcd60e51b815260040161094090613707565b6002600655600954600160a01b900460ff1615610e2f5760405162461bcd60e51b81526004016109409061373e565b6000610e3b8484611944565b91955093509050600082610e5c57610e54858584611a28565b905080610e6b565b610e67858584611b2a565b9050805b506000610e766109ac565b610e81575080610f1f565b600954600a54604051633c4750df60e01b8152610f1c926001600160a01b0390811692633c4750df92610eba9290911690600401613316565b60206040518083038186803b158015610ed257600080fd5b505afa158015610ee6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0a9190613287565b610aff610f156109ac565b8590611749565b90505b610f293382611ca2565b610d49611194565b600954600a5460405163990ed59d60e01b81526000926001600160a01b039081169263990ed59d926107eb9290911690600401613316565b6007546001600160a01b031681565b600954600160a01b900460ff1681565b6001600160a01b0381166000908152602081905260409020545b919050565b610fb361039f33610f88565b565b6008546001600160a01b03163314610fdf5760405162461bcd60e51b8152600401610940906136e4565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a95780601f1061077e576101008083540402835291602001916107a9565b600061085461106f611482565b84610a2a856040518060600160405280602581526020016139316025913960016000611099611482565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611674565b60006108546110d7611482565b848461155f565b6007546001600160a01b031633146111085760405162461bcd60e51b815260040161094090613446565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6008546001600160a01b031633146111545760405162461bcd60e51b8152600401610940906136e4565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b600c546001600160a01b031681565b6008546001600160a01b031681565b600061119e6105d5565b116111bb5760405162461bcd60e51b815260040161094090613512565b600b546040516370a0823160e01b81526000916001600160a01b0316906370a08231906111ec903090600401613316565b60206040518083038186803b15801561120457600080fd5b505afa158015611218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123c9190613287565b600c546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190611272903090600401613316565b60206040518083038186803b15801561128a57600080fd5b505afa15801561129e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c29190613287565b600954600b549192506112e2916001600160a01b039081169116846118e9565b600954600c546112ff916001600160a01b039182169116836118e9565b600954600a546040516339ef272d60e01b81526001600160a01b03928316926339ef272d926113379291169086908690600401613381565b600060405180830381600087803b15801561135157600080fd5b505af1158015611365573d6000803e3d6000fd5b505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60006113a26109ac565b6113ae5750600061071a565b61083b6113b96109ac565b610aff670de0b6b3a7640000610af961087e565b6009546001600160a01b031681565b600080866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561141857600080fd5b505afa15801561142c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145091906131b5565b50505050505090506114758161146586611d56565b61146e86611d56565b898961206f565b9150505b95945050505050565b3390565b6001600160a01b0383166114ac5760405162461bcd60e51b81526004016109409061361f565b6001600160a01b0382166114d25760405162461bcd60e51b81526004016109409061346b565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061152d908590613849565b60405180910390a3505050565b600082820183811015610a335760405162461bcd60e51b8152600401610940906134ad565b6001600160a01b0383166115855760405162461bcd60e51b8152600401610940906135da565b6001600160a01b0382166115ab5760405162461bcd60e51b815260040161094090613403565b6115b683838361193f565b6115f3816040518060600160405280602681526020016138e3602691396001600160a01b0386166000908152602081905260409020549190611674565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611622908261153a565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061152d908590613849565b600081848411156116985760405162461bcd60e51b815260040161094091906133d0565b505050900390565b6000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156116de57600080fd5b505afa1580156116f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171691906131b5565b505050505050905061173a8161172b87611d56565b61173487611d56565b89612131565b92509250505b94509492505050565b60008261175857506000610858565b8282028284828161176557fe5b0414610a335760405162461bcd60e51b815260040161094090613558565b6000610a3383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506121cc565b6001600160a01b0382166117eb5760405162461bcd60e51b815260040161094090613599565b6117f78260008361193f565b611834816040518060600160405280602281526020016138c1602291396001600160a01b0385166000908152602081905260409020549190611674565b6001600160a01b03831660009081526020819052604090205560025461185a90826118a7565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061189b908590613849565b60405180910390a35050565b6000610a3383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611674565b61193f8363a9059cbb60e01b8484604051602401611908929190613368565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612203565b505050565b6000808080348015611a1c5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561199f57600080fd5b505af11580156119b3573d6000803e3d6000fd5b5050600b546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2141592506119ed9150505780965060019150611a1c565b600c546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611a1c57809550600191505b50949593949392505050565b6000806000611a378686612292565b90925090508115611a5a57600b54611a5a906001600160a01b03163330856122f6565b8015611a7857600c54611a78906001600160a01b03163330846122f6565b8315611b0a57600b546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611ac4576000611ab187846118a7565b90508015611ac257611ac28161231d565b505b600c546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611b0a576000611af786836118a7565b90508015611b0857611b088161231d565b505b611b1782826106ef6107b3565b6001600160801b03169695505050505050565b600b546040516370a0823160e01b815260009185916001600160a01b03909116906370a0823190611b5f903090600401613316565b60206040518083038186803b158015611b7757600080fd5b505afa158015611b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611baf9190613287565b108015611bbb57508315155b15611bd857600b54611bd8906001600160a01b03163330876122f6565b600c546040516370a0823160e01b815284916001600160a01b0316906370a0823190611c08903090600401613316565b60206040518083038186803b158015611c2057600080fd5b505afa158015611c34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c589190613287565b108015611c6457508215155b15611c8157600c54611c81906001600160a01b03163330866122f6565b611c99611c8c6107b3565b611c94610f31565b612405565b6108768261287f565b6001600160a01b038216611cc85760405162461bcd60e51b8152600401610940906137b4565b611cd46000838361193f565b600254611ce1908261153a565b6002556001600160a01b038216600090815260208190526040902054611d07908261153a565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061189b908590613849565b60008060008360020b12611d6d578260020b611d75565b8260020b6000035b9050620d89e8811115611d9a5760405162461bcd60e51b81526004016109409061353d565b600060018216611dae57600160801b611dc0565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615611df4576ffff97272373d413259a46990580e213a0260801c5b6004821615611e13576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615611e32576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611e51576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611e70576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611e8f576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611eae576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611ece576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615611eee576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615611f0e576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615611f2e576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611f4e576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611f6e576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611f8e576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611fae576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611fcf576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615611fef576e5d6af8dedb81196699c329225ee6040260801c5b6204000082161561200e576d2216e584f5fa1ea926041bedfe980260801c5b6208000082161561202b576b048a170391f7dc42444e8fa20260801c5b60008460020b131561204657806000198161204257fe5b0490505b64010000000081061561205a57600161205d565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b0316111561208f579293925b846001600160a01b0316866001600160a01b0316116120ba576120b3858585612ba0565b9050611479565b836001600160a01b0316866001600160a01b0316101561211c5760006120e1878686612ba0565b905060006120f0878986612c03565b9050806001600160801b0316826001600160801b0316106121115780612113565b815b92505050611479565b612127858584612c03565b9695505050505050565b600080836001600160a01b0316856001600160a01b03161115612152579293925b846001600160a01b0316866001600160a01b03161161217d57612176858585612c40565b9150611740565b836001600160a01b0316866001600160a01b031610156121b6576121a2868585612c40565b91506121af858785612ca9565b9050611740565b6121c1858585612ca9565b905094509492505050565b600081836121ed5760405162461bcd60e51b815260040161094091906133d0565b5060008385816121f957fe5b0495945050505050565b6060612258826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612cec9092919063ffffffff16565b80519091501561193f5780806020019051810190612276919061317e565b61193f5760405162461bcd60e51b81526004016109409061369a565b60008060006122b46122a2610a3a565b610aff86670de0b6b3a7640000611749565b905060006122d6670de0b6b3a7640000610aff6122cf610a3a565b8990611749565b9050818611156122e8578195506122ec565b8094505b5093949293505050565b612317846323b872dd60e01b85858560405160240161190893929190613344565b50505050565b604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90612354908490600401613849565b600060405180830381600087803b15801561236e57600080fd5b505af1158015612382573d6000803e3d6000fd5b5050505060006060336001600160a01b0316836040516123a19061071a565b60006040518083038185875af1925050503d80600081146123de576040519150601f19603f3d011682016040523d82523d6000602084013e6123e3565b606091505b50915091508161193f5760405162461bcd60e51b8152600401610940906134e4565b61240d612f6b565b600b546040516370a0823160e01b81526001600160a01b03909116906370a082319061243d903090600401613316565b60206040518083038186803b15801561245557600080fd5b505afa158015612469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248d9190613287565b8152600c546040516370a0823160e01b81526001600160a01b03909116906370a08231906124bf903090600401613316565b60206040518083038186803b1580156124d757600080fd5b505afa1580156124eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250f9190613287565b6020820152600a5460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b15801561255957600080fd5b505afa15801561256d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259191906131b5565b505050505050905060006125a485611d56565b905060006125b185611d56565b90506125ec6125c583838760200151612c03565b6001600160801b03166125dd84848860000151612ba0565b6001600160801b03169061153a565b6001600160801b03166080850181905261260b90849084908490612131565b60608601526040850181905284516000911061262857600061262b565b60015b905060008161264c5760608601516020870151612647916118a7565b61265c565b6040860151865161265c916118a7565b905080156128755760008261267c57600c546001600160a01b0316612689565b600b546001600160a01b03165b90506126b46001600160a01b0382167368b3465833fb72a70ecdf485e0e4c7bd8665fc456000612cfb565b6126dc6001600160a01b0382167368b3465833fb72a70ecdf485e0e4c7bd8665fc4584612cfb565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc456001600160a01b03166304e45aaf6040518060e00160405280846001600160a01b031681526020018661272f57600b546001600160a01b031661273c565b600c546001600160a01b03165b6001600160a01b03168152602001600a60009054906101000a90046001600160a01b03166001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561279857600080fd5b505afa1580156127ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d0919061324c565b62ffffff168152602001306001600160a01b031681526020018581526020016000815260200160006001600160a01b03168152506040518263ffffffff1660e01b815260040161282091906137eb565b602060405180830381600087803b15801561283a57600080fd5b505af115801561284e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128729190613287565b50505b5050505050505050565b6000612889612f6b565b600b546040516370a0823160e01b81526001600160a01b03909116906370a08231906128b9903090600401613316565b60206040518083038186803b1580156128d157600080fd5b505afa1580156128e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129099190613287565b8152600c546040516370a0823160e01b81526001600160a01b03909116906370a082319061293b903090600401613316565b60206040518083038186803b15801561295357600080fd5b505afa158015612967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298b9190613287565b6020820152600a5460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b1580156129d557600080fd5b505afa1580156129e9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a0d91906131b5565b50505050505090506000612a27612a226107b3565b611d56565b90506000612a36612a22610f31565b9050612a4a6125c583838760200151612c03565b6001600160801b031660808501819052612a6990849084908490612131565b60608601526040850181905284511115612af557600b546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015612aa85750855b15612acc5760408401518451612ac791612ac291906118a7565b61231d565b612af5565b60408401518451612af5913391612ae2916118a7565b600b546001600160a01b031691906118e9565b836060015184602001511115612b8a57600c546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015612b305750855b15612b5857612b53612ac2856060015186602001516118a790919063ffffffff16565b612b8a565b612b8a33612b77866060015187602001516118a790919063ffffffff16565b600c546001600160a01b031691906118e9565b505050608001516001600160801b031692915050565b6000826001600160a01b0316846001600160a01b03161115612bc0579192915b6000612be3856001600160a01b0316856001600160a01b0316600160601b612dbe565b9050611479612bfe84838888036001600160a01b0316612dbe565b612e6d565b6000826001600160a01b0316846001600160a01b03161115612c23579192915b610876612bfe83600160601b8787036001600160a01b0316612dbe565b6000826001600160a01b0316846001600160a01b03161115612c60579192915b836001600160a01b0316612c99606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316612dbe565b81612ca057fe5b04949350505050565b6000826001600160a01b0316846001600160a01b03161115612cc9579192915b610876826001600160801b03168585036001600160a01b0316600160601b612dbe565b60606108768484600085612e83565b801580612d835750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90612d31903090869060040161332a565b60206040518083038186803b158015612d4957600080fd5b505afa158015612d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d819190613287565b155b612d9f5760405162461bcd60e51b81526004016109409061375e565b61193f8363095ea7b360e01b8484604051602401611908929190613368565b6000808060001985870986860292508281109083900303905080612df45760008411612de957600080fd5b508290049050610a33565b808411612e0057600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b806001600160801b0381168114610fa257600080fd5b6060612e8e85612f47565b612eaa5760405162461bcd60e51b815260040161094090613663565b60006060866001600160a01b03168587604051612ec791906132fa565b60006040518083038185875af1925050503d8060008114612f04576040519150601f19603f3d011682016040523d82523d6000602084013e612f09565b606091505b50915091508115612f1d5791506108769050565b805115612f2d5780518082602001fd5b8360405162461bcd60e51b815260040161094091906133d0565b3b151590565b60405180604001604052806002906020820280368337509192915050565b6040518060e001604052806000815260200160008152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b81525090565b8051600281900b811461085857600080fd5b805161ffff8116811461085857600080fd5b600060208284031215612fec578081fd5b8135610a338161389a565b60008060408385031215613009578081fd5b82356130148161389a565b915060208301356130248161389a565b809150509250929050565b600080600060608486031215613043578081fd5b833561304e8161389a565b9250602084013561305e8161389a565b929592945050506040919091013590565b60008060008060808587031215613084578081fd5b843561308f8161389a565b93506020858101356130a08161389a565b935060408601359250606086013567ffffffffffffffff808211156130c3578384fd5b818801915088601f8301126130d6578384fd5b8135818111156130e4578485fd5b604051601f8201601f1916810185018381118282101715613103578687fd5b60405281815283820185018b1015613119578586fd5b81858501868301379081019093019390935250939692955090935050565b60008060408385031215613149578182fd5b82356131548161389a565b946020939093013593505050565b600060208284031215613173578081fd5b8135610a33816138b2565b60006020828403121561318f578081fd5b8151610a33816138b2565b6000602082840312156131ab578081fd5b610a338383612fb7565b600080600080600080600060e0888a0312156131cf578283fd5b87516131da8161389a565b96506131e98960208a01612fb7565b95506131f88960408a01612fc9565b94506132078960608a01612fc9565b93506132168960808a01612fc9565b925060a088015160ff8116811461322b578283fd5b60c089015190925061323c816138b2565b8091505092959891949750929550565b60006020828403121561325d578081fd5b815162ffffff81168114610a33578182fd5b600060208284031215613280578081fd5b5035919050565b600060208284031215613298578081fd5b5051919050565b600080604083850312156132b1578182fd5b505080516020909101519092909150565b6000806000606084860312156132d6578081fd5b833592506020840135915060408401356132ef816138b2565b809150509250925092565b6000825161330c81846020870161386e565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b901515815260200190565b6001600160e01b031991909116815260200190565b60029190910b815260200190565b60006020825282518060208401526133ef81604085016020870161386e565b601f01601f19169190910160400192915050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252600b908201526a21676f7665726e616e636560a81b604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526014908201527308cc2d2d8cac840e8de40e4cacceadcc8408ae8d60631b604082015260600190565b6020808252601190820152706e6f206c6971756964697479206865726560781b604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600990820152682174696d656c6f636b60b81b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600690820152651c185d5cd95960d21b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c092830151169181019190915260e00190565b90815260200190565b918252602082015260400190565b60ff91909116815260200190565b60005b83811015613889578181015183820152602001613871565b838111156123175750506000910152565b6001600160a01b03811681146138af57600080fd5b50565b80151581146138af57600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220ec5a3b2ca5cc5d942f64d29376d14eefe506ab01900bf9bc7c08bc2266eb5ede64736f6c634300060c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000000000000088e0120f9e6652cc058aec07564f69000000000000000000000000000000000088e0120f9e6652cc058aec07564f690000000000000000000000007b5916c61bceeaa2646cf49d9541ac6f5dce3637000000000000000000000000000000000000000000000000000000000000001b7069636b6c696e6720555344432f45544820302e303525204a6172000000000000000000000000000000000000000000000000000000000000000000000000087055534443455448000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _name (string): pickling USDC/ETH 0.05% Jar
Arg [1] : _symbol (string): pUSDCETH
Arg [2] : _pool (address): 0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640
Arg [3] : _governance (address): 0x000000000088E0120F9E6652CC058AeC07564F69
Arg [4] : _timelock (address): 0x000000000088E0120F9E6652CC058AeC07564F69
Arg [5] : _controller (address): 0x7B5916C61bCEeaa2646cf49D9541ac6F5DCe3637
-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [2] : 00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640
Arg [3] : 000000000000000000000000000000000088e0120f9e6652cc058aec07564f69
Arg [4] : 000000000000000000000000000000000088e0120f9e6652cc058aec07564f69
Arg [5] : 0000000000000000000000007b5916c61bceeaa2646cf49d9541ac6f5dce3637
Arg [6] : 000000000000000000000000000000000000000000000000000000000000001b
Arg [7] : 7069636b6c696e6720555344432f45544820302e303525204a61720000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000008
Arg [9] : 7055534443455448000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.