UNPKG

@windfallswap/periphery

Version:

🎚 Peripheral smart contracts for interacting with Windfall Swap

1,053 lines (1,052 loc) • 137 kB
{ "contractName": "WindfallOracleLibrary", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/D/defi/windfall/windfallswap-periphery/contracts/libraries/WindfallOracleLibrary.sol\":\"WindfallOracleLibrary\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"/D/defi/windfall/windfallswap-periphery/contracts/libraries/WindfallOracleLibrary.sol\":{\"keccak256\":\"0xf5c3b7f50bcb47a79494f9f9f6c41fea9d90031a634416a134004cf277140034\",\"urls\":[\"bzz-raw://c51c4bd8938ad3da82bc749321ac0b9cd2d89055f99fd6a039baa1af49678d40\",\"dweb:/ipfs/QmPjRmm49QuwM1E857N1Q6S2UkFs6iCH6GW63smna6Bgxv\"]},\"@windfallswap/core/contracts/interfaces/IWindfallPair.sol\":{\"keccak256\":\"0x5ad5b5543c1f18cb9ad8d30196a8b77e5d0a1dff66a8c34b604d8f9a677b4304\",\"urls\":[\"bzz-raw://42362060f9a3b3c9c5d704093722d2511df7ff6db91c987a906f82c0e424843a\",\"dweb:/ipfs/QmWh7ZGPVmgHanrt3o3xe6UTraPJ3hZ3vuYXHvBKwXL5Z5\"]},\"@windfallswap/lib/contracts/libraries/Babylonian.sol\":{\"keccak256\":\"0x81eb4c5866c15c48b9b75d004f82dcda6c9d7342fb5cf136c27e8761601c35cb\",\"urls\":[\"bzz-raw://eedefbef0159af045769189dc9bfa2f01dea7fe7767943f409dc5cff05de4619\",\"dweb:/ipfs/QmUEaa5Cu9vpUxZMdFmwpLgby95Xo76v1BjFFxMhFwbEqP\"]},\"@windfallswap/lib/contracts/libraries/BitMath.sol\":{\"keccak256\":\"0x5610a7da9b61b3d8426eef6191e59557535570dbbc814cee70ae200972d47654\",\"urls\":[\"bzz-raw://c4cf4baaf6ce8f3e49c3738b56c1ad18651debacef9683eb1a5a0ab3895b0cfd\",\"dweb:/ipfs/QmQn8izKRZZTg8e4sjzWuj5rqZfmiQFS5PRhfDeJiUJdeX\"]},\"@windfallswap/lib/contracts/libraries/FixedPoint.sol\":{\"keccak256\":\"0xd2b3565c194a169490f329888c3d2ff8540016b96e4af98c8312e0c5c4f67b29\",\"urls\":[\"bzz-raw://cd2b37c11ead13c9cb260e2d457887ddaafce961c74cbd0fdc68a2c5a7cae1be\",\"dweb:/ipfs/QmWCnVeVpfvbCarjU3QdNpFMJRrZ7xXcZnG6Fi2sfWvbtb\"]},\"@windfallswap/lib/contracts/libraries/FullMath.sol\":{\"keccak256\":\"0x551088475af882db32a532bbf16c82859ce727bfa6b390b7ca1ba2ee1d913284\",\"urls\":[\"bzz-raw://b2967b56e05e57d367680628e244725d6d5271cb1fd3355308a6eba5ccfa01ae\",\"dweb:/ipfs/QmZZpc7PQ2wynS1XW2sStFpWWRwyLb8XHMvWx3SKmdmuvq\"]}},\"version\":1}", "bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122014bf229ebab71327a1608bdeafad73d35b1756e14be83213a1d6bda55ccfbdcd64736f6c63430006060033", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122014bf229ebab71327a1608bdeafad73d35b1756e14be83213a1d6bda55ccfbdcd64736f6c63430006060033", "immutableReferences": {}, "sourceMap": "256:1468:8:-: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": "256:1468:8:-:0;;;;;;12:1:-1;9;2:12", "source": "pragma solidity >=0.5.0;\r\n\r\nimport '@windfallswap/core/contracts/interfaces/IWindfallPair.sol';\r\nimport '@windfallswap/lib/contracts/libraries/FixedPoint.sol';\r\n\r\n// library with helper methods for oracles that are concerned with computing average prices\r\nlibrary WindfallOracleLibrary {\r\n using FixedPoint for *;\r\n\r\n // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]\r\n function currentBlockTimestamp() internal view returns (uint32) {\r\n return uint32(block.timestamp % 2 ** 32);\r\n }\r\n\r\n // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.\r\n function currentCumulativePrices(\r\n address pair\r\n ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) {\r\n blockTimestamp = currentBlockTimestamp();\r\n price0Cumulative = IWindfallPair(pair).price0CumulativeLast();\r\n price1Cumulative = IWindfallPair(pair).price1CumulativeLast();\r\n\r\n // if time has elapsed since the last update on the pair, mock the accumulated price values\r\n (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IWindfallPair(pair).getReserves();\r\n if (blockTimestampLast != blockTimestamp) {\r\n // subtraction overflow is desired\r\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\r\n // addition overflow is desired\r\n // counterfactual\r\n price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;\r\n // counterfactual\r\n price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;\r\n }\r\n }\r\n}\r\n", "sourcePath": "D:/defi/windfall/windfallswap-periphery/contracts/libraries/WindfallOracleLibrary.sol", "ast": { "absolutePath": "/D/defi/windfall/windfallswap-periphery/contracts/libraries/WindfallOracleLibrary.sol", "exportedSymbols": { "WindfallOracleLibrary": [ 3466 ] }, "id": 3467, "nodeType": "SourceUnit", "nodes": [ { "id": 3361, "literals": [ "solidity", ">=", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:24:8" }, { "absolutePath": "@windfallswap/core/contracts/interfaces/IWindfallPair.sol", "file": "@windfallswap/core/contracts/interfaces/IWindfallPair.sol", "id": 3362, "nodeType": "ImportDirective", "scope": 3467, "sourceUnit": 5153, "src": "28:67:8", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@windfallswap/lib/contracts/libraries/FixedPoint.sol", "file": "@windfallswap/lib/contracts/libraries/FixedPoint.sol", "id": 3363, "nodeType": "ImportDirective", "scope": 3467, "sourceUnit": 6263, "src": "97:62:8", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 3466, "linearizedBaseContracts": [ 3466 ], "name": "WindfallOracleLibrary", "nodeType": "ContractDefinition", "nodes": [ { "id": 3365, "libraryName": { "contractScope": null, "id": 3364, "name": "FixedPoint", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 6262, "src": "299:10:8", "typeDescriptions": { "typeIdentifier": "t_contract$_FixedPoint_$6262", "typeString": "library FixedPoint" } }, "nodeType": "UsingForDirective", "src": "293:23:8", "typeName": null }, { "body": { "id": 3380, "nodeType": "Block", "src": "501:59:8", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 3377, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 3372, "name": "block", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -4, "src": "526:5:8", "typeDescriptions": { "typeIdentifier": "t_magic_block", "typeString": "block" } }, "id": 3373, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "timestamp", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "526:15:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "%", "rightExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_4294967296_by_1", "typeString": "int_const 4294967296" }, "id": 3376, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "hexValue": "32", "id": 3374, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "544:1:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, "value": "2" }, "nodeType": "BinaryOperation", "operator": "**", "rightExpression": { "argumentTypes": null, "hexValue": "3332", "id": 3375, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "549:2:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_32_by_1", "typeString": "int_const 32" }, "value": "32" }, "src": "544:7:8", "typeDescriptions": { "typeIdentifier": "t_rational_4294967296_by_1", "typeString": "int_const 4294967296" } }, "src": "526:25:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 3371, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "519:6:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint32_$", "typeString": "type(uint32)" }, "typeName": { "id": 3370, "name": "uint32", "nodeType": "ElementaryTypeName", "src": "519:6:8", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 3378, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "519:33:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "functionReturnParameters": 3369, "id": 3379, "nodeType": "Return", "src": "512:40:8" } ] }, "documentation": null, "id": 3381, "implemented": true, "kind": "function", "modifiers": [], "name": "currentBlockTimestamp", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 3366, "nodeType": "ParameterList", "parameters": [], "src": "467:2:8" }, "returnParameters": { "id": 3369, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 3368, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "overrides": null, "scope": 3381, "src": "493:6:8", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "typeName": { "id": 3367, "name": "uint32", "nodeType": "ElementaryTypeName", "src": "493:6:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "value": null, "visibility": "internal" } ], "src": "492:8:8" }, "scope": 3466, "src": "437:123:8", "stateMutability": "view", "virtual": false, "visibility": "internal" }, { "body": { "id": 3464, "nodeType": "Block", "src": "821:900:8", "statements": [ { "expression": { "argumentTypes": null, "id": 3395, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 3392, "name": "blockTimestamp", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3390, "src": "832:14:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [], "expression": { "argumentTypes": [], "id": 3393, "name": "currentBlockTimestamp", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3381, "src": "849:21:8", "typeDescriptions": { "typeIdentifier": "t_function_internal_view$__$returns$_t_uint32_$", "typeString": "function () view returns (uint32)" } }, "id": 3394, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "849:23:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "src": "832:40:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "id": 3396, "nodeType": "ExpressionStatement", "src": "832:40:8" }, { "expression": { "argumentTypes": null, "id": 3403, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 3397, "name": "price0Cumulative", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3386, "src": "883:16:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [], "expression": { "argumentTypes": [], "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 3399, "name": "pair", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3383, "src": "916:4:8", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 3398, "name": "IWindfallPair", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5152, "src": "902:13:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IWindfallPair_$5152_$", "typeString": "type(contract IWindfallPair)" } }, "id": 3400, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "902:19:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IWindfallPair_$5152", "typeString": "contract IWindfallPair" } }, "id": 3401, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "price0CumulativeLast", "nodeType": "MemberAccess", "referencedDeclaration": 5099, "src": "902:40:8", "typeDescriptions": { "typeIdentifier": "t_function_external_view$__$returns$_t_uint256_$", "typeString": "function () view external returns (uint256)" } }, "id": 3402, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "902:42:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "883:61:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 3404, "nodeType": "ExpressionStatement", "src": "883:61:8" }, { "expression": { "argumentTypes": null, "id": 3411, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 3405, "name": "price1Cumulative", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3388, "src": "955:16:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [], "expression": { "argumentTypes": [], "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 3407, "name": "pair", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3383, "src": "988:4:8", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 3406, "name": "IWindfallPair", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5152, "src": "974:13:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IWindfallPair_$5152_$", "typeString": "type(contract IWindfallPair)" } }, "id": 3408, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "974:19:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IWindfallPair_$5152", "typeString": "contract IWindfallPair" } }, "id": 3409, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "price1CumulativeLast", "nodeType": "MemberAccess", "referencedDeclaration": 5104, "src": "974:40:8", "typeDescriptions": { "typeIdentifier": "t_function_external_view$__$returns$_t_uint256_$", "typeString": "function () view external returns (uint256)" } }, "id": 3410, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "974:42:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "955:61:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 3412, "nodeType": "ExpressionStatement", "src": "955:61:8" }, { "assignments": [ 3414, 3416, 3418 ], "declarations": [ { "constant": false, "id": 3414, "mutability": "mutable", "name": "reserve0", "nodeType": "VariableDeclaration", "overrides": null, "scope": 3464, "src": "1131:16:8", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" }, "typeName": { "id": 3413, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "1131:7:8", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 3416, "mutability": "mutable", "name": "reserve1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 3464, "src": "1149:16:8", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" }, "typeName": { "id": 3415, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "1149:7:8", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 3418, "mutability": "mutable", "name": "blockTimestampLast", "nodeType": "VariableDeclaration", "overrides": null, "scope": 3464, "src": "1167:25:8", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "typeName": { "id": 3417, "name": "uint32", "nodeType": "ElementaryTypeName", "src": "1167:6:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "value": null, "visibility": "internal" } ], "id": 3424, "initialValue": { "argumentTypes": null, "arguments": [], "expression": { "argumentTypes": [], "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 3420, "name": "pair", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3383, "src": "1210:4:8", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 3419, "name": "IWindfallPair", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5152, "src": "1196:13:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IWindfallPair_$5152_$", "typeString": "type(contract IWindfallPair)" } }, "id": 3421, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1196:19:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IWindfallPair_$5152", "typeString": "contract IWindfallPair" } }, "id": 3422, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "getReserves", "nodeType": "MemberAccess", "referencedDeclaration": 5094, "src": "1196:31:8", "typeDescriptions": { "typeIdentifier": "t_function_external_view$__$returns$_t_uint112_$_t_uint112_$_t_uint32_$", "typeString": "function () view external returns (uint112,uint112,uint32)" } }, "id": 3423, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1196:33:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$_t_uint112_$_t_uint112_$_t_uint32_$", "typeString": "tuple(uint112,uint112,uint32)" } }, "nodeType": "VariableDeclarationStatement", "src": "1130:99:8" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "id": 3427, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 3425, "name": "blockTimestampLast", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3418, "src": "1244:18:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "id": 3426, "name": "blockTimestamp", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3390, "src": "1266:14:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "src": "1244:36:8", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 3463, "nodeType": "IfStatement", "src": "1240:474:8", "trueBody": { "id": 3462, "nodeType": "Block", "src": "1282:432:8", "statements": [ { "assignments": [ 3429 ], "declarations": [ { "constant": false, "id": 3429, "mutability": "mutable", "name": "timeElapsed", "nodeType": "VariableDeclaration", "overrides": null, "scope": 3462, "src": "1345:18:8", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "typeName": { "id": 3428, "name": "uint32", "nodeType": "ElementaryTypeName", "src": "1345:6:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "value": null, "visibility": "internal" } ], "id": 3433, "initialValue": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "id": 3432, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 3430, "name": "blockTimestamp", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3390, "src": "1366:14:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "nodeType": "BinaryOperation", "operator": "-", "rightExpression": { "argumentTypes": null, "id": 3431, "name": "blockTimestampLast", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3418, "src": "1383:18:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "src": "1366:35:8", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "nodeType": "VariableDeclarationStatement", "src": "1345:56:8" }, { "expression": { "argumentTypes": null, "id": 3446, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 3434, "name": "price0Cumulative", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3386, "src": "1492:16:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "+=", "rightHandSide": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 3445, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 3439, "name": "reserve1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3416, "src": "1537:8:8", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, { "argumentTypes": null, "id": 3440, "name": "reserve0", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3414, "src": "1547:8:8", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint112", "typeString": "uint112" }, { "typeIdentifier": "t_uint112", "typeString": "uint112" } ], "expression": { "argumentTypes": null, "id": 3437, "name": "FixedPoint", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6262, "src": "1517:10:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_FixedPoint_$6262_$", "typeString": "type(library FixedPoint)" } }, "id": 3438, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "fraction", "nodeType": "MemberAccess", "referencedDeclaration": 6153, "src": "1517:19:8", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_struct$_uq112x112_$5641_memory_ptr_$", "typeString": "function (uint256,uint256) pure returns (struct FixedPoint.uq112x112 memory)" } }, "id": 3441, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1517:39:8", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$5641_memory_ptr", "typeString": "struct FixedPoint.uq112x112 memory" } }, "id": 3442, "isConstant": false,