UNPKG

@valueswap/v2-core

Version:
1,169 lines • 45.1 kB
{ "contractName": "UQ112x112", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/second/Documents/work/valueswap-v2-core/contracts/libraries/UQ112x112.sol\":\"UQ112x112\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"/Users/second/Documents/work/valueswap-v2-core/contracts/libraries/UQ112x112.sol\":{\"keccak256\":\"0x2240694530251ab376ae468d0a2d3ee8b3109e56f2acadbc203cdf341506dd31\",\"urls\":[\"bzz-raw://56f55c411faa2924df0915ff77129b9d8c64d3e4d28554e7234f3774ac95958a\",\"dweb:/ipfs/QmYrzUurXL8ijzS8EnLtQTVD7fKPReosg2DsEPXXCY7ec3\"]}},\"version\":1}", "bytecode": "0x60556023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723158205513056be7b70204237488e19348717fced416da871d50c4d0bb481b28aa076164736f6c63430005100032", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723158205513056be7b70204237488e19348717fced416da871d50c4d0bb481b28aa076164736f6c63430005100032", "sourceMap": "183:394:11:-;;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": "183:394:11:-;;;;;;;;", "source": "pragma solidity =0.5.16;\n\n// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))\n\n// range: [0, 2**112 - 1]\n// resolution: 1 / 2**112\n\nlibrary UQ112x112 {\n uint224 constant Q112 = 2**112;\n\n // encode a uint112 as a UQ112x112\n function encode(uint112 y) internal pure returns (uint224 z) {\n z = uint224(y) * Q112; // never overflows\n }\n\n // divide a UQ112x112 by a uint112, returning a UQ112x112\n function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {\n z = x / uint224(y);\n }\n}\n", "sourcePath": "/Users/second/Documents/work/valueswap-v2-core/contracts/libraries/UQ112x112.sol", "ast": { "absolutePath": "/Users/second/Documents/work/valueswap-v2-core/contracts/libraries/UQ112x112.sol", "exportedSymbols": { "UQ112x112": [ 2367 ] }, "id": 2368, "nodeType": "SourceUnit", "nodes": [ { "id": 2327, "literals": [ "solidity", "=", "0.5", ".16" ], "nodeType": "PragmaDirective", "src": "0:24:11" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 2367, "linearizedBaseContracts": [ 2367 ], "name": "UQ112x112", "nodeType": "ContractDefinition", "nodes": [ { "constant": true, "id": 2332, "name": "Q112", "nodeType": "VariableDeclaration", "scope": 2367, "src": "207:30:11", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "typeName": { "id": 2328, "name": "uint224", "nodeType": "ElementaryTypeName", "src": "207:7:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "value": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_5192296858534827628530496329220096_by_1", "typeString": "int_const 5192...(26 digits omitted)...0096" }, "id": 2331, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "hexValue": "32", "id": 2329, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "231:1:11", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, "value": "2" }, "nodeType": "BinaryOperation", "operator": "**", "rightExpression": { "argumentTypes": null, "hexValue": "313132", "id": 2330, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "234:3:11", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_112_by_1", "typeString": "int_const 112" }, "value": "112" }, "src": "231:6:11", "typeDescriptions": { "typeIdentifier": "t_rational_5192296858534827628530496329220096_by_1", "typeString": "int_const 5192...(26 digits omitted)...0096" } }, "visibility": "internal" }, { "body": { "id": 2347, "nodeType": "Block", "src": "344:57:11", "statements": [ { "expression": { "argumentTypes": null, "id": 2345, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 2339, "name": "z", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2337, "src": "354:1:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "id": 2344, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 2341, "name": "y", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2334, "src": "366:1:11", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint112", "typeString": "uint112" } ], "id": 2340, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "358:7:11", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint224_$", "typeString": "type(uint224)" }, "typeName": "uint224" }, "id": 2342, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "358:10:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "id": 2343, "name": "Q112", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2332, "src": "371:4:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "src": "358:17:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "src": "354:21:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "id": 2346, "nodeType": "ExpressionStatement", "src": "354:21:11" } ] }, "documentation": null, "id": 2348, "implemented": true, "kind": "function", "modifiers": [], "name": "encode", "nodeType": "FunctionDefinition", "parameters": { "id": 2335, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 2334, "name": "y", "nodeType": "VariableDeclaration", "scope": 2348, "src": "299:9:11", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" }, "typeName": { "id": 2333, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "299:7:11", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "value": null, "visibility": "internal" } ], "src": "298:11:11" }, "returnParameters": { "id": 2338, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 2337, "name": "z", "nodeType": "VariableDeclaration", "scope": 2348, "src": "333:9:11", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "typeName": { "id": 2336, "name": "uint224", "nodeType": "ElementaryTypeName", "src": "333:7:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "value": null, "visibility": "internal" } ], "src": "332:11:11" }, "scope": 2367, "src": "283:118:11", "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, { "body": { "id": 2365, "nodeType": "Block", "src": "540:35:11", "statements": [ { "expression": { "argumentTypes": null, "id": 2363, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 2357, "name": "z", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2355, "src": "550:1:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "id": 2362, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 2358, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2350, "src": "554:1:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "nodeType": "BinaryOperation", "operator": "/", "rightExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 2360, "name": "y", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2352, "src": "566:1:11", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint112", "typeString": "uint112" } ], "id": 2359, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "558:7:11", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint224_$", "typeString": "type(uint224)" }, "typeName": "uint224" }, "id": 2361, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "558:10:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "src": "554:14:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "src": "550:18:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "id": 2364, "nodeType": "ExpressionStatement", "src": "550:18:11" } ] }, "documentation": null, "id": 2366, "implemented": true, "kind": "function", "modifiers": [], "name": "uqdiv", "nodeType": "FunctionDefinition", "parameters": { "id": 2353, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 2350, "name": "x", "nodeType": "VariableDeclaration", "scope": 2366, "src": "484:9:11", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "typeName": { "id": 2349, "name": "uint224", "nodeType": "ElementaryTypeName", "src": "484:7:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 2352, "name": "y", "nodeType": "VariableDeclaration", "scope": 2366, "src": "495:9:11", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" }, "typeName": { "id": 2351, "name": "uint112", "nodeType": "ElementaryTypeName", "src": "495:7:11", "typeDescriptions": { "typeIdentifier": "t_uint112", "typeString": "uint112" } }, "value": null, "visibility": "internal" } ], "src": "483:22:11" }, "returnParameters": { "id": 2356, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 2355, "name": "z", "nodeType": "VariableDeclaration", "scope": 2366, "src": "529:9:11", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "typeName": { "id": 2354, "name": "uint224", "nodeType": "ElementaryTypeName", "src": "529:7:11", "typeDescriptions": { "typeIdentifier": "t_uint224", "typeString": "uint224" } }, "value": null, "visibility": "internal" } ], "src": "528:11:11" }, "scope": 2367, "src": "469:106:11", "stateMutability": "pure", "superFunction": null, "visibility": "internal" } ], "scope": 2368, "src": "183:394:11" } ], "src": "0:578:11" }, "legacyAST": { "attributes": { "absolutePath": "/Users/second/Documents/work/valueswap-v2-core/contracts/libraries/UQ112x112.sol", "exportedSymbols": { "UQ112x112": [ 2367 ] } }, "children": [ { "attributes": { "literals": [ "solidity", "=", "0.5", ".16" ] }, "id": 2327, "name": "PragmaDirective", "src": "0:24:11" }, { "attributes": { "baseContracts": [ null ], "contractDependencies": [ null ], "contractKind": "library", "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ 2367 ], "name": "UQ112x112", "scope": 2368 }, "children": [ { "attributes": { "constant": true, "name": "Q112", "scope": 2367, "stateVariable": true, "storageLocation": "default", "type": "uint224", "visibility": "internal" }, "children": [ { "attributes": { "name": "uint224", "type": "uint224" }, "id": 2328, "name": "ElementaryTypeName", "src": "207:7:11" }, { "attributes": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_5192296858534827628530496329220096_by_1", "typeString": "int_const 5192...(26 digits omitted)...0096" }, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "operator": "**", "type": "int_const 5192...(26 digits omitted)...0096" }, "children": [ { "attributes": { "argumentTypes": null, "hexvalue": "32", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "subdenomination": null, "token": "number", "type": "int_const 2", "value": "2" }, "id": 2329, "name": "Literal", "src": "231:1:11" }, { "attributes": { "argumentTypes": null, "hexvalue": "313132", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "subdenomination": null, "token": "number", "type": "int_const 112", "value": "112" }, "id": 2330, "name": "Literal", "src": "234:3:11" } ], "id": 2331, "name": "BinaryOperation", "src": "231:6:11" } ], "id": 2332, "name": "VariableDeclaration", "src": "207:30:11" }, { "attributes": { "documentation": null, "implemented": true, "isConstructor": false, "kind": "function", "modifiers": [ null ], "name": "encode", "scope": 2367, "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, "children": [ { "children": [ { "attributes": { "constant": false, "name": "y", "scope": 2348, "stateVariable": false, "storageLocation": "default", "type": "uint112", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "uint112", "type": "uint112" }, "id": 2333, "name": "ElementaryTypeName", "src": "299:7:11" } ], "id": 2334, "name": "VariableDeclaration", "src": "299:9:11" } ], "id": 2335, "name": "ParameterList", "src": "298:11:11" }, { "children": [ { "attributes": { "constant": false, "name": "z", "scope": 2348, "stateVariable": false, "storageLocation": "default", "type": "uint224", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "uint224", "type": "uint224" }, "id": 2336, "name": "ElementaryTypeName", "src": "333:7:11" } ], "id": 2337, "name": "VariableDeclaration", "src": "333:9:11" } ], "id": 2338, "name": "ParameterList", "src": "332:11:11" }, { "children": [ { "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "=", "type": "uint224" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 2337, "type": "uint224", "value": "z" }, "id": 2339, "name": "Identifier", "src": "354:1:11" }, { "attributes": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "*", "type": "uint224" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, "names": [ null ], "type": "uint224", "type_conversion": true }, "children": [ { "attributes": { "argumentTypes": [ { "typeIdentifier": "t_uint112", "typeString": "uint112" } ], "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "type": "type(uint224)", "value": "uint224" }, "id": 2340, "name": "ElementaryTypeNameExpression", "src": "358:7:11" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 2334, "type": "uint112", "value": "y" }, "id": 2341, "name": "Identifier", "src": "366:1:11" } ], "id": 2342, "name": "FunctionCall", "src": "358:10:11" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 2332, "type": "uint224", "value": "Q112" }, "id": 2343, "name": "Identifier", "src": "371:4:11" } ], "id": 2344, "name": "BinaryOperation", "src": "358:17:11" } ], "id": 2345, "name": "Assignment", "src": "354:21:11" } ], "id": 2346, "name": "ExpressionStatement", "src": "354:21:11" } ], "id": 2347, "name": "Block", "src": "344:57:11" } ], "id": 2348, "name": "FunctionDefinition", "src": "283:118:11" }, { "attributes": { "documentation": null, "implemented": true, "isConstructor": false, "kind": "function", "modifiers": [ null ], "name": "uqdiv", "scope": 2367, "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, "children": [ { "children": [ { "attributes": { "constant": false, "name": "x", "scope": 2366, "stateVariable": false, "storageLocation": "default", "type": "uint224", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "uint224", "type": "uint224" }, "id": 2349, "name": "ElementaryTypeName", "src": "484:7:11" } ], "id": 2350, "name": "VariableDeclaration", "src": "484:9:11" }, { "attributes": { "constant": false, "name": "y", "scope": 2366, "stateVariable": false, "storageLocation": "default", "type": "uint112", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "uint112", "type": "uint112" }, "id": 2351, "name": "ElementaryTypeName", "src": "495:7:11" } ], "id": 2352, "name": "VariableDeclaration", "src": "495:9:11" } ], "id": 2353, "name": "ParameterList", "src": "483:22:11" }, { "children": [ { "attributes": { "constant": false, "name": "z", "scope": 2366, "stateVariable": false, "storageLocation": "default", "type": "uint224", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "uint224", "type": "uint224" }, "id": 2354, "name": "ElementaryTypeName", "src": "529:7:11" } ], "id": 2355, "name": "VariableDeclaration", "src": "529:9:11" } ], "id": 2356, "name": "ParameterList", "src": "528:11:11" }, { "children": [ { "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "=", "type": "uint224" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 2355, "type": "uint224", "value": "z" }, "id": 2357, "name": "Identifier", "src": "550:1:11" }, { "attributes": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint224", "typeString": "uint224" }, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "/", "type": "uint224" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 2350, "type": "uint224", "value": "x" }, "id": 2358, "name": "Identifier", "src": "554:1:11" }, { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, "names": [ null ], "type": "uint224", "type_conversion": true }, "children": [ { "attributes": { "argumentTypes": [ { "typeIdentifier": "t_uint112", "typeString": "uint112" } ], "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "type": "type(uint224)", "value": "uint224" }, "id": 2359, "name": "ElementaryTypeNameExpression", "src": "558:7:11" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 2352, "type": "uint112", "value": "y" }, "id": 2360, "name": "Identifier", "src": "566:1:11" } ], "id": 2361, "name": "FunctionCall", "src": "558:10:11" } ], "id": 2362, "name": "BinaryOperation", "src": "554:14:11" } ], "id": 2363, "name": "Assignment", "src": "550:18:11" } ], "id": 2364, "name": "ExpressionStatement", "src": "550:18:11" } ], "id": 2365, "name": "Block", "src": "540:35:11" } ], "id": 2366, "name": "FunctionDefinition", "src": "469:106:11" } ], "id": 2367, "name": "ContractDefinition", "src": "183:394:11" } ], "id": 2368, "name": "SourceUnit", "src": "0:578:11" }, "compiler": { "name": "solc", "version": "0.5.16+commit.9c3226ce.Emscripten.clang" }, "networks": {}, "schemaVersion": "3.3.3", "updatedAt": "2021-01-30T15:36:09.994Z", "devdoc": { "methods": {} }, "userdoc": { "methods": {} } }