@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
1,084 lines (1,083 loc) • 255 kB
JSON
{
"contractName": "DolomiteMarginMath",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"author\":\"dYdX * Library for non-standard Math functions\",\"methods\":{},\"title\":\"Math\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol\":\"DolomiteMarginMath\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol\":{\"keccak256\":\"0x53f205f6a779d579be29faa9412c806a892b3e605fff092dfd9d14d936fa019f\",\"urls\":[\"bzz-raw://0ff936f89602a63b8e6a4eb4ce8f87673c0f45b7ce29694920905a3f0b5a6a69\",\"dweb:/ipfs/QmbYME9BeEvPC1ndV8EaUDX5fDMghLc3rocNUxFtgHmg8m\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Require.sol\":{\"keccak256\":\"0x05a2a90b41b6a5f42f0a72da63d015fb0b406a9ba2172823352e522e8bf3a606\",\"urls\":[\"bzz-raw://19883f0c6d33266f756ec5c3d17539524aa24b993c46c33f8400801d09373a6c\",\"dweb:/ipfs/QmYX2fwK3vQQDSZLMrc5wMfeb8RWrcC9CGX8XECLty8QDk\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]}},\"version\":1}",
"bytecode": "0x60636023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a72315820cf18a9c6cb0f245077c5c002bd5d873d8b1535921b20fc0ea39e2ad0020f72cb6c6578706572696d656e74616cf564736f6c63430005100040",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a72315820cf18a9c6cb0f245077c5c002bd5d873d8b1535921b20fc0ea39e2ad0020f72cb6c6578706572696d656e74616cf564736f6c63430005100040",
"sourceMap": "860:2905:92:-;;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": "860:2905:92:-;;;;;;;;",
"source": "/*\n\n Copyright 2019 dYdX Trading Inc.\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\n*/\n\npragma solidity ^0.5.7;\npragma experimental ABIEncoderV2;\n\nimport { SafeMath } from \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport { Require } from \"./Require.sol\";\n\n\n/**\n * @title Math\n * @author dYdX\n *\n * Library for non-standard Math functions\n */\nlibrary DolomiteMarginMath {\n using SafeMath for uint256;\n\n // ============ Constants ============\n\n bytes32 private constant FILE = \"Math\";\n\n // ============ Library Functions ============\n\n /*\n * Return target * (numerator / denominator).\n */\n function getPartial(\n uint256 target,\n uint256 numerator,\n uint256 denominator\n )\n internal\n pure\n returns (uint256)\n {\n return target.mul(numerator).div(denominator);\n }\n\n /*\n * Return target * (numerator / denominator), but rounded half-up. Meaning, a result of 101.1 rounds to 102\n * instead of 101.\n */\n function getPartialRoundUp(\n uint256 target,\n uint256 numerator,\n uint256 denominator\n )\n internal\n pure\n returns (uint256)\n {\n if (target == 0 || numerator == 0) {\n // SafeMath will check for zero denominator\n return SafeMath.div(0, denominator);\n }\n return target.mul(numerator).sub(1).div(denominator).add(1);\n }\n\n /*\n * Return target * (numerator / denominator), but rounded half-up. Meaning, a result of 101.5 rounds to 102\n * instead of 101.\n */\n function getPartialRoundHalfUp(\n uint256 target,\n uint256 numerator,\n uint256 denominator\n )\n internal\n pure\n returns (uint256)\n {\n if (target == 0 || numerator == 0) {\n // SafeMath will check for zero denominator\n return SafeMath.div(0, denominator);\n }\n uint result = target.mul(numerator);\n // round the denominator comparator up to ensure a fair comparison is done on the `result`'s modulo.\n // For example, 51 / 103 == 0; 51 % 103 == 51; ((103 - 1) / 2) + 1 == 52; 51 < 52, therefore no round up\n return result.div(denominator).add(result.mod(denominator) >= denominator.sub(1).div(2).add(1) ? 1 : 0);\n }\n\n function to128(\n uint256 number\n )\n internal\n pure\n returns (uint128)\n {\n uint128 result = uint128(number);\n Require.that(\n result == number,\n FILE,\n \"Unsafe cast to uint128\",\n number\n );\n return result;\n }\n\n function to112(\n uint256 number\n )\n internal\n pure\n returns (uint112)\n {\n uint112 result = uint112(number);\n Require.that(\n result == number,\n FILE,\n \"Unsafe cast to uint112\",\n number\n );\n return result;\n }\n\n function to32(\n uint256 number\n )\n internal\n pure\n returns (uint32)\n {\n uint32 result = uint32(number);\n Require.that(\n result == number,\n FILE,\n \"Unsafe cast to uint32\",\n number\n );\n return result;\n }\n}\n",
"sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol",
"ast": {
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol",
"exportedSymbols": {
"DolomiteMarginMath": [
26238
]
},
"id": 26239,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 26025,
"literals": [
"solidity",
"^",
"0.5",
".7"
],
"nodeType": "PragmaDirective",
"src": "603:23:92"
},
{
"id": 26026,
"literals": [
"experimental",
"ABIEncoderV2"
],
"nodeType": "PragmaDirective",
"src": "627:33:92"
},
{
"absolutePath": "@openzeppelin/contracts/math/SafeMath.sol",
"file": "@openzeppelin/contracts/math/SafeMath.sol",
"id": 26028,
"nodeType": "ImportDirective",
"scope": 26239,
"sourceUnit": 37366,
"src": "662:69:92",
"symbolAliases": [
{
"foreign": 26027,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Require.sol",
"file": "./Require.sol",
"id": 26030,
"nodeType": "ImportDirective",
"scope": 26239,
"sourceUnit": 28453,
"src": "732:40:92",
"symbolAliases": [
{
"foreign": 26029,
"local": null
}
],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@title Math\n@author dYdX\n * Library for non-standard Math functions",
"fullyImplemented": true,
"id": 26238,
"linearizedBaseContracts": [
26238
],
"name": "DolomiteMarginMath",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 26033,
"libraryName": {
"contractScope": null,
"id": 26031,
"name": "SafeMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 37365,
"src": "899:8:92",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeMath_$37365",
"typeString": "library SafeMath"
}
},
"nodeType": "UsingForDirective",
"src": "893:27:92",
"typeName": {
"id": 26032,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "912:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"constant": true,
"id": 26036,
"name": "FILE",
"nodeType": "VariableDeclaration",
"scope": 26238,
"src": "970:38:92",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 26034,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "970:7:92",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": {
"argumentTypes": null,
"hexValue": "4d617468",
"id": 26035,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1002:6:92",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_19602d14acfdf1c8f04515d25ae0ffed7a19e56fe260950b488efb9ba564a438",
"typeString": "literal_string \"Math\""
},
"value": "Math"
},
"visibility": "private"
},
{
"body": {
"id": 26055,
"nodeType": "Block",
"src": "1298:62:92",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 26052,
"name": "denominator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26042,
"src": "1341:11:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 26049,
"name": "numerator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26040,
"src": "1326:9:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 26047,
"name": "target",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26038,
"src": "1315:6:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 26048,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "mul",
"nodeType": "MemberAccess",
"referencedDeclaration": 37282,
"src": "1315:10:92",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 26050,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1315:21:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 26051,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "div",
"nodeType": "MemberAccess",
"referencedDeclaration": 37298,
"src": "1315:25:92",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 26053,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1315:38:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"functionReturnParameters": 26046,
"id": 26054,
"nodeType": "Return",
"src": "1308:45:92"
}
]
},
"documentation": null,
"id": 26056,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getPartial",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 26043,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 26038,
"name": "target",
"nodeType": "VariableDeclaration",
"scope": 26056,
"src": "1161:14:92",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26037,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1161:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 26040,
"name": "numerator",
"nodeType": "VariableDeclaration",
"scope": 26056,
"src": "1185:17:92",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26039,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1185:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 26042,
"name": "denominator",
"nodeType": "VariableDeclaration",
"scope": 26056,
"src": "1212:19:92",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26041,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1212:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1151:86:92"
},
"returnParameters": {
"id": 26046,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 26045,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 26056,
"src": "1285:7:92",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26044,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1285:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1284:9:92"
},
"scope": 26238,
"src": "1132:228:92",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 26096,
"nodeType": "Block",
"src": "1689:236:92",
"statements": [
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"id": 26073,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 26069,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 26067,
"name": "target",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26058,
"src": "1703:6:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 26068,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1713:1:92",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "1703:11:92",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"nodeType": "BinaryOperation",
"operator": "||",
"rightExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 26072,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 26070,
"name": "numerator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26060,
"src": "1718:9:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 26071,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1731:1:92",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "1718:14:92",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"src": "1703:29:92",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 26081,
"nodeType": "IfStatement",
"src": "1699:151:92",
"trueBody": {
"id": 26080,
"nodeType": "Block",
"src": "1734:116:92",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "30",
"id": 26076,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1824:1:92",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
{
"argumentTypes": null,
"id": 26077,
"name": "denominator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26062,
"src": "1827:11:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 26074,
"name": "SafeMath",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 37365,
"src": "1811:8:92",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_SafeMath_$37365_$",
"typeString": "type(library SafeMath)"
}
},
"id": 26075,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "div",
"nodeType": "MemberAccess",
"referencedDeclaration": 37298,
"src": "1811:12:92",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 26078,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1811:28:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"functionReturnParameters": 26066,
"id": 26079,
"nodeType": "Return",
"src": "1804:35:92"
}
]
}
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "31",
"id": 26093,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1916:1:92",
"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"
}
],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 26090,
"name": "denominator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26062,
"src": "1899:11:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "31",
"id": 26087,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1892:1:92",
"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"
}
],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 26084,
"name": "numerator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26060,
"src": "1877:9:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 26082,
"name": "target",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26058,
"src": "1866:6:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 26083,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "mul",
"nodeType": "MemberAccess",
"referencedDeclaration": 37282,
"src": "1866:10:92",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 26085,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1866:21:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 26086,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "sub",
"nodeType": "MemberAccess",
"referencedDeclaration": 37221,
"src": "1866:25:92",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 26088,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1866:28:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 26089,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "div",
"nodeType": "MemberAccess",
"referencedDeclaration": 37298,
"src": "1866:32:92",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 26091,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1866:45:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 26092,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "add",
"nodeType": "MemberAccess",
"referencedDeclaration": 37205,
"src": "1866:49:92",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 26094,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1866:52:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"functionReturnParameters": 26066,
"id": 26095,
"nodeType": "Return",
"src": "1859:59:92"
}
]
},
"documentation": null,
"id": 26097,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getPartialRoundUp",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 26063,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 26058,
"name": "target",
"nodeType": "VariableDeclaration",
"scope": 26097,
"src": "1552:14:92",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26057,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1552:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 26060,
"name": "numerator",
"nodeType": "VariableDeclaration",
"scope": 26097,
"src": "1576:17:92",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26059,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1576:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 26062,
"name": "denominator",
"nodeType": "VariableDeclaration",
"scope": 26097,
"src": "1603:19:92",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26061,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1603:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1542:86:92"
},
"returnParameters": {
"id": 26066,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 26065,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 26097,
"src": "1676:7:92",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26064,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1676:7:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1675:9:92"
},
"scope": 26238,
"src": "1516:409:92",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 26155,
"nodeType": "Block",
"src": "2258:547:92",
"statements": [
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"id": 26114,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 26110,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 26108,
"name": "target",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26099,
"src": "2272:6:92",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 26109,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "2282:1:92",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "2272:11:92",
"typeDescriptions": {
"typeIdentifier": "t_bool",