@valueswap/v2-periphery
Version:
🎚 Peripheral smart contracts for interacting with Valueswap V2
1,051 lines (1,050 loc) • 148 kB
JSON
{
"contractName": "ValueswapV2OracleLibrary",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2OracleLibrary.sol\":\"ValueswapV2OracleLibrary\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2OracleLibrary.sol\":{\"keccak256\":\"0x3a8a56b8e1d867cecffdb0ff2de6e9a293cc132dd9b2fbd54a8e1cd0eb14cf38\",\"urls\":[\"bzz-raw://892355f90888817408635e26a4c9514f1e18f1a57d7fdd492aef676644bde319\",\"dweb:/ipfs/QmNcMiLuFVHdnEgTSMubByZkzVu8hWjchR9SRKQe7j53TQ\"]},\"@valueswap/lib/contracts/libraries/Babylonian.sol\":{\"keccak256\":\"0xeb1c2a281a00f4660775f75ccfa1e51fbe1d75f86aeb9d0d297151ecdb900177\",\"urls\":[\"bzz-raw://68515f0265381bddfb1d1356ea10ce4e5784276fc09f197fcdcedfa5c75cc069\",\"dweb:/ipfs/QmXWVVPnuJwRUAu3Qpu1s7Fyc5WPQxmZPczVEe5cJ5wVHZ\"]},\"@valueswap/lib/contracts/libraries/BitMath.sol\":{\"keccak256\":\"0x19f84d5268286794b44939ec0d85b3c6f59e133f826cdbd9e40112fc94919bb7\",\"urls\":[\"bzz-raw://d21c67ed58cf667d052e141df2fba76c46c159edcc45eb897c908c20c69d2727\",\"dweb:/ipfs/QmUyKz1992wgR8nYAzBuQzjBAKMxLAN3hTgzpYJxusbmVH\"]},\"@valueswap/lib/contracts/libraries/FixedPoint.sol\":{\"keccak256\":\"0xc3a39b8a11715cea45ad9f67f50e4e4c33778c1124acd59e90daf064c9a93974\",\"urls\":[\"bzz-raw://2c6c3cdcdb30caa5d15477550003b5dbb174cb2c0be3c012af030fce3d043f28\",\"dweb:/ipfs/QmWh3n5g6zq3umJcURnKCFhhif2c8yb6mKczFjfoCNLC3g\"]},\"@valueswap/lib/contracts/libraries/FullMath.sol\":{\"keccak256\":\"0xc4ffcf28169f73fc9fdd1f82345d6d4fcccf3fd5aea83c133437c25e4e0950a9\",\"urls\":[\"bzz-raw://c9257a47501005f0a648bc4801ef4abc33843681aaf03a6d0c43d46b69e37407\",\"dweb:/ipfs/QmciHvDrqhxs5fjsrm9aNq29FZXpunMn17n2wWj83Zsh3B\"]},\"@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol\":{\"keccak256\":\"0x4899f60670cbc336cd8f5fefb631d6ce27ae4226ad4aac5d0963cd23db2fc36a\",\"urls\":[\"bzz-raw://7aa68c3572d1a4713c4af9ba99dd1907a9dc5a104273dab86e1d02797f6b1dd6\",\"dweb:/ipfs/QmXq89Vb6D4XeA2PDqNy13VkNeevTJePCrLF7KUHkver4q\"]}},\"version\":1}",
"bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f5d24d3bbc827c308c4533ee3c1295ba4fc360a66888c546a14fae741af46ba364736f6c63430006060033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f5d24d3bbc827c308c4533ee3c1295ba4fc360a66888c546a14fae741af46ba364736f6c63430006060033",
"immutableReferences": {},
"sourceMap": "250:1452:17:-:0;;132:2:-1;166:7;155:9;146:7;137:37;255:7;249:14;246:1;241:23;235:4;232:33;222:2;;269:9;222:2;293:9;290:1;283:20;323:4;314:7;306:22;347:7;338;331:24",
"deployedSourceMap": "250:1452:17:-:0;;;;;;12:1:-1;9;2:12",
"source": "pragma solidity >=0.5.0;\n\nimport '@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol';\nimport '@valueswap/lib/contracts/libraries/FixedPoint.sol';\n\n// library with helper methods for oracles that are concerned with computing average prices\nlibrary ValueswapV2OracleLibrary {\n using FixedPoint for *;\n\n // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]\n function currentBlockTimestamp() internal view returns (uint32) {\n return uint32(block.timestamp % 2 ** 32);\n }\n\n // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.\n function currentCumulativePrices(\n address pair\n ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) {\n blockTimestamp = currentBlockTimestamp();\n price0Cumulative = IValueswapV2Pair(pair).price0CumulativeLast();\n price1Cumulative = IValueswapV2Pair(pair).price1CumulativeLast();\n\n // if time has elapsed since the last update on the pair, mock the accumulated price values\n (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IValueswapV2Pair(pair).getReserves();\n if (blockTimestampLast != blockTimestamp) {\n // subtraction overflow is desired\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\n // addition overflow is desired\n // counterfactual\n price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;\n // counterfactual\n price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;\n }\n }\n}\n",
"sourcePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2OracleLibrary.sol",
"ast": {
"absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2OracleLibrary.sol",
"exportedSymbols": {
"ValueswapV2OracleLibrary": [
6160
]
},
"id": 6161,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 6055,
"literals": [
"solidity",
">=",
"0.5",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:24:17"
},
{
"absolutePath": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol",
"file": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol",
"id": 6056,
"nodeType": "ImportDirective",
"scope": 6161,
"sourceUnit": 9359,
"src": "26:70:17",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@valueswap/lib/contracts/libraries/FixedPoint.sol",
"file": "@valueswap/lib/contracts/libraries/FixedPoint.sol",
"id": 6057,
"nodeType": "ImportDirective",
"scope": 6161,
"sourceUnit": 8659,
"src": "97:59:17",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": null,
"fullyImplemented": true,
"id": 6160,
"linearizedBaseContracts": [
6160
],
"name": "ValueswapV2OracleLibrary",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 6059,
"libraryName": {
"contractScope": null,
"id": 6058,
"name": "FixedPoint",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8658,
"src": "295:10:17",
"typeDescriptions": {
"typeIdentifier": "t_contract$_FixedPoint_$8658",
"typeString": "library FixedPoint"
}
},
"nodeType": "UsingForDirective",
"src": "289:23:17",
"typeName": null
},
{
"body": {
"id": 6074,
"nodeType": "Block",
"src": "494:57:17",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 6071,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 6066,
"name": "block",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": -4,
"src": "518:5:17",
"typeDescriptions": {
"typeIdentifier": "t_magic_block",
"typeString": "block"
}
},
"id": 6067,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "timestamp",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "518:15:17",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "%",
"rightExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_4294967296_by_1",
"typeString": "int_const 4294967296"
},
"id": 6070,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"hexValue": "32",
"id": 6068,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "536:1:17",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_2_by_1",
"typeString": "int_const 2"
},
"value": "2"
},
"nodeType": "BinaryOperation",
"operator": "**",
"rightExpression": {
"argumentTypes": null,
"hexValue": "3332",
"id": 6069,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "541:2:17",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_32_by_1",
"typeString": "int_const 32"
},
"value": "32"
},
"src": "536:7:17",
"typeDescriptions": {
"typeIdentifier": "t_rational_4294967296_by_1",
"typeString": "int_const 4294967296"
}
},
"src": "518:25:17",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 6065,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "511:6:17",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint32_$",
"typeString": "type(uint32)"
},
"typeName": {
"id": 6064,
"name": "uint32",
"nodeType": "ElementaryTypeName",
"src": "511:6:17",
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
}
}
},
"id": 6072,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "511:33:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"functionReturnParameters": 6063,
"id": 6073,
"nodeType": "Return",
"src": "504:40:17"
}
]
},
"documentation": null,
"id": 6075,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "currentBlockTimestamp",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 6060,
"nodeType": "ParameterList",
"parameters": [],
"src": "460:2:17"
},
"returnParameters": {
"id": 6063,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 6062,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 6075,
"src": "486:6:17",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
},
"typeName": {
"id": 6061,
"name": "uint32",
"nodeType": "ElementaryTypeName",
"src": "486:6:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "485:8:17"
},
"scope": 6160,
"src": "430:121:17",
"stateMutability": "view",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 6158,
"nodeType": "Block",
"src": "807:893:17",
"statements": [
{
"expression": {
"argumentTypes": null,
"id": 6089,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 6086,
"name": "blockTimestamp",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6084,
"src": "817:14:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"id": 6087,
"name": "currentBlockTimestamp",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6075,
"src": "834:21:17",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_view$__$returns$_t_uint32_$",
"typeString": "function () view returns (uint32)"
}
},
"id": 6088,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "834:23:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"src": "817:40:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"id": 6090,
"nodeType": "ExpressionStatement",
"src": "817:40:17"
},
{
"expression": {
"argumentTypes": null,
"id": 6097,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 6091,
"name": "price0Cumulative",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6080,
"src": "867:16:17",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 6093,
"name": "pair",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6077,
"src": "903:4:17",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 6092,
"name": "IValueswapV2Pair",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 9358,
"src": "886:16:17",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_IValueswapV2Pair_$9358_$",
"typeString": "type(contract IValueswapV2Pair)"
}
},
"id": 6094,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "886:22:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_contract$_IValueswapV2Pair_$9358",
"typeString": "contract IValueswapV2Pair"
}
},
"id": 6095,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "price0CumulativeLast",
"nodeType": "MemberAccess",
"referencedDeclaration": 9305,
"src": "886:43:17",
"typeDescriptions": {
"typeIdentifier": "t_function_external_view$__$returns$_t_uint256_$",
"typeString": "function () view external returns (uint256)"
}
},
"id": 6096,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "886:45:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "867:64:17",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 6098,
"nodeType": "ExpressionStatement",
"src": "867:64:17"
},
{
"expression": {
"argumentTypes": null,
"id": 6105,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 6099,
"name": "price1Cumulative",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6082,
"src": "941:16:17",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 6101,
"name": "pair",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6077,
"src": "977:4:17",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 6100,
"name": "IValueswapV2Pair",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 9358,
"src": "960:16:17",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_IValueswapV2Pair_$9358_$",
"typeString": "type(contract IValueswapV2Pair)"
}
},
"id": 6102,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "960:22:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_contract$_IValueswapV2Pair_$9358",
"typeString": "contract IValueswapV2Pair"
}
},
"id": 6103,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "price1CumulativeLast",
"nodeType": "MemberAccess",
"referencedDeclaration": 9310,
"src": "960:43:17",
"typeDescriptions": {
"typeIdentifier": "t_function_external_view$__$returns$_t_uint256_$",
"typeString": "function () view external returns (uint256)"
}
},
"id": 6104,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "960:45:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "941:64:17",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 6106,
"nodeType": "ExpressionStatement",
"src": "941:64:17"
},
{
"assignments": [
6108,
6110,
6112
],
"declarations": [
{
"constant": false,
"id": 6108,
"mutability": "mutable",
"name": "reserve0",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 6158,
"src": "1117:16:17",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 6107,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1117:7:17",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 6110,
"mutability": "mutable",
"name": "reserve1",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 6158,
"src": "1135:16:17",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 6109,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1135:7:17",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 6112,
"mutability": "mutable",
"name": "blockTimestampLast",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 6158,
"src": "1153:25:17",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
},
"typeName": {
"id": 6111,
"name": "uint32",
"nodeType": "ElementaryTypeName",
"src": "1153:6:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 6118,
"initialValue": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 6114,
"name": "pair",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6077,
"src": "1199:4:17",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 6113,
"name": "IValueswapV2Pair",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 9358,
"src": "1182:16:17",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_IValueswapV2Pair_$9358_$",
"typeString": "type(contract IValueswapV2Pair)"
}
},
"id": 6115,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1182:22:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_contract$_IValueswapV2Pair_$9358",
"typeString": "contract IValueswapV2Pair"
}
},
"id": 6116,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "getReserves",
"nodeType": "MemberAccess",
"referencedDeclaration": 9300,
"src": "1182:34:17",
"typeDescriptions": {
"typeIdentifier": "t_function_external_view$__$returns$_t_uint112_$_t_uint112_$_t_uint32_$",
"typeString": "function () view external returns (uint112,uint112,uint32)"
}
},
"id": 6117,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1182:36:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$_t_uint112_$_t_uint112_$_t_uint32_$",
"typeString": "tuple(uint112,uint112,uint32)"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1116:102:17"
},
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
},
"id": 6121,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 6119,
"name": "blockTimestampLast",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6112,
"src": "1232:18:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"nodeType": "BinaryOperation",
"operator": "!=",
"rightExpression": {
"argumentTypes": null,
"id": 6120,
"name": "blockTimestamp",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6084,
"src": "1254:14:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"src": "1232:36:17",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 6157,
"nodeType": "IfStatement",
"src": "1228:466:17",
"trueBody": {
"id": 6156,
"nodeType": "Block",
"src": "1270:424:17",
"statements": [
{
"assignments": [
6123
],
"declarations": [
{
"constant": false,
"id": 6123,
"mutability": "mutable",
"name": "timeElapsed",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 6156,
"src": "1331:18:17",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
},
"typeName": {
"id": 6122,
"name": "uint32",
"nodeType": "ElementaryTypeName",
"src": "1331:6:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 6127,
"initialValue": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
},
"id": 6126,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 6124,
"name": "blockTimestamp",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6084,
"src": "1352:14:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"nodeType": "BinaryOperation",
"operator": "-",
"rightExpression": {
"argumentTypes": null,
"id": 6125,
"name": "blockTimestampLast",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6112,
"src": "1369:18:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"src": "1352:35:17",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1331:56:17"
},
{
"expression": {
"argumentTypes": null,
"id": 6140,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 6128,
"name": "price0Cumulative",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6080,
"src": "1475:16:17",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "+=",
"rightHandSide": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 6139,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 6133,
"name": "reserve1",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6110,
"src": "1520:8:17",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
{
"argumentTypes": null,
"id": 6134,
"name": "reserve0",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 6108,
"src": "1530:8:17",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
{
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
],
"expression": {
"argumentTypes": null,
"id": 6131,
"name": "FixedPoint",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8658,
"src": "1500:10:17",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_FixedPoint_$8658_$",
"typeString": "type(library FixedPoint)"
}
},
"id": 6132,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "fraction",
"nodeType": "MemberAccess",
"referencedDeclaration": 8549,
"src": "1500:19:17",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_struct$_uq112x112_$8037_memory_ptr_$",
"typeString": "function (uint256,uint256) pure returns (struct FixedPoint.uq112x112 memory)"
}
},
"id": 6135,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1500:39:17",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8037_memory_ptr",
"typeString": "struct FixedPoint.uq112x112 memory"
}
},