UNPKG

@dolomite-exchange/dolomite-margin

Version:

Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol

1,075 lines (1,074 loc) 570 kB
{ "contractName": "Types", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"author\":\"dYdX * Library for interacting with the basic structs used in DolomiteMargin\",\"methods\":{},\"title\":\"Types\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol\":\"Types\"},\"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\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol\":{\"keccak256\":\"0xe1bab8c8799d83e86c7a49aaf815d8e3bc8d09562d46d44d921500db5e98de0e\",\"urls\":[\"bzz-raw://8ea3d0cc4fdab6dd9bba545a792170f939b342d8d1a7051c1c6365009af72658\",\"dweb:/ipfs/QmaLJgbavu88eEit6JPqfWnw6NmGBDZfveMXxumgWywBFG\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]}},\"version\":1}", "bytecode": "0x60636023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a723158203db67d29faf7991f9d319e771529f42c6ef1e9a34c0dd7700db085af5208633f6c6578706572696d656e74616cf564736f6c63430005100040", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a723158203db67d29faf7991f9d319e771529f42c6ef1e9a34c0dd7700db085af5208633f6c6578706572696d656e74616cf564736f6c63430005100040", "sourceMap": "913:5532:104:-;;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": "913:5532:104:-;;;;;;;;", "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 { DolomiteMarginMath } from \"./DolomiteMarginMath.sol\";\n\n\n/**\n * @title Types\n * @author dYdX\n *\n * Library for interacting with the basic structs used in DolomiteMargin\n */\nlibrary Types {\n using DolomiteMarginMath for uint256;\n\n // ============ Permission ============\n\n struct OperatorArg {\n address operator;\n bool trusted;\n }\n\n // ============ AssetAmount ============\n\n enum AssetDenomination {\n Wei, // the amount is denominated in wei\n Par // the amount is denominated in par\n }\n\n enum AssetReference {\n Delta, // the amount is given as a delta from the current value\n Target // the amount is given as an exact number to end up at\n }\n\n struct AssetAmount {\n bool sign; // true if positive\n AssetDenomination denomination;\n AssetReference ref;\n uint256 value;\n }\n\n // ============ Par (Principal Amount) ============\n\n // Total borrow and supply values for a market\n struct TotalPar {\n uint128 borrow;\n uint128 supply;\n }\n\n // Individual principal amount for an account\n struct Par {\n bool sign; // true if positive\n uint128 value;\n }\n\n function zeroPar()\n internal\n pure\n returns (Par memory)\n {\n return Par({\n sign: false,\n value: 0\n });\n }\n\n function sub(\n Par memory a,\n Par memory b\n )\n internal\n pure\n returns (Par memory)\n {\n return add(a, negative(b));\n }\n\n function add(\n Par memory a,\n Par memory b\n )\n internal\n pure\n returns (Par memory)\n {\n Par memory result;\n if (a.sign == b.sign) {\n result.sign = a.sign;\n result.value = SafeMath.add(a.value, b.value).to128();\n } else {\n if (a.value >= b.value) {\n result.sign = a.sign;\n result.value = SafeMath.sub(a.value, b.value).to128();\n } else {\n result.sign = b.sign;\n result.value = SafeMath.sub(b.value, a.value).to128();\n }\n }\n return result;\n }\n\n function equals(\n Par memory a,\n Par memory b\n )\n internal\n pure\n returns (bool)\n {\n if (a.value == b.value) {\n if (a.value == 0) {\n return true;\n }\n return a.sign == b.sign;\n }\n return false;\n }\n\n function negative(\n Par memory a\n )\n internal\n pure\n returns (Par memory)\n {\n return Par({\n sign: !a.sign,\n value: a.value\n });\n }\n\n function isNegative(\n Par memory a\n )\n internal\n pure\n returns (bool)\n {\n return !a.sign && a.value != 0;\n }\n\n function isPositive(\n Par memory a\n )\n internal\n pure\n returns (bool)\n {\n return a.sign && a.value != 0;\n }\n\n function isZero(\n Par memory a\n )\n internal\n pure\n returns (bool)\n {\n return a.value == 0;\n }\n\n function isLessThanZero(\n Par memory a\n )\n internal\n pure\n returns (bool)\n {\n return a.value != 0 && !a.sign;\n }\n\n function isGreaterThanOrEqualToZero(\n Par memory a\n )\n internal\n pure\n returns (bool)\n {\n return isZero(a) || a.sign;\n }\n\n // ============ Wei (Token Amount) ============\n\n struct TotalWei {\n uint128 borrow;\n uint128 supply;\n }\n\n // Individual token amount for an account\n struct Wei {\n bool sign; // true if positive\n uint256 value;\n }\n\n function zeroWei()\n internal\n pure\n returns (Wei memory)\n {\n return Wei({\n sign: false,\n value: 0\n });\n }\n\n function sub(\n Wei memory a,\n Wei memory b\n )\n internal\n pure\n returns (Wei memory)\n {\n return add(a, negative(b));\n }\n\n function add(\n Wei memory a,\n Wei memory b\n )\n internal\n pure\n returns (Wei memory)\n {\n Wei memory result;\n if (a.sign == b.sign) {\n result.sign = a.sign;\n result.value = SafeMath.add(a.value, b.value);\n } else {\n if (a.value >= b.value) {\n result.sign = a.sign;\n result.value = SafeMath.sub(a.value, b.value);\n } else {\n result.sign = b.sign;\n result.value = SafeMath.sub(b.value, a.value);\n }\n }\n return result;\n }\n\n function equals(\n Wei memory a,\n Wei memory b\n )\n internal\n pure\n returns (bool)\n {\n if (a.value == b.value) {\n if (a.value == 0) {\n return true;\n }\n return a.sign == b.sign;\n }\n return false;\n }\n\n function negative(\n Wei memory a\n )\n internal\n pure\n returns (Wei memory)\n {\n return Wei({\n sign: !a.sign,\n value: a.value\n });\n }\n\n function isNegative(\n Wei memory a\n )\n internal\n pure\n returns (bool)\n {\n return !a.sign && a.value != 0;\n }\n\n function isPositive(\n Wei memory a\n )\n internal\n pure\n returns (bool)\n {\n return a.sign && a.value != 0;\n }\n\n function isZero(\n Wei memory a\n )\n internal\n pure\n returns (bool)\n {\n return a.value == 0;\n }\n}\n", "sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol", "ast": { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol", "exportedSymbols": { "Types": [ 31361 ] }, "id": 31362, "nodeType": "SourceUnit", "nodes": [ { "id": 30852, "literals": [ "solidity", "^", "0.5", ".7" ], "nodeType": "PragmaDirective", "src": "603:23:104" }, { "id": 30853, "literals": [ "experimental", "ABIEncoderV2" ], "nodeType": "PragmaDirective", "src": "627:33:104" }, { "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "id": 30855, "nodeType": "ImportDirective", "scope": 31362, "sourceUnit": 37366, "src": "662:69:104", "symbolAliases": [ { "foreign": 30854, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol", "file": "./DolomiteMarginMath.sol", "id": 30857, "nodeType": "ImportDirective", "scope": 31362, "sourceUnit": 26239, "src": "732:62:104", "symbolAliases": [ { "foreign": 30856, "local": null } ], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": "@title Types\n@author dYdX\n * Library for interacting with the basic structs used in DolomiteMargin", "fullyImplemented": true, "id": 31361, "linearizedBaseContracts": [ 31361 ], "name": "Types", "nodeType": "ContractDefinition", "nodes": [ { "id": 30860, "libraryName": { "contractScope": null, "id": 30858, "name": "DolomiteMarginMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 26238, "src": "939:18:104", "typeDescriptions": { "typeIdentifier": "t_contract$_DolomiteMarginMath_$26238", "typeString": "library DolomiteMarginMath" } }, "nodeType": "UsingForDirective", "src": "933:37:104", "typeName": { "id": 30859, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "962:7:104", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "canonicalName": "Types.OperatorArg", "id": 30865, "members": [ { "constant": false, "id": 30862, "name": "operator", "nodeType": "VariableDeclaration", "scope": 30865, "src": "1050:16:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 30861, "name": "address", "nodeType": "ElementaryTypeName", "src": "1050:7:104", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 30864, "name": "trusted", "nodeType": "VariableDeclaration", "scope": 30865, "src": "1076:12:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 30863, "name": "bool", "nodeType": "ElementaryTypeName", "src": "1076:4:104", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "value": null, "visibility": "internal" } ], "name": "OperatorArg", "nodeType": "StructDefinition", "scope": 31361, "src": "1021:74:104", "visibility": "public" }, { "canonicalName": "Types.AssetDenomination", "id": 30868, "members": [ { "id": 30866, "name": "Wei", "nodeType": "EnumValue", "src": "1180:3:104" }, { "id": 30867, "name": "Par", "nodeType": "EnumValue", "src": "1229:3:104" } ], "name": "AssetDenomination", "nodeType": "EnumDefinition", "src": "1147:128:104" }, { "canonicalName": "Types.AssetReference", "id": 30871, "members": [ { "id": 30869, "name": "Delta", "nodeType": "EnumValue", "src": "1311:5:104" }, { "id": 30870, "name": "Target", "nodeType": "EnumValue", "src": "1383:6:104" } ], "name": "AssetReference", "nodeType": "EnumDefinition", "src": "1281:169:104" }, { "canonicalName": "Types.AssetAmount", "id": 30880, "members": [ { "constant": false, "id": 30873, "name": "sign", "nodeType": "VariableDeclaration", "scope": 30880, "src": "1485:9:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 30872, "name": "bool", "nodeType": "ElementaryTypeName", "src": "1485:4:104", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 30875, "name": "denomination", "nodeType": "VariableDeclaration", "scope": 30880, "src": "1524:30:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_enum$_AssetDenomination_$30868", "typeString": "enum Types.AssetDenomination" }, "typeName": { "contractScope": null, "id": 30874, "name": "AssetDenomination", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 30868, "src": "1524:17:104", "typeDescriptions": { "typeIdentifier": "t_enum$_AssetDenomination_$30868", "typeString": "enum Types.AssetDenomination" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 30877, "name": "ref", "nodeType": "VariableDeclaration", "scope": 30880, "src": "1564:18:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_enum$_AssetReference_$30871", "typeString": "enum Types.AssetReference" }, "typeName": { "contractScope": null, "id": 30876, "name": "AssetReference", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 30871, "src": "1564:14:104", "typeDescriptions": { "typeIdentifier": "t_enum$_AssetReference_$30871", "typeString": "enum Types.AssetReference" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 30879, "name": "value", "nodeType": "VariableDeclaration", "scope": 30880, "src": "1592:13:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 30878, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1592:7:104", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "name": "AssetAmount", "nodeType": "StructDefinition", "scope": 31361, "src": "1456:156:104", "visibility": "public" }, { "canonicalName": "Types.TotalPar", "id": 30885, "members": [ { "constant": false, "id": 30882, "name": "borrow", "nodeType": "VariableDeclaration", "scope": 30885, "src": "1752:14:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "typeName": { "id": 30881, "name": "uint128", "nodeType": "ElementaryTypeName", "src": "1752:7:104", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 30884, "name": "supply", "nodeType": "VariableDeclaration", "scope": 30885, "src": "1776:14:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "typeName": { "id": 30883, "name": "uint128", "nodeType": "ElementaryTypeName", "src": "1776:7:104", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "value": null, "visibility": "internal" } ], "name": "TotalPar", "nodeType": "StructDefinition", "scope": 31361, "src": "1726:71:104", "visibility": "public" }, { "canonicalName": "Types.Par", "id": 30890, "members": [ { "constant": false, "id": 30887, "name": "sign", "nodeType": "VariableDeclaration", "scope": 30890, "src": "1874:9:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 30886, "name": "bool", "nodeType": "ElementaryTypeName", "src": "1874:4:104", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 30889, "name": "value", "nodeType": "VariableDeclaration", "scope": 30890, "src": "1913:13:104", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "typeName": { "id": 30888, "name": "uint128", "nodeType": "ElementaryTypeName", "src": "1913:7:104", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "value": null, "visibility": "internal" } ], "name": "Par", "nodeType": "StructDefinition", "scope": 31361, "src": "1853:80:104", "visibility": "public" }, { "body": { "id": 30900, "nodeType": "Block", "src": "2021:86:104", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "66616c7365", "id": 30896, "isConstant": false, "isLValue": false, "isPure": true, "kind": "bool", "lValueRequested": false, "nodeType": "Literal", "src": "2062:5:104", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "value": "false" }, { "argumentTypes": null, "hexValue": "30", "id": 30897, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "2088:1:104", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 30895, "name": "Par", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30890, "src": "2038:3:104", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_Par_$30890_storage_ptr_$", "typeString": "type(struct Types.Par storage pointer)" } }, "id": 30898, "isConstant": false, "isLValue": false, "isPure": true, "kind": "structConstructorCall", "lValueRequested": false, "names": [ "sign", "value" ], "nodeType": "FunctionCall", "src": "2038:62:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory", "typeString": "struct Types.Par memory" } }, "functionReturnParameters": 30894, "id": 30899, "nodeType": "Return", "src": "2031:69:104" } ] }, "documentation": null, "id": 30901, "implemented": true, "kind": "function", "modifiers": [], "name": "zeroPar", "nodeType": "FunctionDefinition", "parameters": { "id": 30891, "nodeType": "ParameterList", "parameters": [], "src": "1955:2:104" }, "returnParameters": { "id": 30894, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 30893, "name": "", "nodeType": "VariableDeclaration", "scope": 30901, "src": "2005:10:104", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par" }, "typeName": { "contractScope": null, "id": 30892, "name": "Par", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 30890, "src": "2005:3:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_storage_ptr", "typeString": "struct Types.Par" } }, "value": null, "visibility": "internal" } ], "src": "2004:12:104" }, "scope": 31361, "src": "1939:168:104", "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, { "body": { "id": 30917, "nodeType": "Block", "src": "2239:43:104", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 30911, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30903, "src": "2260:1:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } }, { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 30913, "name": "b", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30905, "src": "2272:1:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } ], "id": 30912, "name": "negative", "nodeType": "Identifier", "overloadedDeclarations": [ 31061, 31314 ], "referencedDeclaration": 31061, "src": "2263:8:104", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_struct$_Par_$30890_memory_ptr_$returns$_t_struct$_Par_$30890_memory_ptr_$", "typeString": "function (struct Types.Par memory) pure returns (struct Types.Par memory)" } }, "id": 30914, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "2263:11:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" }, { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } ], "id": 30910, "name": "add", "nodeType": "Identifier", "overloadedDeclarations": [ 31012, 31265 ], "referencedDeclaration": 31012, "src": "2256:3:104", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_struct$_Par_$30890_memory_ptr_$_t_struct$_Par_$30890_memory_ptr_$returns$_t_struct$_Par_$30890_memory_ptr_$", "typeString": "function (struct Types.Par memory,struct Types.Par memory) pure returns (struct Types.Par memory)" } }, "id": 30915, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "2256:19:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } }, "functionReturnParameters": 30909, "id": 30916, "nodeType": "Return", "src": "2249:26:104" } ] }, "documentation": null, "id": 30918, "implemented": true, "kind": "function", "modifiers": [], "name": "sub", "nodeType": "FunctionDefinition", "parameters": { "id": 30906, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 30903, "name": "a", "nodeType": "VariableDeclaration", "scope": 30918, "src": "2135:12:104", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par" }, "typeName": { "contractScope": null, "id": 30902, "name": "Par", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 30890, "src": "2135:3:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_storage_ptr", "typeString": "struct Types.Par" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 30905, "name": "b", "nodeType": "VariableDeclaration", "scope": 30918, "src": "2157:12:104", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par" }, "typeName": { "contractScope": null, "id": 30904, "name": "Par", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 30890, "src": "2157:3:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_storage_ptr", "typeString": "struct Types.Par" } }, "value": null, "visibility": "internal" } ], "src": "2125:50:104" }, "returnParameters": { "id": 30909, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 30908, "name": "", "nodeType": "VariableDeclaration", "scope": 30918, "src": "2223:10:104", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par" }, "typeName": { "contractScope": null, "id": 30907, "name": "Par", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 30890, "src": "2223:3:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_storage_ptr", "typeString": "struct Types.Par" } }, "value": null, "visibility": "internal" } ], "src": "2222:12:104" }, "scope": 31361, "src": "2113:169:104", "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, { "body": { "id": 31011, "nodeType": "Block", "src": "2414:508:104", "statements": [ { "assignments": [ 30928 ], "declarations": [ { "constant": false, "id": 30928, "name": "result", "nodeType": "VariableDeclaration", "scope": 31011, "src": "2424:17:104", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par" }, "typeName": { "contractScope": null, "id": 30927, "name": "Par", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 30890, "src": "2424:3:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_storage_ptr", "typeString": "struct Types.Par" } }, "value": null, "visibility": "internal" } ], "id": 30929, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "2424:17:104" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_bool", "typeString": "bool" }, "id": 30934, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 30930, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30920, "src": "2455:1:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } }, "id": 30931, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "sign", "nodeType": "MemberAccess", "referencedDeclaration": 30887, "src": "2455:6:104", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 30932, "name": "b", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30922, "src": "2465:1:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } }, "id": 30933, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "sign", "nodeType": "MemberAccess", "referencedDeclaration": 30887, "src": "2465:6:104", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "src": "2455:16:104", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": { "id": 31007, "nodeType": "Block", "src": "2591:302:104", "statements": [ { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "id": 30961, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 30957, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30920, "src": "2609:1:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } }, "id": 30958, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": 30889, "src": "2609:7:104", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "nodeType": "BinaryOperation", "operator": ">=", "rightExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 30959, "name": "b", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30922, "src": "2620:1:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr", "typeString": "struct Types.Par memory" } }, "id": 30960, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": 30889, "src": "2620:7:104", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "src": "2609:18:104", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": { "id": 31005, "nodeType": "Block", "src": "2759:124:104", "statements": [ { "expression": { "argumentTypes": null, "id": 30989, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 30984, "name": "result", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30928, "src": "2777:6:104", "typeDescriptions": { "typeIdentifier": "t_struct$_Par_$30890_memory_ptr",