UNPKG

moonwalkerswap-v1-core

Version:
680 lines (679 loc) 930 kB
{ "contractName": "Oracle", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Instances of stored oracle data, \\\"observations\\\", are collected in the oracle array Every pool is initialized with an oracle array length of 1. Anyone can pay the SSTOREs to increase the maximum length of the oracle array. New slots will be added when the array is fully populated. Observations are overwritten when the full length of the oracle array is populated. The most recent observation is available, independent of the length of the oracle array, by passing 0 to observe()\",\"kind\":\"dev\",\"methods\":{},\"title\":\"Oracle\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"Provides price and liquidity data useful for a wide variety of system designs\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/Oracle.sol\":\"Oracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/Oracle.sol\":{\"keccak256\":\"0x727f859fedfcb0402e648407042c022e3fa6568cb137ead98606166f10311772\",\"license\":\"BUSL-1.1\",\"urls\":[\"bzz-raw://d5500452fc47f728c5aff23fdecd19ce1083dc7562d7cc241a7e3b6740ded8c2\",\"dweb:/ipfs/QmXPCRHEn68oEM8uMMiWYScGtaUwfkN2DuajiAyzTgHnaF\"]}},\"version\":1}", "bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209476a22fac39f0ecc82f408d03ef8e24819954990735a975cddf52e109b96bd364736f6c63430007060033", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209476a22fac39f0ecc82f408d03ef8e24819954990735a975cddf52e109b96bd364736f6c63430007060033", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "676:15731:23:-:0;;;;;;;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "676:15731:23:-:0;;;;;;;;", "source": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.5.0;\n\n/// @title Oracle\n/// @notice Provides price and liquidity data useful for a wide variety of system designs\n/// @dev Instances of stored oracle data, \"observations\", are collected in the oracle array\n/// Every pool is initialized with an oracle array length of 1. Anyone can pay the SSTOREs to increase the\n/// maximum length of the oracle array. New slots will be added when the array is fully populated.\n/// Observations are overwritten when the full length of the oracle array is populated.\n/// The most recent observation is available, independent of the length of the oracle array, by passing 0 to observe()\nlibrary Oracle {\n struct Observation {\n // the block timestamp of the observation\n uint32 blockTimestamp;\n // the tick accumulator, i.e. tick * time elapsed since the pool was first initialized\n int56 tickCumulative;\n // the seconds per liquidity, i.e. seconds elapsed / max(1, liquidity) since the pool was first initialized\n uint160 secondsPerLiquidityCumulativeX128;\n // whether or not the observation is initialized\n bool initialized;\n }\n\n /// @notice Transforms a previous observation into a new observation, given the passage of time and the current tick and liquidity values\n /// @dev blockTimestamp _must_ be chronologically equal to or greater than last.blockTimestamp, safe for 0 or 1 overflows\n /// @param last The specified observation to be transformed\n /// @param blockTimestamp The timestamp of the new observation\n /// @param tick The active tick at the time of the new observation\n /// @param liquidity The total in-range liquidity at the time of the new observation\n /// @return Observation The newly populated observation\n function transform(\n Observation memory last,\n uint32 blockTimestamp,\n int24 tick,\n uint128 liquidity\n ) private pure returns (Observation memory) {\n uint32 delta = blockTimestamp - last.blockTimestamp;\n return\n Observation({\n blockTimestamp: blockTimestamp,\n tickCumulative: last.tickCumulative + int56(tick) * delta,\n secondsPerLiquidityCumulativeX128: last.secondsPerLiquidityCumulativeX128 +\n ((uint160(delta) << 128) / (liquidity > 0 ? liquidity : 1)),\n initialized: true\n });\n }\n\n /// @notice Initialize the oracle array by writing the first slot. Called once for the lifecycle of the observations array\n /// @param self The stored oracle array\n /// @param time The time of the oracle initialization, via block.timestamp truncated to uint32\n /// @return cardinality The number of populated elements in the oracle array\n /// @return cardinalityNext The new length of the oracle array, independent of population\n function initialize(Observation[65535] storage self, uint32 time)\n internal\n returns (uint16 cardinality, uint16 cardinalityNext)\n {\n self[0] = Observation({\n blockTimestamp: time,\n tickCumulative: 0,\n secondsPerLiquidityCumulativeX128: 0,\n initialized: true\n });\n return (1, 1);\n }\n\n /// @notice Writes an oracle observation to the array\n /// @dev Writable at most once per block. Index represents the most recently written element. cardinality and index must be tracked externally.\n /// If the index is at the end of the allowable array length (according to cardinality), and the next cardinality\n /// is greater than the current one, cardinality may be increased. This restriction is created to preserve ordering.\n /// @param self The stored oracle array\n /// @param index The index of the observation that was most recently written to the observations array\n /// @param blockTimestamp The timestamp of the new observation\n /// @param tick The active tick at the time of the new observation\n /// @param liquidity The total in-range liquidity at the time of the new observation\n /// @param cardinality The number of populated elements in the oracle array\n /// @param cardinalityNext The new length of the oracle array, independent of population\n /// @return indexUpdated The new index of the most recently written element in the oracle array\n /// @return cardinalityUpdated The new cardinality of the oracle array\n function write(\n Observation[65535] storage self,\n uint16 index,\n uint32 blockTimestamp,\n int24 tick,\n uint128 liquidity,\n uint16 cardinality,\n uint16 cardinalityNext\n ) internal returns (uint16 indexUpdated, uint16 cardinalityUpdated) {\n Observation memory last = self[index];\n\n // early return if we've already written an observation this block\n if (last.blockTimestamp == blockTimestamp) return (index, cardinality);\n\n // if the conditions are right, we can bump the cardinality\n if (cardinalityNext > cardinality && index == (cardinality - 1)) {\n cardinalityUpdated = cardinalityNext;\n } else {\n cardinalityUpdated = cardinality;\n }\n\n indexUpdated = (index + 1) % cardinalityUpdated;\n self[indexUpdated] = transform(last, blockTimestamp, tick, liquidity);\n }\n\n /// @notice Prepares the oracle array to store up to `next` observations\n /// @param self The stored oracle array\n /// @param current The current next cardinality of the oracle array\n /// @param next The proposed next cardinality which will be populated in the oracle array\n /// @return next The next cardinality which will be populated in the oracle array\n function grow(\n Observation[65535] storage self,\n uint16 current,\n uint16 next\n ) internal returns (uint16) {\n require(current > 0, 'I');\n // no-op if the passed next value isn't greater than the current next value\n if (next <= current) return current;\n // store in each slot to prevent fresh SSTOREs in swaps\n // this data will not be used because the initialized boolean is still false\n for (uint16 i = current; i < next; i++) self[i].blockTimestamp = 1;\n return next;\n }\n\n /// @notice comparator for 32-bit timestamps\n /// @dev safe for 0 or 1 overflows, a and b _must_ be chronologically before or equal to time\n /// @param time A timestamp truncated to 32 bits\n /// @param a A comparison timestamp from which to determine the relative position of `time`\n /// @param b From which to determine the relative position of `time`\n /// @return bool Whether `a` is chronologically <= `b`\n function lte(\n uint32 time,\n uint32 a,\n uint32 b\n ) private pure returns (bool) {\n // if there hasn't been overflow, no need to adjust\n if (a <= time && b <= time) return a <= b;\n\n uint256 aAdjusted = a > time ? a : a + 2**32;\n uint256 bAdjusted = b > time ? b : b + 2**32;\n\n return aAdjusted <= bAdjusted;\n }\n\n /// @notice Fetches the observations beforeOrAt and atOrAfter a target, i.e. where [beforeOrAt, atOrAfter] is satisfied.\n /// The result may be the same observation, or adjacent observations.\n /// @dev The answer must be contained in the array, used when the target is located within the stored observation\n /// boundaries: older than the most recent observation and younger, or the same age as, the oldest observation\n /// @param self The stored oracle array\n /// @param time The current block.timestamp\n /// @param target The timestamp at which the reserved observation should be for\n /// @param index The index of the observation that was most recently written to the observations array\n /// @param cardinality The number of populated elements in the oracle array\n /// @return beforeOrAt The observation recorded before, or at, the target\n /// @return atOrAfter The observation recorded at, or after, the target\n function binarySearch(\n Observation[65535] storage self,\n uint32 time,\n uint32 target,\n uint16 index,\n uint16 cardinality\n ) private view returns (Observation memory beforeOrAt, Observation memory atOrAfter) {\n uint256 l = (index + 1) % cardinality; // oldest observation\n uint256 r = l + cardinality - 1; // newest observation\n uint256 i;\n while (true) {\n i = (l + r) / 2;\n\n beforeOrAt = self[i % cardinality];\n\n // we've landed on an uninitialized tick, keep searching higher (more recently)\n if (!beforeOrAt.initialized) {\n l = i + 1;\n continue;\n }\n\n atOrAfter = self[(i + 1) % cardinality];\n\n bool targetAtOrAfter = lte(time, beforeOrAt.blockTimestamp, target);\n\n // check if we've found the answer!\n if (targetAtOrAfter && lte(time, target, atOrAfter.blockTimestamp)) break;\n\n if (!targetAtOrAfter) r = i - 1;\n else l = i + 1;\n }\n }\n\n /// @notice Fetches the observations beforeOrAt and atOrAfter a given target, i.e. where [beforeOrAt, atOrAfter] is satisfied\n /// @dev Assumes there is at least 1 initialized observation.\n /// Used by observeSingle() to compute the counterfactual accumulator values as of a given block timestamp.\n /// @param self The stored oracle array\n /// @param time The current block.timestamp\n /// @param target The timestamp at which the reserved observation should be for\n /// @param tick The active tick at the time of the returned or simulated observation\n /// @param index The index of the observation that was most recently written to the observations array\n /// @param liquidity The total pool liquidity at the time of the call\n /// @param cardinality The number of populated elements in the oracle array\n /// @return beforeOrAt The observation which occurred at, or before, the given timestamp\n /// @return atOrAfter The observation which occurred at, or after, the given timestamp\n function getSurroundingObservations(\n Observation[65535] storage self,\n uint32 time,\n uint32 target,\n int24 tick,\n uint16 index,\n uint128 liquidity,\n uint16 cardinality\n ) private view returns (Observation memory beforeOrAt, Observation memory atOrAfter) {\n // optimistically set before to the newest observation\n beforeOrAt = self[index];\n\n // if the target is chronologically at or after the newest observation, we can early return\n if (lte(time, beforeOrAt.blockTimestamp, target)) {\n if (beforeOrAt.blockTimestamp == target) {\n // if newest observation equals target, we're in the same block, so we can ignore atOrAfter\n return (beforeOrAt, atOrAfter);\n } else {\n // otherwise, we need to transform\n return (beforeOrAt, transform(beforeOrAt, target, tick, liquidity));\n }\n }\n\n // now, set before to the oldest observation\n beforeOrAt = self[(index + 1) % cardinality];\n if (!beforeOrAt.initialized) beforeOrAt = self[0];\n\n // ensure that the target is chronologically at or after the oldest observation\n require(lte(time, beforeOrAt.blockTimestamp, target), 'OLD');\n\n // if we've reached this point, we have to binary search\n return binarySearch(self, time, target, index, cardinality);\n }\n\n /// @dev Reverts if an observation at or before the desired observation timestamp does not exist.\n /// 0 may be passed as `secondsAgo' to return the current cumulative values.\n /// If called with a timestamp falling between two observations, returns the counterfactual accumulator values\n /// at exactly the timestamp between the two observations.\n /// @param self The stored oracle array\n /// @param time The current block timestamp\n /// @param secondsAgo The amount of time to look back, in seconds, at which point to return an observation\n /// @param tick The current tick\n /// @param index The index of the observation that was most recently written to the observations array\n /// @param liquidity The current in-range pool liquidity\n /// @param cardinality The number of populated elements in the oracle array\n /// @return tickCumulative The tick * time elapsed since the pool was first initialized, as of `secondsAgo`\n /// @return secondsPerLiquidityCumulativeX128 The time elapsed / max(1, liquidity) since the pool was first initialized, as of `secondsAgo`\n function observeSingle(\n Observation[65535] storage self,\n uint32 time,\n uint32 secondsAgo,\n int24 tick,\n uint16 index,\n uint128 liquidity,\n uint16 cardinality\n ) internal view returns (int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) {\n if (secondsAgo == 0) {\n Observation memory last = self[index];\n if (last.blockTimestamp != time) last = transform(last, time, tick, liquidity);\n return (last.tickCumulative, last.secondsPerLiquidityCumulativeX128);\n }\n\n uint32 target = time - secondsAgo;\n\n (Observation memory beforeOrAt, Observation memory atOrAfter) =\n getSurroundingObservations(self, time, target, tick, index, liquidity, cardinality);\n\n if (target == beforeOrAt.blockTimestamp) {\n // we're at the left boundary\n return (beforeOrAt.tickCumulative, beforeOrAt.secondsPerLiquidityCumulativeX128);\n } else if (target == atOrAfter.blockTimestamp) {\n // we're at the right boundary\n return (atOrAfter.tickCumulative, atOrAfter.secondsPerLiquidityCumulativeX128);\n } else {\n // we're in the middle\n uint32 observationTimeDelta = atOrAfter.blockTimestamp - beforeOrAt.blockTimestamp;\n uint32 targetDelta = target - beforeOrAt.blockTimestamp;\n return (\n beforeOrAt.tickCumulative +\n ((atOrAfter.tickCumulative - beforeOrAt.tickCumulative) / observationTimeDelta) *\n targetDelta,\n beforeOrAt.secondsPerLiquidityCumulativeX128 +\n uint160(\n (uint256(\n atOrAfter.secondsPerLiquidityCumulativeX128 - beforeOrAt.secondsPerLiquidityCumulativeX128\n ) * targetDelta) / observationTimeDelta\n )\n );\n }\n }\n\n /// @notice Returns the accumulator values as of each time seconds ago from the given time in the array of `secondsAgos`\n /// @dev Reverts if `secondsAgos` > oldest observation\n /// @param self The stored oracle array\n /// @param time The current block.timestamp\n /// @param secondsAgos Each amount of time to look back, in seconds, at which point to return an observation\n /// @param tick The current tick\n /// @param index The index of the observation that was most recently written to the observations array\n /// @param liquidity The current in-range pool liquidity\n /// @param cardinality The number of populated elements in the oracle array\n /// @return tickCumulatives The tick * time elapsed since the pool was first initialized, as of each `secondsAgo`\n /// @return secondsPerLiquidityCumulativeX128s The cumulative seconds / max(1, liquidity) since the pool was first initialized, as of each `secondsAgo`\n function observe(\n Observation[65535] storage self,\n uint32 time,\n uint32[] memory secondsAgos,\n int24 tick,\n uint16 index,\n uint128 liquidity,\n uint16 cardinality\n ) internal view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) {\n require(cardinality > 0, 'I');\n\n tickCumulatives = new int56[](secondsAgos.length);\n secondsPerLiquidityCumulativeX128s = new uint160[](secondsAgos.length);\n for (uint256 i = 0; i < secondsAgos.length; i++) {\n (tickCumulatives[i], secondsPerLiquidityCumulativeX128s[i]) = observeSingle(\n self,\n time,\n secondsAgos[i],\n tick,\n index,\n liquidity,\n cardinality\n );\n }\n }\n}\n", "sourcePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/Oracle.sol", "ast": { "absolutePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/Oracle.sol", "exportedSymbols": { "Oracle": [ 4907 ] }, "id": 4908, "license": "BUSL-1.1", "nodeType": "SourceUnit", "nodes": [ { "id": 4174, "literals": [ "solidity", ">=", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "37:24:23" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": { "id": 4175, "nodeType": "StructuredDocumentation", "src": "63:613:23", "text": "@title Oracle\n @notice Provides price and liquidity data useful for a wide variety of system designs\n @dev Instances of stored oracle data, \"observations\", are collected in the oracle array\n Every pool is initialized with an oracle array length of 1. Anyone can pay the SSTOREs to increase the\n maximum length of the oracle array. New slots will be added when the array is fully populated.\n Observations are overwritten when the full length of the oracle array is populated.\n The most recent observation is available, independent of the length of the oracle array, by passing 0 to observe()" }, "fullyImplemented": true, "id": 4907, "linearizedBaseContracts": [ 4907 ], "name": "Oracle", "nodeType": "ContractDefinition", "nodes": [ { "canonicalName": "Oracle.Observation", "id": 4184, "members": [ { "constant": false, "id": 4177, "mutability": "mutable", "name": "blockTimestamp", "nodeType": "VariableDeclaration", "scope": 4184, "src": "776:21:23", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "typeName": { "id": 4176, "name": "uint32", "nodeType": "ElementaryTypeName", "src": "776:6:23", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "visibility": "internal" }, { "constant": false, "id": 4179, "mutability": "mutable", "name": "tickCumulative", "nodeType": "VariableDeclaration", "scope": 4184, "src": "902:20:23", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int56", "typeString": "int56" }, "typeName": { "id": 4178, "name": "int56", "nodeType": "ElementaryTypeName", "src": "902:5:23", "typeDescriptions": { "typeIdentifier": "t_int56", "typeString": "int56" } }, "visibility": "internal" }, { "constant": false, "id": 4181, "mutability": "mutable", "name": "secondsPerLiquidityCumulativeX128", "nodeType": "VariableDeclaration", "scope": 4184, "src": "1048:41:23", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" }, "typeName": { "id": 4180, "name": "uint160", "nodeType": "ElementaryTypeName", "src": "1048:7:23", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" } }, "visibility": "internal" }, { "constant": false, "id": 4183, "mutability": "mutable", "name": "initialized", "nodeType": "VariableDeclaration", "scope": 4184, "src": "1156:16:23", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 4182, "name": "bool", "nodeType": "ElementaryTypeName", "src": "1156:4:23", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "visibility": "internal" } ], "name": "Observation", "nodeType": "StructDefinition", "scope": 4907, "src": "697:482:23", "visibility": "public" }, { "body": { "id": 4238, "nodeType": "Block", "src": "1982:455:23", "statements": [ { "assignments": [ 4199 ], "declarations": [ { "constant": false, "id": 4199, "mutability": "mutable", "name": "delta", "nodeType": "VariableDeclaration", "scope": 4238, "src": "1992:12:23", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "typeName": { "id": 4198, "name": "uint32", "nodeType": "ElementaryTypeName", "src": "1992:6:23", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "visibility": "internal" } ], "id": 4204, "initialValue": { "commonType": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "id": 4203, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 4200, "name": "blockTimestamp", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4189, "src": "2007:14:23", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "nodeType": "BinaryOperation", "operator": "-", "rightExpression": { "expression": { "id": 4201, "name": "last", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4187, "src": "2024:4:23", "typeDescriptions": { "typeIdentifier": "t_struct$_Observation_$4184_memory_ptr", "typeString": "struct Oracle.Observation memory" } }, "id": 4202, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "blockTimestamp", "nodeType": "MemberAccess", "referencedDeclaration": 4177, "src": "2024:19:23", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "src": "2007:36:23", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "nodeType": "VariableDeclarationStatement", "src": "1992:51:23" }, { "expression": { "arguments": [ { "id": 4206, "name": "blockTimestamp", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4189, "src": "2118:14:23", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, { "commonType": { "typeIdentifier": "t_int56", "typeString": "int56" }, "id": 4215, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "expression": { "id": 4207, "name": "last", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4187, "src": "2166:4:23", "typeDescriptions": { "typeIdentifier": "t_struct$_Observation_$4184_memory_ptr", "typeString": "struct Oracle.Observation memory" } }, "id": 4208, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "tickCumulative", "nodeType": "MemberAccess", "referencedDeclaration": 4179, "src": "2166:19:23", "typeDescriptions": { "typeIdentifier": "t_int56", "typeString": "int56" } }, "nodeType": "BinaryOperation", "operator": "+", "rightExpression": { "commonType": { "typeIdentifier": "t_int56", "typeString": "int56" }, "id": 4214, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "arguments": [ { "id": 4211, "name": "tick", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4191, "src": "2194:4:23", "typeDescriptions": { "typeIdentifier": "t_int24", "typeString": "int24" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int24", "typeString": "int24" } ], "id": 4210, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "2188:5:23", "typeDescriptions": { "typeIdentifier": "t_type$_t_int56_$", "typeString": "type(int56)" }, "typeName": { "id": 4209, "name": "int56", "nodeType": "ElementaryTypeName", "src": "2188:5:23", "typeDescriptions": {} } }, "id": 4212, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "2188:11:23", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_int56", "typeString": "int56" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "id": 4213, "name": "delta", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4199, "src": "2202:5:23", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "src": "2188:19:23", "typeDescriptions": { "typeIdentifier": "t_int56", "typeString": "int56" } }, "src": "2166:41:23", "typeDescriptions": { "typeIdentifier": "t_int56", "typeString": "int56" } }, { "commonType": { "typeIdentifier": "t_uint160", "typeString": "uint160" }, "id": 4234, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "expression": { "id": 4216, "name": "last", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4187, "src": "2260:4:23", "typeDescriptions": { "typeIdentifier": "t_struct$_Observation_$4184_memory_ptr", "typeString": "struct Oracle.Observation memory" } }, "id": 4217, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "secondsPerLiquidityCumulativeX128", "nodeType": "MemberAccess", "referencedDeclaration": 4181, "src": "2260:38:23", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" } }, "nodeType": "BinaryOperation", "operator": "+", "rightExpression": { "components": [ { "commonType": { "typeIdentifier": "t_uint160", "typeString": "uint160" }, "id": 4232, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "components": [ { "commonType": { "typeIdentifier": "t_uint160", "typeString": "uint160" }, "id": 4223, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "arguments": [ { "id": 4220, "name": "delta", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4199, "src": "2331:5:23", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint32", "typeString": "uint32" } ], "id": 4219, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "2323:7:23", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint160_$", "typeString": "type(uint160)" }, "typeName": { "id": 4218, "name": "uint160", "nodeType": "ElementaryTypeName", "src": "2323:7:23", "typeDescriptions": {} } }, "id": 4221, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "2323:14:23", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" } }, "nodeType": "BinaryOperation", "operator": "<<", "rightExpression": { "hexValue": "313238", "id": 4222, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "2341:3:23", "typeDescriptions": { "typeIdentifier": "t_rational_128_by_1", "typeString": "int_const 128" }, "value": "128" }, "src": "2323:21:23", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" } } ], "id": 4224, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "TupleExpression", "src": "2322:23:23", "typeDescriptions": { "typeIdentifier": "t_uint160", "typeString": "uint160" } }, "nodeType": "BinaryOperation", "operator": "/", "rightExpression": { "components": [ { "condition": { "commonType": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "id": 4227, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 4225, "name": "liquidity", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4193, "src": "2349:9:23", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "nodeType": "BinaryOperation", "operator": ">", "rightExpression": { "hexValue": "30", "id": 4226, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "2361:1:23", "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "2349:13:23", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseExpression": { "hexValue": "31", "id": 4229, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "2377:1:23", "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "1" }, "id": 4230, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "Conditional", "src": "2349:29:23", "trueExpression": { "id": 4228, "name": "liquidity", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4193, "src": "2365:9:23", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } } ], "id": 4231, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "TupleExpression", "src": "2348:31:23", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "src": "2322:57:23", "typeDescriptions": { "typeIdentifier": "t_uint160",