@sonicxchain/soxswap-periphery
Version:
Peripheral smart contracts for interacting with Soxswap
1,172 lines (1,171 loc) • 604 kB
JSON
{
"contractName": "FixedPoint",
"abi": [],
"bytecode": "0x604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a72305820d1d956bfd6c986231bde1a437dd4ecdcfb1b967fc85e78ed695d74daaa90cb830029",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a72305820d1d956bfd6c986231bde1a437dd4ecdcfb1b967fc85e78ed695d74daaa90cb830029",
"sourceMap": "188:5028:11:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24",
"deployedSourceMap": "188:5028:11:-;;;;;;;;",
"source": "pragma solidity >=0.4.0;\r\n\r\nimport './FullMath.sol';\r\nimport './Babylonian.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 private constant RESOLUTION = 112;\r\n uint256 private constant Q112 = uint256(1) << RESOLUTION;\r\n uint256 private constant Q224 = Q112 << RESOLUTION;\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 uint144 z = decode144(mul(self, uint256(y < 0 ? -y : y)));\r\n return y < 0 ? -int256(z) : 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_OVERFLOW_UPPER');\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_OVERFLOW_SUM');\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: DIV_BY_ZERO_DIVUQ');\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 // lossy\r\n function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {\r\n require(denominator > 0, 'FixedPoint: DIV_BY_ZERO_FRACTION');\r\n return uq112x112((uint224(numerator) << RESOLUTION) / denominator);\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 > 1, 'FixedPoint: DIV_BY_ZERO_RECIPROCAL_OR_OVERFLOW');\r\n return uq112x112(uint224(Q224 / self._x));\r\n }\r\n\r\n // square root of a UQ112x112\r\n // lossy to 40 bits\r\n function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {\r\n return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 32) << 40));\r\n }\r\n}\r\n",
"sourcePath": "@sonicxchain/soxswap-lib/contracts/libraries/FixedPoint.sol",
"ast": {
"absolutePath": "@sonicxchain/soxswap-lib/contracts/libraries/FixedPoint.sol",
"exportedSymbols": {
"FixedPoint": [
4186
]
},
"id": 4187,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 3713,
"literals": [
"solidity",
">=",
"0.4",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:24:11"
},
{
"absolutePath": "@sonicxchain/soxswap-lib/contracts/libraries/FullMath.sol",
"file": "./FullMath.sol",
"id": 3714,
"nodeType": "ImportDirective",
"scope": 4187,
"sourceUnit": 4380,
"src": "28:24:11",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@sonicxchain/soxswap-lib/contracts/libraries/Babylonian.sol",
"file": "./Babylonian.sol",
"id": 3715,
"nodeType": "ImportDirective",
"scope": 4187,
"sourceUnit": 3712,
"src": "54:26:11",
"symbolAliases": [],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": null,
"fullyImplemented": true,
"id": 4186,
"linearizedBaseContracts": [
4186
],
"name": "FixedPoint",
"nodeType": "ContractDefinition",
"nodes": [
{
"canonicalName": "FixedPoint.uq112x112",
"id": 3718,
"members": [
{
"constant": false,
"id": 3717,
"name": "_x",
"nodeType": "VariableDeclaration",
"scope": 3718,
"src": "304:10:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"typeName": {
"id": 3716,
"name": "uint224",
"nodeType": "ElementaryTypeName",
"src": "304:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "uq112x112",
"nodeType": "StructDefinition",
"scope": 4186,
"src": "276:46:11",
"visibility": "public"
},
{
"canonicalName": "FixedPoint.uq144x112",
"id": 3721,
"members": [
{
"constant": false,
"id": 3720,
"name": "_x",
"nodeType": "VariableDeclaration",
"scope": 3721,
"src": "420:10:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 3719,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "420:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "uq144x112",
"nodeType": "StructDefinition",
"scope": 4186,
"src": "392:46:11",
"visibility": "public"
},
{
"constant": true,
"id": 3724,
"name": "RESOLUTION",
"nodeType": "VariableDeclaration",
"scope": 4186,
"src": "446:39:11",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
},
"typeName": {
"id": 3722,
"name": "uint8",
"nodeType": "ElementaryTypeName",
"src": "446:5:11",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"value": {
"argumentTypes": null,
"hexValue": "313132",
"id": 3723,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "482:3:11",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_112_by_1",
"typeString": "int_const 112"
},
"value": "112"
},
"visibility": "private"
},
{
"constant": true,
"id": 3731,
"name": "Q112",
"nodeType": "VariableDeclaration",
"scope": 4186,
"src": "492:56:11",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 3725,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "492:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 3730,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "31",
"id": 3727,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "532:1:11",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
}
],
"id": 3726,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "524:7:11",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": "uint256"
},
"id": 3728,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "524:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"id": 3729,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3724,
"src": "538:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "524:24:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"visibility": "private"
},
{
"constant": true,
"id": 3736,
"name": "Q224",
"nodeType": "VariableDeclaration",
"scope": 4186,
"src": "555:50:11",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 3732,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "555:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 3735,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 3733,
"name": "Q112",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3731,
"src": "587:4:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"id": 3734,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3724,
"src": "595:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "587:18:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"visibility": "private"
},
{
"constant": true,
"id": 3739,
"name": "LOWER_MASK",
"nodeType": "VariableDeclaration",
"scope": 4186,
"src": "612:68:11",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 3737,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "612:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "307866666666666666666666666666666666666666666666666666666666",
"id": 3738,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "650:30:11",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_5192296858534827628530496329220095_by_1",
"typeString": "int_const 5192...(26 digits omitted)...0095"
},
"value": "0xffffffffffffffffffffffffffff"
},
"visibility": "private"
},
{
"body": {
"id": 3754,
"nodeType": "Block",
"src": "836:61:11",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"id": 3751,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 3748,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3741,
"src": "872:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
],
"id": 3747,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "864:7:11",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint224_$",
"typeString": "type(uint224)"
},
"typeName": "uint224"
},
"id": 3749,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "864:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"id": 3750,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3724,
"src": "878:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "864:24:11",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
],
"id": 3746,
"name": "uq112x112",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3718,
"src": "854:9:11",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_uq112x112_$3718_storage_ptr_$",
"typeString": "type(struct FixedPoint.uq112x112 storage pointer)"
}
},
"id": 3752,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "854:35:11",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$3718_memory",
"typeString": "struct FixedPoint.uq112x112 memory"
}
},
"functionReturnParameters": 3745,
"id": 3753,
"nodeType": "Return",
"src": "847:42:11"
}
]
},
"documentation": null,
"id": 3755,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "encode",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 3742,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3741,
"name": "x",
"nodeType": "VariableDeclaration",
"scope": 3755,
"src": "784:9:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 3740,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "784:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "783:11:11"
},
"returnParameters": {
"id": 3745,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3744,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 3755,
"src": "818:16:11",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$3718_memory_ptr",
"typeString": "struct FixedPoint.uq112x112"
},
"typeName": {
"contractScope": null,
"id": 3743,
"name": "uq112x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 3718,
"src": "818:9:11",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$3718_storage_ptr",
"typeString": "struct FixedPoint.uq112x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "817:18:11"
},
"scope": 4186,
"src": "768:129:11",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 3770,
"nodeType": "Block",
"src": "1017:61:11",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 3767,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 3764,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3757,
"src": "1053:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
],
"id": 3763,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1045:7:11",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": "uint256"
},
"id": 3765,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1045:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"id": 3766,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3724,
"src": "1059:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "1045:24:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 3762,
"name": "uq144x112",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3721,
"src": "1035:9:11",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_uq144x112_$3721_storage_ptr_$",
"typeString": "type(struct FixedPoint.uq144x112 storage pointer)"
}
},
"id": 3768,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1035:35:11",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$3721_memory",
"typeString": "struct FixedPoint.uq144x112 memory"
}
},
"functionReturnParameters": 3761,
"id": 3769,
"nodeType": "Return",
"src": "1028:42:11"
}
]
},
"documentation": null,
"id": 3771,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "encode144",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 3758,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3757,
"name": "x",
"nodeType": "VariableDeclaration",
"scope": 3771,
"src": "965:9:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
},
"typeName": {
"id": 3756,
"name": "uint144",
"nodeType": "ElementaryTypeName",
"src": "965:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "964:11:11"
},
"returnParameters": {
"id": 3761,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3760,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 3771,
"src": "999:16:11",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$3721_memory_ptr",
"typeString": "struct FixedPoint.uq144x112"
},
"typeName": {
"contractScope": null,
"id": 3759,
"name": "uq144x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 3721,
"src": "999:9:11",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$3721_storage_ptr",
"typeString": "struct FixedPoint.uq144x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "998:18:11"
},
"scope": 4186,
"src": "946:132:11",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 3785,
"nodeType": "Block",
"src": "1235:56:11",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
},
"id": 3782,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 3779,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3773,
"src": "1261:4:11",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$3718_memory_ptr",
"typeString": "struct FixedPoint.uq112x112 memory"
}
},
"id": 3780,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "_x",
"nodeType": "MemberAccess",
"referencedDeclaration": 3717,
"src": "1261:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
},
"nodeType": "BinaryOperation",
"operator": ">>",
"rightExpression": {
"argumentTypes": null,
"id": 3781,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3724,
"src": "1272:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "1261:21:11",
"typeDescriptions": {
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint224",
"typeString": "uint224"
}
],
"id": 3778,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1253:7:11",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint112_$",
"typeString": "type(uint112)"
},
"typeName": "uint112"
},
"id": 3783,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1253:30:11",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"functionReturnParameters": 3777,
"id": 3784,
"nodeType": "Return",
"src": "1246:37:11"
}
]
},
"documentation": null,
"id": 3786,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "decode",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 3774,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3773,
"name": "self",
"nodeType": "VariableDeclaration",
"scope": 3786,
"src": "1180:21:11",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$3718_memory_ptr",
"typeString": "struct FixedPoint.uq112x112"
},
"typeName": {
"contractScope": null,
"id": 3772,
"name": "uq112x112",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 3718,
"src": "1180:9:11",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq112x112_$3718_storage_ptr",
"typeString": "struct FixedPoint.uq112x112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1179:23:11"
},
"returnParameters": {
"id": 3777,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3776,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 3786,
"src": "1226:7:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 3775,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1226:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1225:9:11"
},
"scope": 4186,
"src": "1164:127:11",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 3800,
"nodeType": "Block",
"src": "1451:56:11",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 3797,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 3794,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3788,
"src": "1477:4:11",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$3721_memory_ptr",
"typeString": "struct FixedPoint.uq144x112 memory"
}
},
"id": 3795,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "_x",
"nodeType": "MemberAccess",
"referencedDeclaration": 3720,
"src": "1477:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": ">>",
"rightExpression": {
"argumentTypes": null,
"id": 3796,
"name": "RESOLUTION",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3724,
"src": "1488:10:11",
"typeDescriptions": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
}
},
"src": "1477:21:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 3793,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1469:7:11",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint144_$",
"typeString": "type(uint144)"
},
"typeName": "uint144"
},
"id": 3798,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1469:30:11",
"typeDescriptions": {
"typeIdentifier": "t_uint144",
"typeString": "uint144"
}
},
"functionReturnParameters": 3792,
"id": 3799,
"nodeType": "Return",
"src": "1462:37:11"
}
]
},
"documentation": null,
"id": 3801,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "decode144",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 3789,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3788,
"name": "self",
"nodeType": "VariableDeclaration",
"scope": 3801,
"src": "1396:21:11",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_uq144x112_$3721_memory_ptr",
"typeString": "struct FixedPoint.uq144x112"
},
"typeName": {
"contractScope": null,
"id": 3787,
"name": "uq144x112",