UNPKG

hardlydifficult-ethereum-contracts

Version:
1,044 lines (1,043 loc) 594 kB
{ "contractName": "BigDiv", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.5.17+commit.d19bba13\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Results may be off by 1 + 0.000001% for 2x1 calls and 2 + 0.00001% for 2x2 calls. Do not use if your contract expects very small result values to be accurate.\",\"methods\":{},\"title\":\"Reduces the size of terms before multiplication, to avoid an overflow, and then restores the proper size after division.\"},\"userdoc\":{\"methods\":{},\"notice\":\"This effectively allows us to overflow values in the numerator and/or denominator of a fraction, so long as the end result does not overflow as well.\"}},\"settings\":{\"compilationTarget\":{\"/home/circleci/repo/contracts/math/BigDiv.sol\":\"BigDiv\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":2000000},\"remappings\":[]},\"sources\":{\"/home/circleci/repo/contracts/math/BigDiv.sol\":{\"keccak256\":\"0xa5de5987f3c16748ca0e15511c3cd7539345ac13b3e3d7f6a12a38821fd99ade\",\"urls\":[\"bzz-raw://03ea66de02cc69e51688be492329ed542d5a11bc6c7cf62c0b979efa18e834de\",\"dweb:/ipfs/QmbAq2gGsCd4GJDfQRQG9LbQiT756WPk9wvLPaYqLbMvRv\"]},\"@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]}},\"version\":1}", "bytecode": "0x60556023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723158205b9f6945f5bf877b74de95eef6118eeb243114764663c2349bbe1383e0e9388d64736f6c63430005110032", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723158205b9f6945f5bf877b74de95eef6118eeb243114764663c2349bbe1383e0e9388d64736f6c63430005110032", "sourceMap": "582:6284:4:-;;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": "582:6284:4:-;;;;;;;;", "source": "pragma solidity ^0.5.0;\n\n\nimport '@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol';\n\n/**\n * @title Reduces the size of terms before multiplication, to avoid an overflow, and then\n * restores the proper size after division.\n * @notice This effectively allows us to overflow values in the numerator and/or denominator\n * of a fraction, so long as the end result does not overflow as well.\n * @dev Results may be off by 1 + 0.000001% for 2x1 calls and 2 + 0.00001% for 2x2 calls.\n * Do not use if your contract expects very small result values to be accurate.\n */\nlibrary BigDiv\n{\n using SafeMath for uint256;\n\n /// @notice The max possible value\n uint256 private constant MAX_UINT = 2**256 - 1;\n\n /// @notice When multiplying 2 terms <= this value the result won't overflow\n uint256 private constant MAX_BEFORE_SQUARE = 2**128 - 1;\n\n /// @notice The max error target is off by 1 plus up to 0.000001% error\n /// for bigDiv2x1 and that `* 2` for bigDiv2x2\n uint256 private constant MAX_ERROR = 100000000;\n\n /// @notice A larger error threshold to use when multiple rounding errors may apply\n uint256 private constant MAX_ERROR_BEFORE_DIV = MAX_ERROR * 2;\n\n /**\n * @notice Returns the approx result of `a * b / d` so long as the result is <= MAX_UINT\n * @param _numA the first numerator term\n * @param _numB the second numerator term\n * @param _den the denominator\n * @return the approx result with up to off by 1 + MAX_ERROR, rounding down if needed\n */\n function bigDiv2x1(\n uint256 _numA,\n uint256 _numB,\n uint256 _den\n ) internal pure\n returns(uint256)\n {\n if(_numA == 0 || _numB == 0)\n {\n // would div by 0 or underflow if we don't special case 0\n return 0;\n }\n\n uint256 value;\n\n if(MAX_UINT / _numA >= _numB)\n {\n // a*b does not overflow, return exact math\n value = _numA * _numB;\n value /= _den;\n return value;\n }\n\n // Sort numerators\n uint256 numMax = _numB;\n uint256 numMin = _numA;\n if(_numA > _numB)\n {\n numMax = _numA;\n numMin = _numB;\n }\n\n value = numMax / _den;\n if(value > MAX_ERROR)\n {\n // _den is small enough to be MAX_ERROR or better w/o a factor\n value = value.mul(numMin);\n return value;\n }\n\n // formula = ((a / f) * b) / (d / f)\n // factor >= a / sqrt(MAX) * (b / sqrt(MAX))\n uint256 factor = numMin - 1;\n factor /= MAX_BEFORE_SQUARE;\n factor += 1;\n uint256 temp = numMax - 1;\n temp /= MAX_BEFORE_SQUARE;\n temp += 1;\n if(MAX_UINT / factor >= temp)\n {\n factor *= temp;\n value = numMax / factor;\n if(value > MAX_ERROR_BEFORE_DIV)\n {\n value = value.mul(numMin);\n temp = _den - 1;\n temp /= factor;\n temp = temp.add(1);\n value /= temp;\n return value;\n }\n }\n\n // formula: (a / (d / f)) * (b / f)\n // factor: b / sqrt(MAX)\n factor = numMin - 1;\n factor /= MAX_BEFORE_SQUARE;\n factor += 1;\n value = numMin / factor;\n temp = _den - 1;\n temp /= factor;\n temp += 1;\n temp = numMax / temp;\n value = value.mul(temp);\n return value;\n }\n\n /**\n * @notice Returns the approx result of `a * b / d` so long as the result is <= MAX_UINT\n * @param _numA the first numerator term\n * @param _numB the second numerator term\n * @param _den the denominator\n * @return the approx result with up to off by 1 + MAX_ERROR, rounding down if needed\n * @dev roundUp is implemented by first rounding down and then adding the max error to the result\n */\n function bigDiv2x1RoundUp(\n uint256 _numA,\n uint256 _numB,\n uint256 _den\n ) internal pure\n returns(uint256)\n {\n // first get the rounded down result\n uint256 value = bigDiv2x1(_numA, _numB, _den);\n\n if(value == 0)\n {\n // when the value rounds down to 0, assume up to an off by 1 error\n return 1;\n }\n\n // round down has a max error of MAX_ERROR, add that to the result\n // for a round up error of <= MAX_ERROR\n uint256 temp = value - 1;\n temp /= MAX_ERROR;\n temp += 1;\n if(MAX_UINT - value < temp)\n {\n // value + error would overflow, return MAX\n return MAX_UINT;\n }\n\n value += temp;\n\n return value;\n }\n\n /**\n * @notice Returns the approx result of `a * b / (c * d)` so long as the result is <= MAX_UINT\n * @param _numA the first numerator term\n * @param _numB the second numerator term\n * @param _denA the first denominator term\n * @param _denB the second denominator term\n * @return the approx result with up to off by 2 + MAX_ERROR*10 error, rounding down if needed\n * @dev this uses bigDiv2x1 and adds additional rounding error so the max error of this\n * formula is larger\n */\n function bigDiv2x2(\n uint256 _numA,\n uint256 _numB,\n uint256 _denA,\n uint256 _denB\n ) internal pure\n returns (uint256)\n {\n if(MAX_UINT / _denA >= _denB)\n {\n // denA*denB does not overflow, use bigDiv2x1 instead\n return bigDiv2x1(_numA, _numB, _denA * _denB);\n }\n\n if(_numA == 0 || _numB == 0)\n {\n // would div by 0 or underflow if we don't special case 0\n return 0;\n }\n\n // Sort denominators\n uint256 denMax = _denB;\n uint256 denMin = _denA;\n if(_denA > _denB)\n {\n denMax = _denA;\n denMin = _denB;\n }\n\n uint256 value;\n\n if(MAX_UINT / _numA >= _numB)\n {\n // a*b does not overflow, use `a / d / c`\n value = _numA * _numB;\n value /= denMin;\n value /= denMax;\n return value;\n }\n\n // `ab / cd` where both `ab` and `cd` would overflow\n\n // Sort numerators\n uint256 numMax = _numB;\n uint256 numMin = _numA;\n if(_numA > _numB)\n {\n numMax = _numA;\n numMin = _numB;\n }\n\n // formula = (a/d) * b / c\n uint256 temp = numMax / denMin;\n if(temp > MAX_ERROR_BEFORE_DIV)\n {\n return bigDiv2x1(temp, numMin, denMax);\n }\n\n // formula: ((a/f) * b) / d then either * f / c or / c * f\n // factor >= a / sqrt(MAX) * (b / sqrt(MAX))\n uint256 factor = numMin - 1;\n factor /= MAX_BEFORE_SQUARE;\n factor += 1;\n temp = numMax - 1;\n temp /= MAX_BEFORE_SQUARE;\n temp += 1;\n if(MAX_UINT / factor >= temp)\n {\n factor *= temp;\n\n value = numMax / factor;\n if(value > MAX_ERROR_BEFORE_DIV)\n {\n value = value.mul(numMin);\n value /= denMin;\n if(value > 0 && MAX_UINT / value >= factor)\n {\n value *= factor;\n value /= denMax;\n return value;\n }\n }\n }\n\n // formula: (a/f) * b / ((c*d)/f)\n // factor >= c / sqrt(MAX) * (d / sqrt(MAX))\n factor = denMin;\n factor /= MAX_BEFORE_SQUARE;\n temp = denMax;\n // + 1 here prevents overflow of factor*temp\n temp /= MAX_BEFORE_SQUARE + 1;\n factor *= temp;\n return bigDiv2x1(numMax / factor, numMin, MAX_UINT);\n }\n}", "sourcePath": "/home/circleci/repo/contracts/math/BigDiv.sol", "ast": { "absolutePath": "/home/circleci/repo/contracts/math/BigDiv.sol", "exportedSymbols": { "BigDiv": [ 1155 ] }, "id": 1156, "nodeType": "SourceUnit", "nodes": [ { "id": 620, "literals": [ "solidity", "^", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:4" }, { "absolutePath": "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol", "id": 621, "nodeType": "ImportDirective", "scope": 1156, "sourceUnit": 2111, "src": "26:78:4", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": "@title Reduces the size of terms before multiplication, to avoid an overflow, and then\nrestores the proper size after division.\n@notice This effectively allows us to overflow values in the numerator and/or denominator\nof a fraction, so long as the end result does not overflow as well.\n@dev Results may be off by 1 + 0.000001% for 2x1 calls and 2 + 0.00001% for 2x2 calls.\nDo not use if your contract expects very small result values to be accurate.", "fullyImplemented": true, "id": 1155, "linearizedBaseContracts": [ 1155 ], "name": "BigDiv", "nodeType": "ContractDefinition", "nodes": [ { "id": 624, "libraryName": { "contractScope": null, "id": 622, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 2110, "src": "607:8:4", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$2110", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "601:27:4", "typeName": { "id": 623, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "620:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "constant": true, "id": 631, "name": "MAX_UINT", "nodeType": "VariableDeclaration", "scope": 1155, "src": "669:46:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 625, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "669:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639935_by_1", "typeString": "int_const 1157...(70 digits omitted)...9935" }, "id": 630, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639936_by_1", "typeString": "int_const 1157...(70 digits omitted)...9936" }, "id": 628, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "hexValue": "32", "id": 626, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "705:1:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, "value": "2" }, "nodeType": "BinaryOperation", "operator": "**", "rightExpression": { "argumentTypes": null, "hexValue": "323536", "id": 627, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "708:3:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_256_by_1", "typeString": "int_const 256" }, "value": "256" }, "src": "705:6:4", "typeDescriptions": { "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639936_by_1", "typeString": "int_const 1157...(70 digits omitted)...9936" } }, "nodeType": "BinaryOperation", "operator": "-", "rightExpression": { "argumentTypes": null, "hexValue": "31", "id": 629, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "714:1:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "1" }, "src": "705:10:4", "typeDescriptions": { "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639935_by_1", "typeString": "int_const 1157...(70 digits omitted)...9935" } }, "visibility": "private" }, { "constant": true, "id": 638, "name": "MAX_BEFORE_SQUARE", "nodeType": "VariableDeclaration", "scope": 1155, "src": "799:55:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 632, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "799:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_340282366920938463463374607431768211455_by_1", "typeString": "int_const 3402...(31 digits omitted)...1455" }, "id": 637, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_340282366920938463463374607431768211456_by_1", "typeString": "int_const 3402...(31 digits omitted)...1456" }, "id": 635, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "hexValue": "32", "id": 633, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "844:1:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, "value": "2" }, "nodeType": "BinaryOperation", "operator": "**", "rightExpression": { "argumentTypes": null, "hexValue": "313238", "id": 634, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "847:3:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_128_by_1", "typeString": "int_const 128" }, "value": "128" }, "src": "844:6:4", "typeDescriptions": { "typeIdentifier": "t_rational_340282366920938463463374607431768211456_by_1", "typeString": "int_const 3402...(31 digits omitted)...1456" } }, "nodeType": "BinaryOperation", "operator": "-", "rightExpression": { "argumentTypes": null, "hexValue": "31", "id": 636, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "853:1:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "1" }, "src": "844:10:4", "typeDescriptions": { "typeIdentifier": "t_rational_340282366920938463463374607431768211455_by_1", "typeString": "int_const 3402...(31 digits omitted)...1455" } }, "visibility": "private" }, { "constant": true, "id": 641, "name": "MAX_ERROR", "nodeType": "VariableDeclaration", "scope": 1155, "src": "982:46:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 639, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "982:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "313030303030303030", "id": 640, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1019:9:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_100000000_by_1", "typeString": "int_const 100000000" }, "value": "100000000" }, "visibility": "private" }, { "constant": true, "id": 646, "name": "MAX_ERROR_BEFORE_DIV", "nodeType": "VariableDeclaration", "scope": 1155, "src": "1119:61:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 642, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1119:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 645, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 643, "name": "MAX_ERROR", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 641, "src": "1167:9:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "hexValue": "32", "id": 644, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1179:1:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, "value": "2" }, "src": "1167:13:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "private" }, { "body": { "id": 860, "nodeType": "Block", "src": "1612:1528:4", "statements": [ { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_bool", "typeString": "bool" }, "id": 663, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 659, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 657, "name": "_numA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 648, "src": "1621:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 658, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1630:1:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1621:10:4", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "nodeType": "BinaryOperation", "operator": "||", "rightExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 662, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 660, "name": "_numB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 650, "src": "1635:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 661, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1644:1:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1635:10:4", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "src": "1621:24:4", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 667, "nodeType": "IfStatement", "src": "1618:120:4", "trueBody": { "id": 666, "nodeType": "Block", "src": "1651:87:4", "statements": [ { "expression": { "argumentTypes": null, "hexValue": "30", "id": 664, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1730:1:4", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "functionReturnParameters": 656, "id": 665, "nodeType": "Return", "src": "1723:8:4" } ] } }, { "assignments": [ 669 ], "declarations": [ { "constant": false, "id": 669, "name": "value", "nodeType": "VariableDeclaration", "scope": 860, "src": "1744:13:4", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 668, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1744:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 670, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "1744:13:4" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 675, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 673, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 671, "name": "MAX_UINT", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 631, "src": "1767:8:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "/", "rightExpression": { "argumentTypes": null, "id": 672, "name": "_numA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 648, "src": "1778:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1767:16:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">=", "rightExpression": { "argumentTypes": null, "id": 674, "name": "_numB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 650, "src": "1787:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1767:25:4", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 689, "nodeType": "IfStatement", "src": "1764:161:4", "trueBody": { "id": 688, "nodeType": "Block", "src": "1798:127:4", "statements": [ { "expression": { "argumentTypes": null, "id": 680, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 676, "name": "value", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 669, "src": "1856:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 679, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 677, "name": "_numA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 648, "src": "1864:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "id": 678, "name": "_numB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 650, "src": "1872:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1864:13:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1856:21:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 681, "nodeType": "ExpressionStatement", "src": "1856:21:4" }, { "expression": { "argumentTypes": null, "id": 684, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 682, "name": "value", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 669, "src": "1885:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "/=", "rightHandSide": { "argumentTypes": null, "id": 683, "name": "_den", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 652, "src": "1894:4:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1885:13:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 685, "nodeType": "ExpressionStatement", "src": "1885:13:4" }, { "expression": { "argumentTypes": null, "id": 686, "name": "value", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 669, "src": "1913:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "functionReturnParameters": 656, "id": 687, "nodeType": "Return", "src": "1906:12:4" } ] } }, { "assignments": [ 691 ], "declarations": [ { "constant": false, "id": 691, "name": "numMax", "nodeType": "VariableDeclaration", "scope": 860, "src": "1954:14:4", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 690, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1954:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 693, "initialValue": { "argumentTypes": null, "id": 692, "name": "_numB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 650, "src": "1971:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "1954:22:4" }, { "assignments": [ 695 ], "declarations": [ { "constant": false, "id": 695, "name": "numMin", "nodeType": "VariableDeclaration", "scope": 860, "src": "1982:14:4", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 694, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1982:7:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 697, "initialValue": { "argumentTypes": null, "id": 696, "name": "_numA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 648, "src": "1999:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "1982:22:4" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 700, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 698, "name": "_numA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 648, "src": "2013:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">", "rightExpression": { "argumentTypes": null, "id": 699, "name": "_numB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 650, "src": "2021:5:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "2013:13:4", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 710, "nodeType": "IfStatement", "src": "2010:73:4", "trueBody": { "id": 709, "nodeType": "Block", "src": "2032:51:4", "statements": [ { "expression": { "argumentTypes": null, "id": 703, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 701, "name": "numMax", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 691, "src": "2040:6:4", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": {