UNPKG

@windfallswap/periphery

Version:

🎚 Peripheral smart contracts for interacting with Windfall Swap

1,078 lines • 830 kB
{ "contractName": "FixedPoint", "abi": [ { "inputs": [], "name": "Q112", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "RESOLUTION", "outputs": [ { "internalType": "uint8", "name": "", "type": "uint8" } ], "stateMutability": "view", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"Q112\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RESOLUTION\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"@windfallswap/lib/contracts/libraries/FixedPoint.sol\":\"FixedPoint\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"@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": "0x60c4610025600b82828239805160001a60731461001857fe5b30600052607381538281f3fe7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80633bf7a83e146042578063552f888a14605a575b600080fd5b60486076565b60408051918252519081900360200190f35b60606089565b6040805160ff9092168252519081900360200190f35b6e01000000000000000000000000000081565b60708156fea26469706673582212209e36c2815ba812ee2837c8b7a0d41c50cc7e8dc9cf8f546eb02de42d5f8e55c764736f6c63430006060033", "deployedBytecode": "0x7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80633bf7a83e146042578063552f888a14605a575b600080fd5b60486076565b60408051918252519081900360200190f35b60606089565b6040805160ff9092168252519081900360200190f35b6e01000000000000000000000000000081565b60708156fea26469706673582212209e36c2815ba812ee2837c8b7a0d41c50cc7e8dc9cf8f546eb02de42d5f8e55c764736f6c63430006060033", "immutableReferences": {}, "sourceMap": "259:6021: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": "259:6021:17:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;9;2:12;562:62:17;;;:::i;:::-;;;;;;;;;;;;;;;;517:38;;;:::i;:::-;;;;;;;;;;;;;;;;;;;562:62;593:31;562:62;:::o;517:38::-;552:3;517:38;:::o", "source": "// SPDX-License-Identifier: GPL-3.0-or-later\r\npragma solidity >=0.4.0;\r\n\r\nimport './FullMath.sol';\r\nimport './Babylonian.sol';\r\nimport './BitMath.sol';\r\n\r\n// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))\r\nlibrary FixedPoint {\r\n // range: [0, 2**112 - 1]\r\n // resolution: 1 / 2**112\r\n struct uq112x112 {\r\n uint224 _x;\r\n }\r\n\r\n // range: [0, 2**144 - 1]\r\n // resolution: 1 / 2**112\r\n struct uq144x112 {\r\n uint256 _x;\r\n }\r\n\r\n uint8 public constant RESOLUTION = 112;\r\n uint256 public constant Q112 = 0x10000000000000000000000000000; // 2**112\r\n uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; // 2**224\r\n uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits)\r\n\r\n // encode a uint112 as a UQ112x112\r\n function encode(uint112 x) internal pure returns (uq112x112 memory) {\r\n return uq112x112(uint224(x) << RESOLUTION);\r\n }\r\n\r\n // encodes a uint144 as a UQ144x112\r\n function encode144(uint144 x) internal pure returns (uq144x112 memory) {\r\n return uq144x112(uint256(x) << RESOLUTION);\r\n }\r\n\r\n // decode a UQ112x112 into a uint112 by truncating after the radix point\r\n function decode(uq112x112 memory self) internal pure returns (uint112) {\r\n return uint112(self._x >> RESOLUTION);\r\n }\r\n\r\n // decode a UQ144x112 into a uint144 by truncating after the radix point\r\n function decode144(uq144x112 memory self) internal pure returns (uint144) {\r\n return uint144(self._x >> RESOLUTION);\r\n }\r\n\r\n // multiply a UQ112x112 by a uint, returning a UQ144x112\r\n // reverts on overflow\r\n function mul(uq112x112 memory self, uint256 y) internal pure returns (uq144x112 memory) {\r\n uint256 z = 0;\r\n require(y == 0 || (z = self._x * y) / y == self._x, 'FixedPoint::mul: overflow');\r\n return uq144x112(z);\r\n }\r\n\r\n // multiply a UQ112x112 by an int and decode, returning an int\r\n // reverts on overflow\r\n function muli(uq112x112 memory self, int256 y) internal pure returns (int256) {\r\n uint256 z = FullMath.mulDiv(self._x, uint256(y < 0 ? -y : y), Q112);\r\n require(z < 2**255, 'FixedPoint::muli: overflow');\r\n return y < 0 ? -int256(z) : int256(z);\r\n }\r\n\r\n // multiply a UQ112x112 by a UQ112x112, returning a UQ112x112\r\n // lossy\r\n function muluq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) {\r\n if (self._x == 0 || other._x == 0) {\r\n return uq112x112(0);\r\n }\r\n uint112 upper_self = uint112(self._x >> RESOLUTION); // * 2^0\r\n uint112 lower_self = uint112(self._x & LOWER_MASK); // * 2^-112\r\n uint112 upper_other = uint112(other._x >> RESOLUTION); // * 2^0\r\n uint112 lower_other = uint112(other._x & LOWER_MASK); // * 2^-112\r\n\r\n // partial products\r\n uint224 upper = uint224(upper_self) * upper_other; // * 2^0\r\n uint224 lower = uint224(lower_self) * lower_other; // * 2^-224\r\n uint224 uppers_lowero = uint224(upper_self) * lower_other; // * 2^-112\r\n uint224 uppero_lowers = uint224(upper_other) * lower_self; // * 2^-112\r\n\r\n // so the bit shift does not overflow\r\n require(upper <= uint112(-1), 'FixedPoint::muluq: upper overflow');\r\n\r\n // this cannot exceed 256 bits, all values are 224 bits\r\n uint256 sum = uint256(upper << RESOLUTION) + uppers_lowero + uppero_lowers + (lower >> RESOLUTION);\r\n\r\n // so the cast does not overflow\r\n require(sum <= uint224(-1), 'FixedPoint::muluq: sum overflow');\r\n\r\n return uq112x112(uint224(sum));\r\n }\r\n\r\n // divide a UQ112x112 by a UQ112x112, returning a UQ112x112\r\n function divuq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) {\r\n require(other._x > 0, 'FixedPoint::divuq: division by zero');\r\n if (self._x == other._x) {\r\n return uq112x112(uint224(Q112));\r\n }\r\n if (self._x <= uint144(-1)) {\r\n uint256 value = (uint256(self._x) << RESOLUTION) / other._x;\r\n require(value <= uint224(-1), 'FixedPoint::divuq: overflow');\r\n return uq112x112(uint224(value));\r\n }\r\n\r\n uint256 result = FullMath.mulDiv(Q112, self._x, other._x);\r\n require(result <= uint224(-1), 'FixedPoint::divuq: overflow');\r\n return uq112x112(uint224(result));\r\n }\r\n\r\n // returns a UQ112x112 which represents the ratio of the numerator to the denominator\r\n // can be lossy\r\n function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) {\r\n require(denominator > 0, 'FixedPoint::fraction: division by zero');\r\n if (numerator == 0) return FixedPoint.uq112x112(0);\r\n\r\n if (numerator <= uint144(-1)) {\r\n uint256 result = (numerator << RESOLUTION) / denominator;\r\n require(result <= uint224(-1), 'FixedPoint::fraction: overflow');\r\n return uq112x112(uint224(result));\r\n } else {\r\n uint256 result = FullMath.mulDiv(numerator, Q112, denominator);\r\n require(result <= uint224(-1), 'FixedPoint::fraction: overflow');\r\n return uq112x112(uint224(result));\r\n }\r\n }\r\n\r\n // take the reciprocal of a UQ112x112\r\n // reverts on overflow\r\n // lossy\r\n function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {\r\n require(self._x != 0, 'FixedPoint::reciprocal: reciprocal of zero');\r\n require(self._x != 1, 'FixedPoint::reciprocal: overflow');\r\n return uq112x112(uint224(Q224 / self._x));\r\n }\r\n\r\n // square root of a UQ112x112\r\n // lossy between 0/1 and 40 bits\r\n function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {\r\n if (self._x <= uint144(-1)) {\r\n return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112)));\r\n }\r\n\r\n uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x);\r\n safeShiftBits -= safeShiftBits % 2;\r\n return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2)));\r\n }\r\n}\r\n", "sourcePath": "@windfallswap/lib/contracts/libraries/FixedPoint.sol", "ast": { "absolutePath": "@windfallswap/lib/contracts/libraries/FixedPoint.sol", "exportedSymbols": { "FixedPoint": [ 6262 ] }, "id": 6263, "nodeType": "SourceUnit", "nodes": [ { "id": 5635, "literals": [ "solidity", ">=", "0.4", ".0" ], "nodeType": "PragmaDirective", "src": "46:24:17" }, { "absolutePath": "@windfallswap/lib/contracts/libraries/FullMath.sol", "file": "./FullMath.sol", "id": 5636, "nodeType": "ImportDirective", "scope": 6263, "sourceUnit": 6484, "src": "74:24:17", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@windfallswap/lib/contracts/libraries/Babylonian.sol", "file": "./Babylonian.sol", "id": 5637, "nodeType": "ImportDirective", "scope": 6263, "sourceUnit": 5356, "src": "100:26:17", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@windfallswap/lib/contracts/libraries/BitMath.sol", "file": "./BitMath.sol", "id": 5638, "nodeType": "ImportDirective", "scope": 6263, "sourceUnit": 5634, "src": "128:23:17", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 6262, "linearizedBaseContracts": [ 6262 ], "name": "FixedPoint", "nodeType": "ContractDefinition", "nodes": [ { "canonicalName": "FixedPoint.uq112x112", "id": 5641, "members": [ { "constant": false, "id": 5640, "mutability": "mutable", "name": "_x", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5641, "src": "375:10:17", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "typeName": { "id": 5639, "name": "uint224", "nodeType": "ElementaryTypeName", "src": "375:7:17", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "value": null, "visibility": "internal" } ], "name": "uq112x112", "nodeType": "StructDefinition", "scope": 6262, "src": "347:46:17", "visibility": "public" }, { "canonicalName": "FixedPoint.uq144x112", "id": 5644, "members": [ { "constant": false, "id": 5643, "mutability": "mutable", "name": "_x", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5644, "src": "491:10:17", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5642, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "491:7:17", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "name": "uq144x112", "nodeType": "StructDefinition", "scope": 6262, "src": "463:46:17", "visibility": "public" }, { "constant": true, "functionSelector": "552f888a", "id": 5647, "mutability": "constant", "name": "RESOLUTION", "nodeType": "VariableDeclaration", "overrides": null, "scope": 6262, "src": "517:38:17", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "typeName": { "id": 5645, "name": "uint8", "nodeType": "ElementaryTypeName", "src": "517:5:17", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "value": { "argumentTypes": null, "hexValue": "313132", "id": 5646, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "552:3:17", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_112_by_1", "typeString": "int_const 112" }, "value": "112" }, "visibility": "public" }, { "constant": true, "functionSelector": "3bf7a83e", "id": 5650, "mutability": "constant", "name": "Q112", "nodeType": "VariableDeclaration", "overrides": null, "scope": 6262, "src": "562:62:17", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5648, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "562:7:17", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "30783130303030303030303030303030303030303030303030303030303030", "id": 5649, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "593:31:17", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_5192296858534827628530496329220096_by_1", "typeString": "int_const 5192...(26 digits omitted)...0096" }, "value": "0x10000000000000000000000000000" }, "visibility": "public" }, { "constant": true, "id": 5653, "mutability": "constant", "name": "Q224", "nodeType": "VariableDeclaration", "overrides": null, "scope": 6262, "src": "641:91:17", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5651, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "641:7:17", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "3078313030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030", "id": 5652, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "673:59:17", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_26959946667150639794667015087019630673637144422540572481103610249216_by_1", "typeString": "int_const 2695...(60 digits omitted)...9216" }, "value": "0x100000000000000000000000000000000000000000000000000000000" }, "visibility": "private" }, { "constant": true, "id": 5656, "mutability": "constant", "name": "LOWER_MASK", "nodeType": "VariableDeclaration", "overrides": null, "scope": 6262, "src": "749:68:17", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5654, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "749:7:17", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "307866666666666666666666666666666666666666666666666666666666", "id": 5655, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "787:30:17", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_5192296858534827628530496329220095_by_1", "typeString": "int_const 5192...(26 digits omitted)...0095" }, "value": "0xffffffffffffffffffffffffffff" }, "visibility": "private" }, { "body": { "id": 5672, "nodeType": "Block", "src": "973:61:17", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "id": 5669, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 5666, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5658, "src": "1009:1:17", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint112", "typeString": "uint112" } ], "id": 5665, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1001:7:17", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint224_$", "typeString": "type(uint224)" }, "typeName": { "id": 5664, "name": "uint224", "nodeType": "ElementaryTypeName", "src": "1001:7:17", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 5667, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1001:10:17", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "nodeType": "BinaryOperation", "operator": "<<", "rightExpression": { "argumentTypes": null, "id": 5668, "name": "RESOLUTION", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5647, "src": "1015:10:17", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "src": "1001:24:17", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint224", "typeString": "uint224" } ], "id": 5663, "name": "uq112x112", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5641, "src": "991:9:17", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_uq112x112_$5641_storage_ptr_$", "typeString": "type(struct FixedPoint.uq112x112 storage pointer)" } }, "id": 5670, "isConstant": false, "isLValue": false, "isPure": false, "kind": "structConstructorCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "991:35:17", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$5641_memory_ptr", "typeString": "struct FixedPoint.uq112x112 memory" } }, "functionReturnParameters": 5662, "id": 5671, "nodeType": "Return", "src": "984:42:17" } ] }, "documentation": null, "id": 5673, "implemented": true, "kind": "function", "modifiers": [], "name": "encode", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 5659, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5658, "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5673, "src": "921:9:17", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" }, "typeName": { "id": 5657, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "921:7:17", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "value": null, "visibility": "internal" } ], "src": "920:11:17" }, "returnParameters": { "id": 5662, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5661, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5673, "src": "955:16:17", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$5641_memory_ptr", "typeString": "struct FixedPoint.uq112x112" }, "typeName": { "contractScope": null, "id": 5660, "name": "uq112x112", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5641, "src": "955:9:17", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$5641_storage_ptr", "typeString": "struct FixedPoint.uq112x112" } }, "value": null, "visibility": "internal" } ], "src": "954:18:17" }, "scope": 6262, "src": "905:129:17", "stateMutability": "pure", "virtual": false, "visibility": "internal" }, { "body": { "id": 5689, "nodeType": "Block", "src": "1154:61:17", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 5686, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 5683, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5675, "src": "1190:1:17", "typeDescriptions": { "typeIdentifier": "t_uint144", "typeString": "uint144" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint144", "typeString": "uint144" } ], "id": 5682, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1182:7:17", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint256_$", "typeString": "type(uint256)" }, "typeName": { "id": 5681, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1182:7:17", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 5684, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1182:10:17", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<<", "rightExpression": { "argumentTypes": null, "id": 5685, "name": "RESOLUTION", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5647, "src": "1196:10:17", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "src": "1182:24:17", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 5680, "name": "uq144x112", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5644, "src": "1172:9:17", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_uq144x112_$5644_storage_ptr_$", "typeString": "type(struct FixedPoint.uq144x112 storage pointer)" } }, "id": 5687, "isConstant": false, "isLValue": false, "isPure": false, "kind": "structConstructorCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1172:35:17", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_struct$_uq144x112_$5644_memory_ptr", "typeString": "struct FixedPoint.uq144x112 memory" } }, "functionReturnParameters": 5679, "id": 5688, "nodeType": "Return", "src": "1165:42:17" } ] }, "documentation": null, "id": 5690, "implemented": true, "kind": "function", "modifiers": [], "name": "encode144", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 5676, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5675, "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5690, "src": "1102:9:17", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint144", "typeString": "uint144" }, "typeName": { "id": 5674, "name": "uint144", "nodeType": "ElementaryTypeName", "src": "1102:7:17", "typeDescriptions": { "typeIdentifier": "t_uint144", "typeString": "uint144" } }, "value": null, "visibility": "internal" } ], "src": "1101:11:17" }, "returnParameters": { "id": 5679, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5678, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5690, "src": "1136:16:17", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_uq144x112_$5644_memory_ptr", "typeString": "struct FixedPoint.uq144x112" }, "typeName": { "contractScope": null, "id": 5677, "name": "uq144x112", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5644, "src": "1136:9:17", "typeDescriptions": { "typeIdentifier": "t_struct$_uq144x112_$5644_storage_ptr", "typeString": "struct FixedPoint.uq144x112" } }, "value": null, "visibility": "internal" } ], "src": "1135:18:17" }, "scope": 6262, "src": "1083:132:17", "stateMutability": "pure", "virtual": false, "visibility": "internal" }, { "body": { "id": 5705, "nodeType": "Block", "src": "1372:56:17", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "id": 5702, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 5699, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5692, "src": "1398:4:17", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$5641_memory_ptr", "typeString": "struct FixedPoint.uq112x112 memory" } }, "id": 5700, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "_x", "nodeType": "MemberAccess", "referencedDeclaration": 5640, "src": "1398:7:17", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "nodeType": "BinaryOperation", "operator": ">>", "rightExpression": { "argumentTypes": null, "id": 5701, "name": "RESOLUTION", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5647, "src": "1409:10:17", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "src": "1398:21:17", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint224", "typeString": "uint224" } ], "id": 5698, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1390:7:17", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint112_$", "typeString": "type(uint112)" }, "typeName": { "id": 5697, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "1390:7:17", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 5703, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1390:30:17", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "functionReturnParameters": 5696, "id": 5704, "nodeType": "Return", "src": "1383:37:17" } ] }, "documentation": null, "id": 5706, "implemented": true, "kind": "function", "modifiers": [], "name": "decode", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 5693, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5692, "mutability": "mutable", "name": "self", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5706, "src": "1317:21:17", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$5641_memory_ptr", "typeString": "struct FixedPoint.uq112x112" }, "typeName": { "contractScope": null, "id": 5691, "name": "uq112x112", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5641, "src": "1317:9:17", "typeDescriptions": { "typeIdentifier": "t_struct$_uq112x112_$5641_storage_ptr", "typeString": "struct FixedPoint.uq112x112" } }, "value": null, "visibility": "internal" } ], "src": "1316:23:17" }, "returnParameters": { "id": 5696, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5695, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5706, "src": "1363:7:17", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" }, "typeName": { "id": 5694, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "1363:7:17", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "value": null, "visibility": "internal" } ], "src": "1362:9:17" }, "scope": 6262, "src": "1301:127:17", "stateMutability": "pure", "virtual": false, "visibility": "internal" }, { "body": { "id": 5721, "nodeType": "Block", "src": "1588:56:17", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 5718, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 5715, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5708, "src": "1614:4:17", "typeDescriptions": { "typeIdentifier": "t_struct$_uq144x112_$5644_memory_ptr", "typeString": "struct FixedPoint.uq144x112 memory" } }, "id": 5716, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "_x", "nodeType": "MemberAccess",