@sonicswap/periphery
Version:
🎚 Peripheral smart contracts for interacting with the Sonicswap exchanges
1,085 lines (1,084 loc) • 875 kB
JSON
{
"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.12+commit.27d51765\"},\"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\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@sonicswap/lib/contracts/libraries/FixedPoint.sol\":\"FixedPoint\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@sonicswap/lib/contracts/libraries/Babylonian.sol\":{\"keccak256\":\"0xc2389737a1d4954f93ed88099f8833ccc350a62b8b29b61c2a24f237eb4649bc\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://3d95218a6f0c7c5030e1f81aabcfe297449bf8bb92fcac1c4ba9bcfc8d61e62b\",\"dweb:/ipfs/QmXzJQLQfgqCuxL5JGMrKRQf5ziRNvQiQkNK3ZK6Lkn4CR\"]},\"@sonicswap/lib/contracts/libraries/BitMath.sol\":{\"keccak256\":\"0xa4d662f44b982fc9aa6542249aa79b2b07b3e34d5cdaa03720d3d471ac07f5de\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://4d40d6c87edb8699d5c5c80344b642a516e0a071f173d393678fee58bbc5fde5\",\"dweb:/ipfs/QmXfp4W5jAdpcsv8VTP8RWsPcmASEtmzF9Xg9xehKK7Xdm\"]},\"@sonicswap/lib/contracts/libraries/FixedPoint.sol\":{\"keccak256\":\"0xba90ab07a7e7870d349fd22dda12b02b78a2b5c0f797de591115cde1ae3e47b0\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://b91731ebb4825bcd8512fbf9721d602c298a18392919ddf800f3394231090cb4\",\"dweb:/ipfs/QmUNu1dqnNMyjUeD23KheR1ACVvWmP1T6SmH55Q2kS4nwS\"]},\"@sonicswap/lib/contracts/libraries/FullMath.sol\":{\"keccak256\":\"0x074f43cf798f046118ed21bb9859a7fa1074b9581fe315c8702d6d292fdb2784\",\"license\":\"CC-BY-4.0\",\"urls\":[\"bzz-raw://55a5cb6c5ae9ccc1e6870315bfa5f23f4c758db606f6a292fdff2224fcec082e\",\"dweb:/ipfs/QmRZayK4DWdWHaape9XcVj6VobzX7en7Tejk7gbzv7CHTy\"]}},\"version\":1}",
"bytecode": "0x60b9610025600b82828239805160001a60731461001857fe5b30600052607381538281f3fe7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80633bf7a83e146042578063552f888a14605a575b600080fd5b60486076565b60408051918252519081900360200190f35b6060607e565b6040805160ff9092168252519081900360200190f35b600160701b81565b60708156fea264697066735822122074d5aeb077b7312346867bb39bc5870ad722d3789c8bb9a92dd29e96860c69d264736f6c634300060c0033",
"deployedBytecode": "0x7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80633bf7a83e146042578063552f888a14605a575b600080fd5b60486076565b60408051918252519081900360200190f35b6060607e565b6040805160ff9092168252519081900360200190f35b600160701b81565b60708156fea264697066735822122074d5aeb077b7312346867bb39bc5870ad722d3789c8bb9a92dd29e96860c69d264736f6c634300060c0033",
"immutableReferences": {},
"sourceMap": "251:5884:28:-:0;;;;;;;;;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "251:5884:28:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;540:62;;;:::i;:::-;;;;;;;;;;;;;;;;496:38;;;:::i;:::-;;;;;;;;;;;;;;;;;;;540:62;-1:-1:-1;;;540:62:28;:::o;496:38::-;531:3;496:38;:::o",
"source": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity =0.6.12;\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 public constant RESOLUTION = 112;\n uint256 public constant Q112 = 0x10000000000000000000000000000; // 2**112\n uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; // 2**224\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: upper overflow');\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: sum overflow');\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::divuq: division by zero');\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 // can be lossy\n function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) {\n require(denominator > 0, 'FixedPoint::fraction: division by zero');\n if (numerator == 0) return FixedPoint.uq112x112(0);\n\n if (numerator <= uint144(-1)) {\n uint256 result = (numerator << RESOLUTION) / denominator;\n require(result <= uint224(-1), 'FixedPoint::fraction: overflow');\n return uq112x112(uint224(result));\n } else {\n uint256 result = FullMath.mulDiv(numerator, Q112, denominator);\n require(result <= uint224(-1), 'FixedPoint::fraction: overflow');\n return uq112x112(uint224(result));\n }\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 != 0, 'FixedPoint::reciprocal: reciprocal of zero');\n require(self._x != 1, 'FixedPoint::reciprocal: 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": "@sonicswap/lib/contracts/libraries/FixedPoint.sol",
"ast": {
"absolutePath": "@sonicswap/lib/contracts/libraries/FixedPoint.sol",
"exportedSymbols": {
"FixedPoint": [
9463
]
},
"id": 9464,
"license": "GPL-3.0-or-later",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 8836,
"literals": [
"solidity",
"=",
"0.6",
".12"
],
"nodeType": "PragmaDirective",
"src": "45:24:28"
},
{
"absolutePath": "@sonicswap/lib/contracts/libraries/FullMath.sol",
"file": "./FullMath.sol",
"id": 8837,
"nodeType": "ImportDirective",
"scope": 9464,
"sourceUnit": 9685,
"src": "71:24:28",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@sonicswap/lib/contracts/libraries/Babylonian.sol",
"file": "./Babylonian.sol",
"id": 8838,
"nodeType": "ImportDirective",
"scope": 9464,
"sourceUnit": 8557,
"src": "96:26:28",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@sonicswap/lib/contracts/libraries/BitMath.sol",
"file": "./BitMath.sol",
"id": 8839,
"nodeType": "ImportDirective",
"scope": 9464,
"sourceUnit": 8835,
"src": "123:23:28",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": null,
"fullyImplemented": true,
"id": 9463,
"linearizedBaseContracts": [
9463
],
"name": "FixedPoint",
"nodeType": "ContractDefinition",
"nodes": [
{
"canonicalName": "FixedPoint.uq112x112",
"id": 8842,
"members": [
{
"constant": false,
"id": 8841,
"mutability": "mutable",
"name": "_x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8842,
"src": "363:10:28",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"typeName": {
"id": 8840,
"name": "uint224",
"nodeType": "ElementaryTypeName",
"src": "363:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "uq112x112",
"nodeType": "StructDefinition",
"scope": 9463,
"src": "336:44:28",
"visibility": "public"
},
{
"canonicalName": "FixedPoint.uq144x112",
"id": 8845,
"members": [
{
"constant": false,
"id": 8844,
"mutability": "mutable",
"name": "_x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8845,
"src": "473:10:28",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8843,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "473:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "uq144x112",
"nodeType": "StructDefinition",
"scope": 9463,
"src": "446:44:28",
"visibility": "public"
},
{
"constant": true,
"functionSelector": "552f888a",
"id": 8848,
"mutability": "constant",
"name": "RESOLUTION",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 9463,
"src": "496:38:28",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
},
"typeName": {
"id": 8846,
"name": "uint8",
"nodeType": "ElementaryTypeName",
"src": "496:5:28",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"value": {
"argumentTypes": null,
"hexValue": "313132",
"id": 8847,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "531:3:28",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_112_by_1",
"typeString": "int_const 112"
},
"value": "112"
},
"visibility": "public"
},
{
"constant": true,
"functionSelector": "3bf7a83e",
"id": 8851,
"mutability": "constant",
"name": "Q112",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 9463,
"src": "540:62:28",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8849,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "540:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "30783130303030303030303030303030303030303030303030303030303030",
"id": 8850,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "571:31:28",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_5192296858534827628530496329220096_by_1",
"typeString": "int_const 5192...(26 digits omitted)...0096"
},
"value": "0x10000000000000000000000000000"
},
"visibility": "public"
},
{
"constant": true,
"id": 8854,
"mutability": "constant",
"name": "Q224",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 9463,
"src": "618:91:28",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8852,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "618:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "3078313030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030",
"id": 8853,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "650:59:28",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_26959946667150639794667015087019630673637144422540572481103610249216_by_1",
"typeString": "int_const 2695...(60 digits omitted)...9216"
},
"value": "0x100000000000000000000000000000000000000000000000000000000"
},
"visibility": "private"
},
{
"constant": true,
"id": 8857,
"mutability": "constant",
"name": "LOWER_MASK",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 9463,
"src": "725:68:28",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8855,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "725:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "307866666666666666666666666666666666666666666666666666666666",
"id": 8856,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "763:30:28",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_5192296858534827628530496329220095_by_1",
"typeString": "int_const 5192...(26 digits omitted)...0095"
},
"value": "0xffffffffffffffffffffffffffff"
},
"visibility": "private"
},
{
"body": {
"id": 8873,
"nodeType": "Block",
"src": "946:59:28",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"id": 8870,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 8867,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8859,
"src": "981:1:28",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
],
"id": 8866,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "973:7:28",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint224_$",
"typeString": "type(uint224)"
},
"typeName": {
"id": 8865,
"name": "uint224",
"nodeType": "ElementaryTypeName",
"src": "973:7:28",
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
}
}
},
"id": 8868,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "973:10:28",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"id": 8869,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8848,
"src": "987:10:28",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "973:24:28",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
],
"id": 8864,
"name": "uq112x112",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8842,
"src": "963:9:28",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_uq112x112_$8842_storage_ptr_$",
"typeString": "type(struct FixedPoint.uq112x112 storage pointer)"
}
},
"id": 8871,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "963:35:28",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8842_memory_ptr",
"typeString": "struct FixedPoint.uq112x112 memory"
}
},
"functionReturnParameters": 8863,
"id": 8872,
"nodeType": "Return",
"src": "956:42:28"
}
]
},
"documentation": null,
"id": 8874,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "encode",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 8860,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8859,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8874,
"src": "894:9:28",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 8858,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "894:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "893:11:28"
},
"returnParameters": {
"id": 8863,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8862,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8874,
"src": "928:16:28",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8842_memory_ptr",
"typeString": "struct FixedPoint.uq112x112"
},
"typeName": {
"contractScope": null,
"id": 8861,
"name": "uq112x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8842,
"src": "928:9:28",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8842_storage_ptr",
"typeString": "struct FixedPoint.uq112x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "927:18:28"
},
"scope": 9463,
"src": "878:127:28",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 8890,
"nodeType": "Block",
"src": "1122:59:28",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 8887,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 8884,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8876,
"src": "1157:1:28",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
],
"id": 8883,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1149:7:28",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": {
"id": 8882,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1149:7:28",
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
}
}
},
"id": 8885,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1149:10:28",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"id": 8886,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8848,
"src": "1163:10:28",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "1149:24:28",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 8881,
"name": "uq144x112",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8845,
"src": "1139:9:28",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_uq144x112_$8845_storage_ptr_$",
"typeString": "type(struct FixedPoint.uq144x112 storage pointer)"
}
},
"id": 8888,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1139:35:28",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$8845_memory_ptr",
"typeString": "struct FixedPoint.uq144x112 memory"
}
},
"functionReturnParameters": 8880,
"id": 8889,
"nodeType": "Return",
"src": "1132:42:28"
}
]
},
"documentation": null,
"id": 8891,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "encode144",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 8877,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8876,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8891,
"src": "1070:9:28",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
},
"typeName": {
"id": 8875,
"name": "uint144",
"nodeType": "ElementaryTypeName",
"src": "1070:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1069:11:28"
},
"returnParameters": {
"id": 8880,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8879,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8891,
"src": "1104:16:28",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$8845_memory_ptr",
"typeString": "struct FixedPoint.uq144x112"
},
"typeName": {
"contractScope": null,
"id": 8878,
"name": "uq144x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8845,
"src": "1104:9:28",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$8845_storage_ptr",
"typeString": "struct FixedPoint.uq144x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1103:18:28"
},
"scope": 9463,
"src": "1051:130:28",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 8906,
"nodeType": "Block",
"src": "1335:54:28",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"id": 8903,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 8900,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8893,
"src": "1360:4:28",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8842_memory_ptr",
"typeString": "struct FixedPoint.uq112x112 memory"
}
},
"id": 8901,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "_x",
"nodeType": "MemberAccess",
"referencedDeclaration": 8841,
"src": "1360:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"nodeType": "BinaryOperation",
"operator": ">>",
"rightExpression": {
"argumentTypes": null,
"id": 8902,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8848,
"src": "1371:10:28",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "1360:21:28",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
],
"id": 8899,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1352:7:28",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint112_$",
"typeString": "type(uint112)"
},
"typeName": {
"id": 8898,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1352:7:28",
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
}
}
},
"id": 8904,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1352:30:28",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"functionReturnParameters": 8897,
"id": 8905,
"nodeType": "Return",
"src": "1345:37:28"
}
]
},
"documentation": null,
"id": 8907,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "decode",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 8894,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8893,
"mutability": "mutable",
"name": "self",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8907,
"src": "1280:21:28",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8842_memory_ptr",
"typeString": "struct FixedPoint.uq112x112"
},
"typeName": {
"contractScope": null,
"id": 8892,
"name": "uq112x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8842,
"src": "1280:9:28",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8842_storage_ptr",
"typeString": "struct FixedPoint.uq112x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1279:23:28"
},
"returnParameters": {
"id": 8897,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8896,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8907,
"src": "1326:7:28",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 8895,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1326:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1325:9:28"
},
"scope": 9463,
"src": "1264:125:28",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 8922,
"nodeType": "Block",
"src": "1546:54:28",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 8919,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 8916,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8909,
"src": "1571:4:28",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$8845_memory_ptr",
"typeString": "struct FixedPoint.uq144x112 memory"
}
},
"id": 8917,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "_x",
"nodeType": "MemberAccess",
"referencedDeclaration": 8844,
"src": "1571:7:28",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"