@marketprotocol/marketprotocol
Version:
Decentralized Derivatives Trading Protocol For The Ethereum Blockchain
1,140 lines (1,139 loc) • 313 kB
JSON
{
"contractName": "MathLib",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.5.2+commit.1df8f40c\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{},\"title\":\"Math function library with overflow protection inspired by Open Zeppelin\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/MathLib.sol\":\"MathLib\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/MathLib.sol\":{\"keccak256\":\"0x28e7ed8ea6e300e4d0dbf0e63b2414ba71bc1596b7142690c1bf4016e313abee\",\"urls\":[\"bzzr://6bb2953cfd96de25e614d77e8a4793a8bc11f9eae0d2d0fb9614488bca7e1754\"]}},\"version\":1}",
"bytecode": "0x604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a72305820536710891897d9bccd15308728c75a71fe41ab5a1adfc5c04519d966be053add0029",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a72305820536710891897d9bccd15308728c75a71fe41ab5a1adfc5c04519d966be053add0029",
"sourceMap": "716:3175:5:-;;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": "716:3175:5:-;;;;;;;;",
"source": "/*\n Copyright 2017-2019 Phillip A. Elsasser\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\npragma solidity 0.5.2;\n\n\n/// @title Math function library with overflow protection inspired by Open Zeppelin\nlibrary MathLib {\n\n int256 constant INT256_MIN = int256((uint256(1) << 255));\n int256 constant INT256_MAX = int256(~((uint256(1) << 255)));\n\n function multiply(uint256 a, uint256 b) pure internal returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"MathLib: multiplication overflow\");\n\n return c;\n }\n\n function divideFractional(\n uint256 a,\n uint256 numerator,\n uint256 denominator\n ) pure internal returns (uint256)\n {\n return multiply(a, numerator) / denominator;\n }\n\n function subtract(uint256 a, uint256 b) pure internal returns (uint256) {\n require(b <= a, \"MathLib: subtraction overflow\");\n return a - b;\n }\n\n function add(uint256 a, uint256 b) pure internal returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"MathLib: addition overflow\");\n return c;\n }\n\n /// @notice determines the amount of needed collateral for a given position (qty and price)\n /// @param priceFloor lowest price the contract is allowed to trade before expiration\n /// @param priceCap highest price the contract is allowed to trade before expiration\n /// @param qtyMultiplier multiplier for qty from base units\n /// @param longQty qty to redeem\n /// @param shortQty qty to redeem\n /// @param price of the trade\n function calculateCollateralToReturn(\n uint priceFloor,\n uint priceCap,\n uint qtyMultiplier,\n uint longQty,\n uint shortQty,\n uint price\n ) pure internal returns (uint)\n {\n uint neededCollateral = 0;\n uint maxLoss;\n if (longQty > 0) { // calculate max loss from entry price to floor\n if (price <= priceFloor) {\n maxLoss = 0;\n } else {\n maxLoss = subtract(price, priceFloor);\n }\n neededCollateral = multiply(multiply(maxLoss, longQty), qtyMultiplier);\n }\n\n if (shortQty > 0) { // calculate max loss from entry price to ceiling;\n if (price >= priceCap) {\n maxLoss = 0;\n } else {\n maxLoss = subtract(priceCap, price);\n }\n neededCollateral = add(neededCollateral, multiply(multiply(maxLoss, shortQty), qtyMultiplier));\n }\n return neededCollateral;\n }\n\n /// @notice determines the amount of needed collateral for minting a long and short position token\n function calculateTotalCollateral(\n uint priceFloor,\n uint priceCap,\n uint qtyMultiplier\n ) pure internal returns (uint)\n {\n return multiply(subtract(priceCap, priceFloor), qtyMultiplier);\n }\n\n /// @notice calculates the fee in terms of base units of the collateral token per unit pair minted.\n function calculateFeePerUnit(\n uint priceFloor,\n uint priceCap,\n uint qtyMultiplier,\n uint feeInBasisPoints\n ) pure internal returns (uint)\n {\n uint midPrice = add(priceCap, priceFloor) / 2;\n return multiply(multiply(midPrice, qtyMultiplier), feeInBasisPoints) / 10000;\n }\n}\n",
"sourcePath": "/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/MathLib.sol",
"ast": {
"absolutePath": "/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/MathLib.sol",
"exportedSymbols": {
"MathLib": [
1489
]
},
"id": 1490,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 1220,
"literals": [
"solidity",
"0.5",
".2"
],
"nodeType": "PragmaDirective",
"src": "607:22:5"
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@title Math function library with overflow protection inspired by Open Zeppelin",
"fullyImplemented": true,
"id": 1489,
"linearizedBaseContracts": [
1489
],
"name": "MathLib",
"nodeType": "ContractDefinition",
"nodes": [
{
"constant": true,
"id": 1230,
"name": "INT256_MIN",
"nodeType": "VariableDeclaration",
"scope": 1489,
"src": "739:56:5",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
},
"typeName": {
"id": 1221,
"name": "int256",
"nodeType": "ElementaryTypeName",
"src": "739:6:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"value": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1227,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "31",
"id": 1224,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "784:1:5",
"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": 1223,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "776:7:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": "uint256"
},
"id": 1225,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "776:10:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"hexValue": "323535",
"id": 1226,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "790:3:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_255_by_1",
"typeString": "int_const 255"
},
"value": "255"
},
"src": "776:17:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"id": 1228,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "775:19:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 1222,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "768:6:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_int256_$",
"typeString": "type(int256)"
},
"typeName": "int256"
},
"id": 1229,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "768:27:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"visibility": "internal"
},
{
"constant": true,
"id": 1242,
"name": "INT256_MAX",
"nodeType": "VariableDeclaration",
"scope": 1489,
"src": "801:59:5",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
},
"typeName": {
"id": 1231,
"name": "int256",
"nodeType": "ElementaryTypeName",
"src": "801:6:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"value": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 1240,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "UnaryOperation",
"operator": "~",
"prefix": true,
"src": "837:22:5",
"subExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1237,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "31",
"id": 1234,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "848:1:5",
"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": 1233,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "840:7:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": "uint256"
},
"id": 1235,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "840:10:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<<",
"rightExpression": {
"argumentTypes": null,
"hexValue": "323535",
"id": 1236,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "854:3:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_255_by_1",
"typeString": "int_const 255"
},
"value": "255"
},
"src": "840:17:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"id": 1238,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "839:19:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"id": 1239,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "838:21:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 1232,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "830:6:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_int256_$",
"typeString": "type(int256)"
},
"typeName": "int256"
},
"id": 1241,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "830:30:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"visibility": "internal"
},
{
"body": {
"id": 1275,
"nodeType": "Block",
"src": "939:174:5",
"statements": [
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1253,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1251,
"name": "a",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1244,
"src": "953:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 1252,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "958:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "953:6:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 1257,
"nodeType": "IfStatement",
"src": "949:45:5",
"trueBody": {
"id": 1256,
"nodeType": "Block",
"src": "961:33:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"hexValue": "30",
"id": 1254,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "982:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"functionReturnParameters": 1250,
"id": 1255,
"nodeType": "Return",
"src": "975:8:5"
}
]
}
},
{
"assignments": [
1259
],
"declarations": [
{
"constant": false,
"id": 1259,
"name": "c",
"nodeType": "VariableDeclaration",
"scope": 1275,
"src": "1004:9:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1258,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1004:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 1263,
"initialValue": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1262,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1260,
"name": "a",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1244,
"src": "1016:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "*",
"rightExpression": {
"argumentTypes": null,
"id": 1261,
"name": "b",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1246,
"src": "1020:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "1016:5:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1004:17:5"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1269,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1267,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1265,
"name": "c",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1259,
"src": "1039:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "/",
"rightExpression": {
"argumentTypes": null,
"id": 1266,
"name": "a",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1244,
"src": "1043:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "1039:5:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"id": 1268,
"name": "b",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1246,
"src": "1048:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "1039:10:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "4d6174684c69623a206d756c7469706c69636174696f6e206f766572666c6f77",
"id": 1270,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1052:34:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_1915c4c9d4b642800e7af35a49ea0b6fbb09245fa5419ef3563837553ba04991",
"typeString": "literal_string \"MathLib: multiplication overflow\""
},
"value": "MathLib: multiplication overflow"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_1915c4c9d4b642800e7af35a49ea0b6fbb09245fa5419ef3563837553ba04991",
"typeString": "literal_string \"MathLib: multiplication overflow\""
}
],
"id": 1264,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
3189,
3190
],
"referencedDeclaration": 3190,
"src": "1031:7:5",
"typeDescriptions": {
"typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$",
"typeString": "function (bool,string memory) pure"
}
},
"id": 1271,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1031:56:5",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 1272,
"nodeType": "ExpressionStatement",
"src": "1031:56:5"
},
{
"expression": {
"argumentTypes": null,
"id": 1273,
"name": "c",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1259,
"src": "1105:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"functionReturnParameters": 1250,
"id": 1274,
"nodeType": "Return",
"src": "1098:8:5"
}
]
},
"documentation": null,
"id": 1276,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "multiply",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 1247,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 1244,
"name": "a",
"nodeType": "VariableDeclaration",
"scope": 1276,
"src": "885:9:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1243,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "885:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 1246,
"name": "b",
"nodeType": "VariableDeclaration",
"scope": 1276,
"src": "896:9:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1245,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "896:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "884:22:5"
},
"returnParameters": {
"id": 1250,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 1249,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 1276,
"src": "930:7:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1248,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "930:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "929:9:5"
},
"scope": 1489,
"src": "867:246:5",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 1294,
"nodeType": "Block",
"src": "1262:60:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1292,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 1288,
"name": "a",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1278,
"src": "1288:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,
"id": 1289,
"name": "numerator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1280,
"src": "1291:9:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 1287,
"name": "multiply",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1276,
"src": "1279:8:5",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 1290,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1279:22:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "/",
"rightExpression": {
"argumentTypes": null,
"id": 1291,
"name": "denominator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1282,
"src": "1304:11:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "1279:36:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"functionReturnParameters": 1286,
"id": 1293,
"nodeType": "Return",
"src": "1272:43:5"
}
]
},
"documentation": null,
"id": 1295,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "divideFractional",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 1283,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 1278,
"name": "a",
"nodeType": "VariableDeclaration",
"scope": 1295,
"src": "1154:9:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1277,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1154:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 1280,
"name": "numerator",
"nodeType": "VariableDeclaration",
"scope": 1295,
"src": "1173:17:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1279,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1173:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 1282,
"name": "denominator",
"nodeType": "VariableDeclaration",
"scope": 1295,
"src": "1200:19:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1281,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1200:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1144:81:5"
},
"returnParameters": {
"id": 1286,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 1285,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 1295,
"src": "1249:7:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1284,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1249:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1248:9:5"
},
"scope": 1489,
"src": "1119:203:5",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 1315,
"nodeType": "Block",
"src": "1400:87:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1307,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1305,
"name": "b",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1299,
"src": "1418:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",