UNPKG

moonwalkerswap-v1-core

Version:
954 lines 912 kB
{ "contractName": "TickMath", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"stateVariables\":{\"MAX_SQRT_RATIO\":{\"details\":\"The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\"},\"MAX_TICK\":{\"details\":\"The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\"},\"MIN_SQRT_RATIO\":{\"details\":\"The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\"},\"MIN_TICK\":{\"details\":\"The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\"}},\"title\":\"Math library for computing sqrt prices from ticks and vice versa\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"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\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/TickMath.sol\":\"TickMath\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/TickMath.sol\":{\"keccak256\":\"0x1f864a2bf61ba05f3173eaf2e3f94c5e1da4bec0554757527b6d1ef1fe439e4e\",\"license\":\"GPL-2.0-or-later\",\"urls\":[\"bzz-raw://5139b586df546a9d1c46804ca400b1cb9ce87236eaf212ebd64edee6747a172a\",\"dweb:/ipfs/QmVa2kcRw3VyuB6j1EVWXACKnkbQZgfXYXNi5voq3XkYG8\"]}},\"version\":1}", "bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204cf495d4e0c9d616382caaabacdbd41c44aa86a9a0c55cf1ef61d4d7e41e2f9c64736f6c63430007060033", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204cf495d4e0c9d616382caaabacdbd41c44aa86a9a0c55cf1ef61d4d7e41e2f9c64736f6c63430007060033", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "306:8331:30:-:0;;;;;;;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "306:8331:30:-:0;;;;;;;;", "source": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Math library for computing sqrt prices from ticks and vice versa\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n/// prices between 2**-128 and 2**128\nlibrary TickMath {\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\n int24 internal constant MIN_TICK = -887272;\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\n int24 internal constant MAX_TICK = -MIN_TICK;\n\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\n /// @dev Throws if |tick| > max tick\n /// @param tick The input tick for the above formula\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\n /// at the given tick\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n require(absTick <= uint256(MAX_TICK), 'T');\n\n uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;\n if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\n if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\n if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\n\n if (tick > 0) ratio = type(uint256).max / ratio;\n\n // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\n // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\n // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\n sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));\n }\n\n /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\n /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\n /// ever return.\n /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\n /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\n function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\n // second inequality must be < because the price can never reach the price at the max tick\n require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R');\n uint256 ratio = uint256(sqrtPriceX96) << 32;\n\n uint256 r = ratio;\n uint256 msb = 0;\n\n assembly {\n let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(5, gt(r, 0xFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(4, gt(r, 0xFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(3, gt(r, 0xFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(2, gt(r, 0xF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(1, gt(r, 0x3))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := gt(r, 0x1)\n msb := or(msb, f)\n }\n\n if (msb >= 128) r = ratio >> (msb - 127);\n else r = ratio << (127 - msb);\n\n int256 log_2 = (int256(msb) - 128) << 64;\n\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(63, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(62, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(61, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(60, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(59, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(58, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(57, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(56, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(55, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(54, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(53, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(52, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(51, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(50, f))\n }\n\n int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\n\n int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);\n int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);\n\n tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;\n }\n}\n", "sourcePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/TickMath.sol", "ast": { "absolutePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/TickMath.sol", "exportedSymbols": { "TickMath": [ 7170 ] }, "id": 7171, "license": "GPL-2.0-or-later", "nodeType": "SourceUnit", "nodes": [ { "id": 6637, "literals": [ "solidity", ">=", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "45:24:30" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": { "id": 6638, "nodeType": "StructuredDocumentation", "src": "71:235:30", "text": "@title Math library for computing sqrt prices from ticks and vice versa\n @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n prices between 2**-128 and 2**128" }, "fullyImplemented": true, "id": 7170, "linearizedBaseContracts": [ 7170 ], "name": "TickMath", "nodeType": "ContractDefinition", "nodes": [ { "constant": true, "documentation": { "id": 6639, "nodeType": "StructuredDocumentation", "src": "329:108:30", "text": "@dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128" }, "id": 6643, "mutability": "constant", "name": "MIN_TICK", "nodeType": "VariableDeclaration", "scope": 7170, "src": "442:42:30", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" }, "typeName": { "id": 6640, "name": "int24", "nodeType": "ElementaryTypeName", "src": "442:5:30", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } }, "value": { "id": 6642, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "UnaryOperation", "operator": "-", "prefix": true, "src": "477:7:30", "subExpression": { "hexValue": "383837323732", "id": 6641, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "478:6:30", "typeDescriptions": { "typeIdentifier": "t_rational_887272_by_1", "typeString": "int_const 887272" }, "value": "887272" }, "typeDescriptions": { "typeIdentifier": "t_rational_minus_887272_by_1", "typeString": "int_const -887272" } }, "visibility": "internal" }, { "constant": true, "documentation": { "id": 6644, "nodeType": "StructuredDocumentation", "src": "490:107:30", "text": "@dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128" }, "id": 6648, "mutability": "constant", "name": "MAX_TICK", "nodeType": "VariableDeclaration", "scope": 7170, "src": "602:44:30", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" }, "typeName": { "id": 6645, "name": "int24", "nodeType": "ElementaryTypeName", "src": "602:5:30", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } }, "value": { "id": 6647, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "UnaryOperation", "operator": "-", "prefix": true, "src": "637:9:30", "subExpression": { "id": 6646, "name": "MIN_TICK", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6643, "src": "638:8:30", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } }, "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } }, "visibility": "internal" }, { "constant": true, "documentation": { "id": 6649, "nodeType": "StructuredDocumentation", "src": "653:116:30", "text": "@dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)" }, "id": 6652, "mutability": "constant", "name": "MIN_SQRT_RATIO", "nodeType": "VariableDeclaration", "scope": 7170, "src": "774:53:30", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" }, "typeName": { "id": 6650, "name": "uint160", "nodeType": "ElementaryTypeName", "src": "774:7:30", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" } }, "value": { "hexValue": "34323935313238373339", "id": 6651, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "817:10:30", "typeDescriptions": { "typeIdentifier": "t_rational_4295128739_by_1", "typeString": "int_const 4295128739" }, "value": "4295128739" }, "visibility": "internal" }, { "constant": true, "documentation": { "id": 6653, "nodeType": "StructuredDocumentation", "src": "833:116:30", "text": "@dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)" }, "id": 6656, "mutability": "constant", "name": "MAX_SQRT_RATIO", "nodeType": "VariableDeclaration", "scope": 7170, "src": "954:92:30", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" }, "typeName": { "id": 6654, "name": "uint160", "nodeType": "ElementaryTypeName", "src": "954:7:30", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" } }, "value": { "hexValue": "31343631343436373033343835323130313033323837323733303532323033393838383232333738373233393730333432", "id": 6655, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "997:49:30", "typeDescriptions": { "typeIdentifier": "t_rational_1461446703485210103287273052203988822378723970342_by_1", "typeString": "int_const 1461...(41 digits omitted)...0342" }, "value": "1461446703485210103287273052203988822378723970342" }, "visibility": "internal" }, { "body": { "id": 7029, "nodeType": "Block", "src": "1440:2495:30", "statements": [ { "assignments": [ 6665 ], "declarations": [ { "constant": false, "id": 6665, "mutability": "mutable", "name": "absTick", "nodeType": "VariableDeclaration", "scope": 7029, "src": "1450:15:30", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 6664, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1450:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" } ], "id": 6685, "initialValue": { "condition": { "commonType": { "typeIdentifier": "t_int24", "typeString": "int24" }, "id": 6668, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 6666, "name": "tick", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6659, "src": "1468:4:30", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "hexValue": "30", "id": 6667, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1475:1:30", "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1468:8:30", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseExpression": { "arguments": [ { "arguments": [ { "id": 6681, "name": "tick", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6659, "src": "1519:4:30", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int24", "typeString": "int24" } ], "id": 6680, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1512:6:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_int256_$", "typeString": "type(int256)" }, "typeName": { "id": 6679, "name": "int256", "nodeType": "ElementaryTypeName", "src": "1512:6:30", "typeDescriptions": {} } }, "id": 6682, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1512:12:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int256", "typeString": "int256" } ], "id": 6678, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1504:7:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint256_$", "typeString": "type(uint256)" }, "typeName": { "id": 6677, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1504:7:30", "typeDescriptions": {} } }, "id": 6683, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1504:21:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 6684, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "Conditional", "src": "1468:57:30", "trueExpression": { "arguments": [ { "id": 6675, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "UnaryOperation", "operator": "-", "prefix": true, "src": "1487:13:30", "subExpression": { "arguments": [ { "id": 6673, "name": "tick", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6659, "src": "1495:4:30", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int24", "typeString": "int24" } ], "id": 6672, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1488:6:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_int256_$", "typeString": "type(int256)" }, "typeName": { "id": 6671, "name": "int256", "nodeType": "ElementaryTypeName", "src": "1488:6:30", "typeDescriptions": {} } }, "id": 6674, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1488:12:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int256", "typeString": "int256" } ], "id": 6670, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1479:7:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint256_$", "typeString": "type(uint256)" }, "typeName": { "id": 6669, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1479:7:30", "typeDescriptions": {} } }, "id": 6676, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1479:22:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "1450:75:30" }, { "expression": { "arguments": [ { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 6692, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 6687, "name": "absTick", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6665, "src": "1543:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<=", "rightExpression": { "arguments": [ { "id": 6690, "name": "MAX_TICK", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6648, "src": "1562:8:30", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int24", "typeString": "int24" } ], "id": 6689, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1554:7:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint256_$", "typeString": "type(uint256)" }, "typeName": { "id": 6688, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1554:7:30", "typeDescriptions": {} } }, "id": 6691, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1554:17:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1543:28:30", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "hexValue": "54", "id": 6693, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "1573:3:30", "typeDescriptions": { "typeIdentifier": "t_stringliteral_846b7b6deb1cfa110d0ea7ec6162a7123b761785528db70cceed5143183b11fc", "typeString": "literal_string \"T\"" }, "value": "T" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_846b7b6deb1cfa110d0ea7ec6162a7123b761785528db70cceed5143183b11fc", "typeString": "literal_string \"T\"" } ], "id": 6686, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 4294967278, 4294967278 ], "referencedDeclaration": 4294967278, "src": "1535:7:30", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 6694, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1535:42:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 6695, "nodeType": "ExpressionStatement", "src": "1535:42:30" }, { "assignments": [ 6697 ], "declarations": [ { "constant": false, "id": 6697, "mutability": "mutable", "name": "ratio", "nodeType": "VariableDeclaration", "scope": 7029, "src": "1588:13:30", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 6696, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1588:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" } ], "id": 6706, "initialValue": { "condition": { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 6702, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 6700, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 6698, "name": "absTick", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6665, "src": "1604:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "&", "rightExpression": { "hexValue": "307831", "id": 6699, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1614:3:30", "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "0x1" }, "src": "1604:13:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "hexValue": "30", "id": 6701, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1621:1:30", "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1604:18:30", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseExpression": { "hexValue": "3078313030303030303030303030303030303030303030303030303030303030303030", "id": 6704, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1662:35:30", "typeDescriptions": { "typeIdentifier": "t_rational_340282366920938463463374607431768211456_by_1", "typeString": "int_const 3402...(31 digits omitted)...1456" }, "value": "0x100000000000000000000000000000000" }, "id": 6705, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "Conditional", "src": "1604:93:30", "trueExpression": { "hexValue": "30786666666362393333626436666164333761613264313632643161353934303031", "id": 6703, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1625:34:30", "typeDescriptions": { "typeIdentifier": "t_rational_340265354078544963557816517032075149313_by_1", "typeString": "int_const 3402...(31 digits omitted)...9313" }, "value": "0xfffcb933bd6fad37aa2d162d1a594001" }, "typeDescriptions": { "typeIdentifier": "t_uint136", "typeString": "uint136" } }, "nodeType": "VariableDeclarationStatement", "src": "1588:109:30" }, { "condition": { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 6711, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 6709, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 6707, "name": "absTick", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6665, "src": "1711:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "&", "rightExpression": { "hexValue": "307832", "id": 6708, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1721:3:30", "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, "value": "0x2" }, "src": "1711:13:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeSt