@valueswap/v2-periphery
Version:
🎚 Peripheral smart contracts for interacting with Valueswap V2
1,086 lines (1,085 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.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\":{\"@valueswap/lib/contracts/libraries/FixedPoint.sol\":\"FixedPoint\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"@valueswap/lib/contracts/libraries/Babylonian.sol\":{\"keccak256\":\"0xeb1c2a281a00f4660775f75ccfa1e51fbe1d75f86aeb9d0d297151ecdb900177\",\"urls\":[\"bzz-raw://68515f0265381bddfb1d1356ea10ce4e5784276fc09f197fcdcedfa5c75cc069\",\"dweb:/ipfs/QmXWVVPnuJwRUAu3Qpu1s7Fyc5WPQxmZPczVEe5cJ5wVHZ\"]},\"@valueswap/lib/contracts/libraries/BitMath.sol\":{\"keccak256\":\"0x19f84d5268286794b44939ec0d85b3c6f59e133f826cdbd9e40112fc94919bb7\",\"urls\":[\"bzz-raw://d21c67ed58cf667d052e141df2fba76c46c159edcc45eb897c908c20c69d2727\",\"dweb:/ipfs/QmUyKz1992wgR8nYAzBuQzjBAKMxLAN3hTgzpYJxusbmVH\"]},\"@valueswap/lib/contracts/libraries/FixedPoint.sol\":{\"keccak256\":\"0xc3a39b8a11715cea45ad9f67f50e4e4c33778c1124acd59e90daf064c9a93974\",\"urls\":[\"bzz-raw://2c6c3cdcdb30caa5d15477550003b5dbb174cb2c0be3c012af030fce3d043f28\",\"dweb:/ipfs/QmWh3n5g6zq3umJcURnKCFhhif2c8yb6mKczFjfoCNLC3g\"]},\"@valueswap/lib/contracts/libraries/FullMath.sol\":{\"keccak256\":\"0xc4ffcf28169f73fc9fdd1f82345d6d4fcccf3fd5aea83c133437c25e4e0950a9\",\"urls\":[\"bzz-raw://c9257a47501005f0a648bc4801ef4abc33843681aaf03a6d0c43d46b69e37407\",\"dweb:/ipfs/QmciHvDrqhxs5fjsrm9aNq29FZXpunMn17n2wWj83Zsh3B\"]}},\"version\":1}",
"bytecode": "0x60c4610025600b82828239805160001a60731461001857fe5b30600052607381538281f3fe7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80633bf7a83e146042578063552f888a14605a575b600080fd5b60486076565b60408051918252519081900360200190f35b60606089565b6040805160ff9092168252519081900360200190f35b6e01000000000000000000000000000081565b60708156fea26469706673582212200c6db1052238fc66091ec59be40b124488f47a9723268c6f2c07e95ecb6a2dec64736f6c63430006060033",
"deployedBytecode": "0x7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80633bf7a83e146042578063552f888a14605a575b600080fd5b60486076565b60408051918252519081900360200190f35b60606089565b6040805160ff9092168252519081900360200190f35b6e01000000000000000000000000000081565b60708156fea26469706673582212200c6db1052238fc66091ec59be40b124488f47a9723268c6f2c07e95ecb6a2dec64736f6c63430006060033",
"immutableReferences": {},
"sourceMap": "251:5884:24:-: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": "251:5884:24:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;9;2:12;540:62:24;;;:::i;:::-;;;;;;;;;;;;;;;;496:38;;;:::i;:::-;;;;;;;;;;;;;;;;;;;540:62;571:31;540:62;:::o;496:38::-;531:3;496:38;:::o",
"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 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": "@valueswap/lib/contracts/libraries/FixedPoint.sol",
"ast": {
"absolutePath": "@valueswap/lib/contracts/libraries/FixedPoint.sol",
"exportedSymbols": {
"FixedPoint": [
8658
]
},
"id": 8659,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 8031,
"literals": [
"solidity",
">=",
"0.4",
".0"
],
"nodeType": "PragmaDirective",
"src": "45:24:24"
},
{
"absolutePath": "@valueswap/lib/contracts/libraries/FullMath.sol",
"file": "./FullMath.sol",
"id": 8032,
"nodeType": "ImportDirective",
"scope": 8659,
"sourceUnit": 8880,
"src": "71:24:24",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@valueswap/lib/contracts/libraries/Babylonian.sol",
"file": "./Babylonian.sol",
"id": 8033,
"nodeType": "ImportDirective",
"scope": 8659,
"sourceUnit": 7752,
"src": "96:26:24",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@valueswap/lib/contracts/libraries/BitMath.sol",
"file": "./BitMath.sol",
"id": 8034,
"nodeType": "ImportDirective",
"scope": 8659,
"sourceUnit": 8030,
"src": "123:23:24",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": null,
"fullyImplemented": true,
"id": 8658,
"linearizedBaseContracts": [
8658
],
"name": "FixedPoint",
"nodeType": "ContractDefinition",
"nodes": [
{
"canonicalName": "FixedPoint.uq112x112",
"id": 8037,
"members": [
{
"constant": false,
"id": 8036,
"mutability": "mutable",
"name": "_x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8037,
"src": "363:10:24",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"typeName": {
"id": 8035,
"name": "uint224",
"nodeType": "ElementaryTypeName",
"src": "363:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "uq112x112",
"nodeType": "StructDefinition",
"scope": 8658,
"src": "336:44:24",
"visibility": "public"
},
{
"canonicalName": "FixedPoint.uq144x112",
"id": 8040,
"members": [
{
"constant": false,
"id": 8039,
"mutability": "mutable",
"name": "_x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8040,
"src": "473:10:24",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8038,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "473:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "uq144x112",
"nodeType": "StructDefinition",
"scope": 8658,
"src": "446:44:24",
"visibility": "public"
},
{
"constant": true,
"functionSelector": "552f888a",
"id": 8043,
"mutability": "constant",
"name": "RESOLUTION",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8658,
"src": "496:38:24",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
},
"typeName": {
"id": 8041,
"name": "uint8",
"nodeType": "ElementaryTypeName",
"src": "496:5:24",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"value": {
"argumentTypes": null,
"hexValue": "313132",
"id": 8042,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "531:3:24",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_112_by_1",
"typeString": "int_const 112"
},
"value": "112"
},
"visibility": "public"
},
{
"constant": true,
"functionSelector": "3bf7a83e",
"id": 8046,
"mutability": "constant",
"name": "Q112",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8658,
"src": "540:62:24",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8044,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "540:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "30783130303030303030303030303030303030303030303030303030303030",
"id": 8045,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "571:31:24",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_5192296858534827628530496329220096_by_1",
"typeString": "int_const 5192...(26 digits omitted)...0096"
},
"value": "0x10000000000000000000000000000"
},
"visibility": "public"
},
{
"constant": true,
"id": 8049,
"mutability": "constant",
"name": "Q224",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8658,
"src": "618:91:24",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8047,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "618:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "3078313030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030",
"id": 8048,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "650:59:24",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_26959946667150639794667015087019630673637144422540572481103610249216_by_1",
"typeString": "int_const 2695...(60 digits omitted)...9216"
},
"value": "0x100000000000000000000000000000000000000000000000000000000"
},
"visibility": "private"
},
{
"constant": true,
"id": 8052,
"mutability": "constant",
"name": "LOWER_MASK",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8658,
"src": "725:68:24",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8050,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "725:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "307866666666666666666666666666666666666666666666666666666666",
"id": 8051,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "763:30:24",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_5192296858534827628530496329220095_by_1",
"typeString": "int_const 5192...(26 digits omitted)...0095"
},
"value": "0xffffffffffffffffffffffffffff"
},
"visibility": "private"
},
{
"body": {
"id": 8068,
"nodeType": "Block",
"src": "946:59:24",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"id": 8065,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 8062,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8054,
"src": "981:1:24",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
],
"id": 8061,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "973:7:24",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint224_$",
"typeString": "type(uint224)"
},
"typeName": {
"id": 8060,
"name": "uint224",
"nodeType": "ElementaryTypeName",
"src": "973:7:24",
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
}
}
},
"id": 8063,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "973:10:24",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"id": 8064,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8043,
"src": "987:10:24",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "973:24:24",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
],
"id": 8059,
"name": "uq112x112",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8037,
"src": "963:9:24",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_uq112x112_$8037_storage_ptr_$",
"typeString": "type(struct FixedPoint.uq112x112 storage pointer)"
}
},
"id": 8066,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "963:35:24",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8037_memory_ptr",
"typeString": "struct FixedPoint.uq112x112 memory"
}
},
"functionReturnParameters": 8058,
"id": 8067,
"nodeType": "Return",
"src": "956:42:24"
}
]
},
"documentation": null,
"id": 8069,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "encode",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 8055,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8054,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8069,
"src": "894:9:24",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 8053,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "894:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "893:11:24"
},
"returnParameters": {
"id": 8058,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8057,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8069,
"src": "928:16:24",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8037_memory_ptr",
"typeString": "struct FixedPoint.uq112x112"
},
"typeName": {
"contractScope": null,
"id": 8056,
"name": "uq112x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8037,
"src": "928:9:24",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8037_storage_ptr",
"typeString": "struct FixedPoint.uq112x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "927:18:24"
},
"scope": 8658,
"src": "878:127:24",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 8085,
"nodeType": "Block",
"src": "1122:59:24",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 8082,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 8079,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8071,
"src": "1157:1:24",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
],
"id": 8078,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1149:7:24",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": {
"id": 8077,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1149:7:24",
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
}
}
},
"id": 8080,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1149:10:24",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"id": 8081,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8043,
"src": "1163:10:24",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "1149:24:24",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 8076,
"name": "uq144x112",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8040,
"src": "1139:9:24",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_uq144x112_$8040_storage_ptr_$",
"typeString": "type(struct FixedPoint.uq144x112 storage pointer)"
}
},
"id": 8083,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1139:35:24",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$8040_memory_ptr",
"typeString": "struct FixedPoint.uq144x112 memory"
}
},
"functionReturnParameters": 8075,
"id": 8084,
"nodeType": "Return",
"src": "1132:42:24"
}
]
},
"documentation": null,
"id": 8086,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "encode144",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 8072,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8071,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8086,
"src": "1070:9:24",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
},
"typeName": {
"id": 8070,
"name": "uint144",
"nodeType": "ElementaryTypeName",
"src": "1070:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1069:11:24"
},
"returnParameters": {
"id": 8075,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8074,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8086,
"src": "1104:16:24",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$8040_memory_ptr",
"typeString": "struct FixedPoint.uq144x112"
},
"typeName": {
"contractScope": null,
"id": 8073,
"name": "uq144x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8040,
"src": "1104:9:24",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$8040_storage_ptr",
"typeString": "struct FixedPoint.uq144x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1103:18:24"
},
"scope": 8658,
"src": "1051:130:24",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 8101,
"nodeType": "Block",
"src": "1335:54:24",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"id": 8098,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 8095,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8088,
"src": "1360:4:24",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8037_memory_ptr",
"typeString": "struct FixedPoint.uq112x112 memory"
}
},
"id": 8096,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "_x",
"nodeType": "MemberAccess",
"referencedDeclaration": 8036,
"src": "1360:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"nodeType": "BinaryOperation",
"operator": ">>",
"rightExpression": {
"argumentTypes": null,
"id": 8097,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8043,
"src": "1371:10:24",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "1360:21:24",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
],
"id": 8094,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1352:7:24",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint112_$",
"typeString": "type(uint112)"
},
"typeName": {
"id": 8093,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1352:7:24",
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
}
}
},
"id": 8099,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1352:30:24",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"functionReturnParameters": 8092,
"id": 8100,
"nodeType": "Return",
"src": "1345:37:24"
}
]
},
"documentation": null,
"id": 8102,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "decode",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 8089,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8088,
"mutability": "mutable",
"name": "self",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8102,
"src": "1280:21:24",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8037_memory_ptr",
"typeString": "struct FixedPoint.uq112x112"
},
"typeName": {
"contractScope": null,
"id": 8087,
"name": "uq112x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8037,
"src": "1280:9:24",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$8037_storage_ptr",
"typeString": "struct FixedPoint.uq112x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1279:23:24"
},
"returnParameters": {
"id": 8092,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 8091,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 8102,
"src": "1326:7:24",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 8090,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1326:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1325:9:24"
},
"scope": 8658,
"src": "1264:125:24",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 8117,
"nodeType": "Block",
"src": "1546:54:24",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 8114,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 8111,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 8104,
"src": "1571:4:24",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$8040_memory_ptr",
"typeString": "struct FixedPoint.uq144x112 memory"
}
},
"id": 8112,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "_x",
"nodeType": "MemberAccess",
"referencedDeclaration": 8039,
"src": "1571:7:24",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},