UNPKG

hardlydifficult-eth

Version:

A collection of reusable contracts and Javascript helpers for Ethereum.

1,112 lines (1,111 loc) 763 kB
{ "contractName": "FixedPoint", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.6.10+commit.00c0fcaf\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"@uniswap/lib/contracts/libraries/FixedPoint.sol\":\"FixedPoint\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":2000000},\"remappings\":[]},\"sources\":{\"@uniswap/lib/contracts/libraries/Babylonian.sol\":{\"keccak256\":\"0x2799682d733a6ef3aae1dce7dbe2cff5513f0244e4abd07338fe7a45c8fd9733\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://332968199300fe6025b9ad8f3d69f252ec2a3a092fa42a0ef7f2d1397f59a7e5\",\"dweb:/ipfs/Qme4wBzDwfHr7zHk8WrCwCpozpt4KHuDQSxfJTDoHL8Pdi\"]},\"@uniswap/lib/contracts/libraries/BitMath.sol\":{\"keccak256\":\"0x0ef2d7cd41b3f1818fa41019b38948489238efccebe428d4b04919174378abf5\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://696ac37d8731506cbac9b428afb7bdfa35a490df139022be2b04ab3815113cf4\",\"dweb:/ipfs/QmUQ5ty49YATw4Gf5PrtFkxNErcnwhNUpRF3WFaVJxATf9\"]},\"@uniswap/lib/contracts/libraries/FixedPoint.sol\":{\"keccak256\":\"0x0e8d7f2bfad7505f9d029ea060eab9747363d50bf01f2d954bf719da6fac342f\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://35dd605e2fd59d2606529ab1575cd937082018cd041cfbb843b68e97e440b9b0\",\"dweb:/ipfs/QmUHbzyCdzwUSCUPVFFm9N6oKXiisVdscX8H73nwNXmmpV\"]},\"@uniswap/lib/contracts/libraries/FullMath.sol\":{\"keccak256\":\"0xf3dd7fc13a7eee86c17cdfe13b03a7f24ebaf09588550b64b581ae7b2bd59273\",\"license\":\"CC-BY-4.0\",\"urls\":[\"bzz-raw://492ced3afa929c790c9b1314b86454a977528e8f3d408a55b1275a396154d097\",\"dweb:/ipfs/QmbX2YAgtoM13Z2MRnV5WnUpzmw3fMxmhzCnsKKxQUjGJJ\"]}},\"version\":1}", "bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209a10e10cd2552f461b45a2d94fc7c624abd86af191070d1a5c4c2d9534c4619864736f6c634300060a0033", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209a10e10cd2552f461b45a2d94fc7c624abd86af191070d1a5c4c2d9534c4619864736f6c634300060a0033", "immutableReferences": {}, "sourceMap": "251:5329:4:-:0;;;;;;;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "251:5329:4:-:0;;;;;;;;", "source": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.4.0;\n\nimport './FullMath.sol';\nimport './Babylonian.sol';\nimport './BitMath.sol';\n\n// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))\nlibrary FixedPoint {\n // range: [0, 2**112 - 1]\n // resolution: 1 / 2**112\n struct uq112x112 {\n uint224 _x;\n }\n\n // range: [0, 2**144 - 1]\n // resolution: 1 / 2**112\n struct uq144x112 {\n uint256 _x;\n }\n\n uint8 private constant RESOLUTION = 112;\n uint256 private constant Q112 = 0x10000000000000000000000000000;\n uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000;\n uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits)\n\n // encode a uint112 as a UQ112x112\n function encode(uint112 x) internal pure returns (uq112x112 memory) {\n return uq112x112(uint224(x) << RESOLUTION);\n }\n\n // encodes a uint144 as a UQ144x112\n function encode144(uint144 x) internal pure returns (uq144x112 memory) {\n return uq144x112(uint256(x) << RESOLUTION);\n }\n\n // decode a UQ112x112 into a uint112 by truncating after the radix point\n function decode(uq112x112 memory self) internal pure returns (uint112) {\n return uint112(self._x >> RESOLUTION);\n }\n\n // decode a UQ144x112 into a uint144 by truncating after the radix point\n function decode144(uq144x112 memory self) internal pure returns (uint144) {\n return uint144(self._x >> RESOLUTION);\n }\n\n // multiply a UQ112x112 by a uint, returning a UQ144x112\n // reverts on overflow\n function mul(uq112x112 memory self, uint256 y) internal pure returns (uq144x112 memory) {\n uint256 z = 0;\n require(y == 0 || (z = self._x * y) / y == self._x, 'FixedPoint: MUL_OVERFLOW');\n return uq144x112(z);\n }\n\n // multiply a UQ112x112 by an int and decode, returning an int\n // reverts on overflow\n function muli(uq112x112 memory self, int256 y) internal pure returns (int256) {\n uint256 z = FullMath.mulDiv(self._x, uint256(y < 0 ? -y : y), Q112);\n require(z < 2**255, 'FixedPoint: MULI_OVERFLOW');\n return y < 0 ? -int256(z) : int256(z);\n }\n\n // multiply a UQ112x112 by a UQ112x112, returning a UQ112x112\n // lossy\n function muluq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) {\n if (self._x == 0 || other._x == 0) {\n return uq112x112(0);\n }\n uint112 upper_self = uint112(self._x >> RESOLUTION); // * 2^0\n uint112 lower_self = uint112(self._x & LOWER_MASK); // * 2^-112\n uint112 upper_other = uint112(other._x >> RESOLUTION); // * 2^0\n uint112 lower_other = uint112(other._x & LOWER_MASK); // * 2^-112\n\n // partial products\n uint224 upper = uint224(upper_self) * upper_other; // * 2^0\n uint224 lower = uint224(lower_self) * lower_other; // * 2^-224\n uint224 uppers_lowero = uint224(upper_self) * lower_other; // * 2^-112\n uint224 uppero_lowers = uint224(upper_other) * lower_self; // * 2^-112\n\n // so the bit shift does not overflow\n require(upper <= uint112(-1), 'FixedPoint: MULUQ_OVERFLOW_UPPER');\n\n // this cannot exceed 256 bits, all values are 224 bits\n uint256 sum = uint256(upper << RESOLUTION) + uppers_lowero + uppero_lowers + (lower >> RESOLUTION);\n\n // so the cast does not overflow\n require(sum <= uint224(-1), 'FixedPoint: MULUQ_OVERFLOW_SUM');\n\n return uq112x112(uint224(sum));\n }\n\n // divide a UQ112x112 by a UQ112x112, returning a UQ112x112\n function divuq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) {\n require(other._x > 0, 'FixedPoint: DIV_BY_ZERO_DIVUQ');\n if (self._x == other._x) {\n return uq112x112(uint224(Q112));\n }\n if (self._x <= uint144(-1)) {\n uint256 value = (uint256(self._x) << RESOLUTION) / other._x;\n require(value <= uint224(-1), 'FixedPoint: DIVUQ_OVERFLOW');\n return uq112x112(uint224(value));\n }\n\n uint256 result = FullMath.mulDiv(Q112, self._x, other._x);\n require(result <= uint224(-1), 'FixedPoint: DIVUQ_OVERFLOW');\n return uq112x112(uint224(result));\n }\n\n // returns a UQ112x112 which represents the ratio of the numerator to the denominator\n // lossy\n function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {\n require(denominator > 0, 'FixedPoint: DIV_BY_ZERO_FRACTION');\n return uq112x112((uint224(numerator) << RESOLUTION) / denominator);\n }\n\n // take the reciprocal of a UQ112x112\n // reverts on overflow\n // lossy\n function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {\n require(self._x > 1, 'FixedPoint: DIV_BY_ZERO_RECIPROCAL_OR_OVERFLOW');\n return uq112x112(uint224(Q224 / self._x));\n }\n\n // square root of a UQ112x112\n // lossy between 0/1 and 40 bits\n function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {\n if (self._x <= uint144(-1)) {\n return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112)));\n }\n\n uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x);\n safeShiftBits -= safeShiftBits % 2;\n return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2)));\n }\n}\n", "sourcePath": "@uniswap/lib/contracts/libraries/FixedPoint.sol", "ast": { "absolutePath": "@uniswap/lib/contracts/libraries/FixedPoint.sol", "exportedSymbols": { "FixedPoint": [ 1166 ] }, "id": 1167, "license": "GPL-3.0-or-later", "nodeType": "SourceUnit", "nodes": [ { "id": 608, "literals": [ "solidity", ">=", "0.4", ".0" ], "nodeType": "PragmaDirective", "src": "45:24:4" }, { "absolutePath": "@uniswap/lib/contracts/libraries/FullMath.sol", "file": "./FullMath.sol", "id": 609, "nodeType": "ImportDirective", "scope": 1167, "sourceUnit": 1380, "src": "71:24:4", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@uniswap/lib/contracts/libraries/Babylonian.sol", "file": "./Babylonian.sol", "id": 610, "nodeType": "ImportDirective", "scope": 1167, "sourceUnit": 490, "src": "96:26:4", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@uniswap/lib/contracts/libraries/BitMath.sol", "file": "./BitMath.sol", "id": 611, "nodeType": "ImportDirective", "scope": 1167, "sourceUnit": 607, "src": "123:23:4", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 1166, "linearizedBaseContracts": [ 1166 ], "name": "FixedPoint", "nodeType": "ContractDefinition", "nodes": [ { "canonicalName": "FixedPoint.uq112x112", "id": 614, "members": [ { "constant": false, "id": 613, "mutability": "mutable", "name": "_x", "nodeType": "VariableDeclaration", "overrides": null, "scope": 614, "src": "363:10:4", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "typeName": { "id": 612, "name": "uint224", "nodeType": "ElementaryTypeName", "src": "363:7:4", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "value": null, "visibility": "internal" } ], "name": "uq112x112", "nodeType": "StructDefinition", "scope": 1166, "src": "336:44:4", "visibility": "public" }, { "canonicalName": "FixedPoint.uq144x112", "id": 617, "members": [ { "constant": false, "id": 616, "mutability": "mutable", "name": "_x", "nodeType": "VariableDeclaration", "overrides": null, "scope": 617, "src": "473:10:4", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 615, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "473:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "name": "uq144x112", "nodeType": "StructDefinition", "scope": 1166, "src": "446:44:4", "visibility": "public" }, { "constant": true, "id": 620, "mutability": "constant", "name": "RESOLUTION", "nodeType": "VariableDeclaration", "overrides": null, "scope": 1166, "src": "496:39:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "typeName": { "id": 618, "name": "uint8", "nodeType": "ElementaryTypeName", "src": "496:5:4", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "value": { "argumentTypes": null, "hexValue": "313132", "id": 619, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "532:3:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_112_by_1", "typeString": "int_const 112" }, "value": "112" }, "visibility": "private" }, { "constant": true, "id": 623, "mutability": "constant", "name": "Q112", "nodeType": "VariableDeclaration", "overrides": null, "scope": 1166, "src": "541:63:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 621, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "541:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "30783130303030303030303030303030303030303030303030303030303030", "id": 622, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "573:31:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_5192296858534827628530496329220096_by_1", "typeString": "int_const 5192...(26 digits omitted)...0096" }, "value": "0x10000000000000000000000000000" }, "visibility": "private" }, { "constant": true, "id": 626, "mutability": "constant", "name": "Q224", "nodeType": "VariableDeclaration", "overrides": null, "scope": 1166, "src": "610:91:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 624, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "610:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "3078313030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030", "id": 625, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "642:59:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_26959946667150639794667015087019630673637144422540572481103610249216_by_1", "typeString": "int_const 2695...(60 digits omitted)...9216" }, "value": "0x100000000000000000000000000000000000000000000000000000000" }, "visibility": "private" }, { "constant": true, "id": 629, "mutability": "constant", "name": "LOWER_MASK", "nodeType": "VariableDeclaration", "overrides": null, "scope": 1166, "src": "707:68:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 627, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "707:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "307866666666666666666666666666666666666666666666666666666666", "id": 628, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "745:30:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_5192296858534827628530496329220095_by_1", "typeString": "int_const 5192...(26 digits omitted)...0095" }, "value": "0xffffffffffffffffffffffffffff" }, "visibility": "private" }, { "body": { "id": 645, "nodeType": "Block", "src": "928:59:4", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "id": 642, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 639, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 631, "src": "963:1:4", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint112", "typeString": "uint112" } ], "id": 638, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "955:7:4", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint224_$", "typeString": "type(uint224)" }, "typeName": { "id": 637, "name": "uint224", "nodeType": "ElementaryTypeName", "src": "955:7:4", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 640, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "955:10:4", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "nodeType": "BinaryOperation", "operator": "<<", "rightExpression": { "argumentTypes": null, "id": 641, "name": "RESOLUTION", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 620, "src": "969:10:4", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "src": "955:24:4", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint224", "typeString": "uint224" } ], "id": 636, "name": "uq112x112", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 614, "src": "945:9:4", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_uq112x112_$614_storage_ptr_$", "typeString": "type(struct FixedPoint.uq112x112 storage pointer)" } }, "id": 643, "isConstant": false, "isLValue": false, "isPure": false, "kind": "structConstructorCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "945:35:4", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$614_memory_ptr", "typeString": "struct FixedPoint.uq112x112 memory" } }, "functionReturnParameters": 635, "id": 644, "nodeType": "Return", "src": "938:42:4" } ] }, "documentation": null, "id": 646, "implemented": true, "kind": "function", "modifiers": [], "name": "encode", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 632, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 631, "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", "overrides": null, "scope": 646, "src": "876:9:4", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" }, "typeName": { "id": 630, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "876:7:4", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "value": null, "visibility": "internal" } ], "src": "875:11:4" }, "returnParameters": { "id": 635, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 634, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "overrides": null, "scope": 646, "src": "910:16:4", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$614_memory_ptr", "typeString": "struct FixedPoint.uq112x112" }, "typeName": { "contractScope": null, "id": 633, "name": "uq112x112", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 614, "src": "910:9:4", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$614_storage_ptr", "typeString": "struct FixedPoint.uq112x112" } }, "value": null, "visibility": "internal" } ], "src": "909:18:4" }, "scope": 1166, "src": "860:127:4", "stateMutability": "pure", "virtual": false, "visibility": "internal" }, { "body": { "id": 662, "nodeType": "Block", "src": "1104:59:4", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 659, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 656, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 648, "src": "1139:1:4", "typeDescriptions": { "typeIdentifier": "t_uint144", "typeString": "uint144" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint144", "typeString": "uint144" } ], "id": 655, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1131:7:4", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint256_$", "typeString": "type(uint256)" }, "typeName": { "id": 654, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1131:7:4", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 657, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1131:10:4", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<<", "rightExpression": { "argumentTypes": null, "id": 658, "name": "RESOLUTION", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 620, "src": "1145:10:4", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "src": "1131:24:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 653, "name": "uq144x112", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 617, "src": "1121:9:4", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_uq144x112_$617_storage_ptr_$", "typeString": "type(struct FixedPoint.uq144x112 storage pointer)" } }, "id": 660, "isConstant": false, "isLValue": false, "isPure": false, "kind": "structConstructorCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1121:35:4", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_struct$_uq144x112_$617_memory_ptr", "typeString": "struct FixedPoint.uq144x112 memory" } }, "functionReturnParameters": 652, "id": 661, "nodeType": "Return", "src": "1114:42:4" } ] }, "documentation": null, "id": 663, "implemented": true, "kind": "function", "modifiers": [], "name": "encode144", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 649, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 648, "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", "overrides": null, "scope": 663, "src": "1052:9:4", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint144", "typeString": "uint144" }, "typeName": { "id": 647, "name": "uint144", "nodeType": "ElementaryTypeName", "src": "1052:7:4", "typeDescriptions": { "typeIdentifier": "t_uint144", "typeString": "uint144" } }, "value": null, "visibility": "internal" } ], "src": "1051:11:4" }, "returnParameters": { "id": 652, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 651, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "overrides": null, "scope": 663, "src": "1086:16:4", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_uq144x112_$617_memory_ptr", "typeString": "struct FixedPoint.uq144x112" }, "typeName": { "contractScope": null, "id": 650, "name": "uq144x112", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 617, "src": "1086:9:4", "typeDescriptions": { "typeIdentifier": "t_struct$_uq144x112_$617_storage_ptr", "typeString": "struct FixedPoint.uq144x112" } }, "value": null, "visibility": "internal" } ], "src": "1085:18:4" }, "scope": 1166, "src": "1033:130:4", "stateMutability": "pure", "virtual": false, "visibility": "internal" }, { "body": { "id": 678, "nodeType": "Block", "src": "1317:54:4", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "id": 675, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 672, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 665, "src": "1342:4:4", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$614_memory_ptr", "typeString": "struct FixedPoint.uq112x112 memory" } }, "id": 673, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "_x", "nodeType": "MemberAccess", "referencedDeclaration": 613, "src": "1342:7:4", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "nodeType": "BinaryOperation", "operator": ">>", "rightExpression": { "argumentTypes": null, "id": 674, "name": "RESOLUTION", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 620, "src": "1353:10:4", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "src": "1342:21:4", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint224", "typeString": "uint224" } ], "id": 671, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1334:7:4", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint112_$", "typeString": "type(uint112)" }, "typeName": { "id": 670, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "1334:7:4", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 676, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1334:30:4", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "functionReturnParameters": 669, "id": 677, "nodeType": "Return", "src": "1327:37:4" } ] }, "documentation": null, "id": 679, "implemented": true, "kind": "function", "modifiers": [], "name": "decode", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 666, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 665, "mutability": "mutable", "name": "self", "nodeType": "VariableDeclaration", "overrides": null, "scope": 679, "src": "1262:21:4", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$614_memory_ptr", "typeString": "struct FixedPoint.uq112x112" }, "typeName": { "contractScope": null, "id": 664, "name": "uq112x112", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 614, "src": "1262:9:4", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$614_storage_ptr", "typeString": "struct FixedPoint.uq112x112" } }, "value": null, "visibility": "internal" } ], "src": "1261:23:4" }, "returnParameters": { "id": 669, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 668, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "overrides": null, "scope": 679, "src": "1308:7:4", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" }, "typeName": { "id": 667, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "1308:7:4", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "value": null, "visibility": "internal" } ], "src": "1307:9:4" }, "scope": 1166, "src": "1246:125:4", "stateMutability": "pure", "virtual": false, "visibility": "internal" }, { "body": { "id": 694, "nodeType": "Block", "src": "1528:54:4", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 691, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 688, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 681, "src": "1553:4:4", "typeDescriptions": { "typeIdentifier": "t_struct$_uq144x112_$617_memory_ptr", "typeString": "struct FixedPoint.uq144x112 memory" } }, "id": 689, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "_x", "nodeType": "MemberAccess", "referencedDeclaration": 616, "src": "1553:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">>", "rightExpression": { "argumentTypes": null, "id": 690, "name": "RESOLUTION", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 620, "src": "1564:10:4", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "src": "1553:21:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 687, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1545:7:4", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint144_$", "typeString": "type(uint144)" }, "typeName": { "id": 686, "name": "uint144", "nodeType": "ElementaryTypeName", "src": "1545:7:4", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 692, "isConstant": false, "isLValue": false,