@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
1,231 lines • 92.4 kB
JSON
{
"contractName": "Decimal",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"author\":\"dYdX * Library that defines a fixed-point number with 18 decimal places.\",\"methods\":{},\"title\":\"Decimal\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol\":\"Decimal\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol\":{\"keccak256\":\"0xd9a348c2b1eec076609ba12bbec6b9c2e4ea135790a7ef4f5411feb050af2144\",\"urls\":[\"bzz-raw://d5bcff29e47d5cd02d7a9966e9f44c46ccbb4f0e4adfc4b0b86646880677db39\",\"dweb:/ipfs/QmRKfJD4FFM1AvTynSFNx1NcDg94o9SAcjz7dvMaJCfecp\"]},\"/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": "0x60636023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a723158206e5d6d510e485e0a7b6bb18527ed4d34c451ba7fd29b19f51f0be8a39f87a4fd6c6578706572696d656e74616cf564736f6c63430005100040",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a723158206e5d6d510e485e0a7b6bb18527ed4d34c451ba7fd29b19f51f0be8a39f87a4fd6c6578706572696d656e74616cf564736f6c63430005100040",
"sourceMap": "911:1114:91:-;;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": "911:1114:91:-;;;;;;;;",
"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 Decimal\n * @author dYdX\n *\n * Library that defines a fixed-point number with 18 decimal places.\n */\nlibrary Decimal {\n using SafeMath for uint256;\n\n // ============ Constants ============\n\n uint256 constant BASE = 10**18;\n\n // ============ Structs ============\n\n struct D256 {\n uint256 value;\n }\n\n // ============ Functions ============\n\n function zero()\n internal\n pure\n returns (D256 memory)\n {\n return D256({ value: 0 });\n }\n\n function one()\n internal\n pure\n returns (D256 memory)\n {\n return D256({ value: BASE });\n }\n\n function onePlus(\n D256 memory d\n )\n internal\n pure\n returns (D256 memory)\n {\n return D256({ value: d.value.add(BASE) });\n }\n\n function mul(\n uint256 target,\n D256 memory d\n )\n internal\n pure\n returns (uint256)\n {\n return DolomiteMarginMath.getPartial(target, d.value, BASE);\n }\n\n function div(\n uint256 target,\n D256 memory d\n )\n internal\n pure\n returns (uint256)\n {\n return DolomiteMarginMath.getPartial(target, BASE, d.value);\n }\n}\n",
"sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol",
"ast": {
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol",
"exportedSymbols": {
"Decimal": [
26023
]
},
"id": 26024,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 25934,
"literals": [
"solidity",
"^",
"0.5",
".7"
],
"nodeType": "PragmaDirective",
"src": "603:23:91"
},
{
"id": 25935,
"literals": [
"experimental",
"ABIEncoderV2"
],
"nodeType": "PragmaDirective",
"src": "627:33:91"
},
{
"absolutePath": "@openzeppelin/contracts/math/SafeMath.sol",
"file": "@openzeppelin/contracts/math/SafeMath.sol",
"id": 25937,
"nodeType": "ImportDirective",
"scope": 26024,
"sourceUnit": 37366,
"src": "662:69:91",
"symbolAliases": [
{
"foreign": 25936,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol",
"file": "./DolomiteMarginMath.sol",
"id": 25939,
"nodeType": "ImportDirective",
"scope": 26024,
"sourceUnit": 26239,
"src": "732:62:91",
"symbolAliases": [
{
"foreign": 25938,
"local": null
}
],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@title Decimal\n@author dYdX\n * Library that defines a fixed-point number with 18 decimal places.",
"fullyImplemented": true,
"id": 26023,
"linearizedBaseContracts": [
26023
],
"name": "Decimal",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 25942,
"libraryName": {
"contractScope": null,
"id": 25940,
"name": "SafeMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 37365,
"src": "939:8:91",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeMath_$37365",
"typeString": "library SafeMath"
}
},
"nodeType": "UsingForDirective",
"src": "933:27:91",
"typeName": {
"id": 25941,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "952:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"constant": true,
"id": 25947,
"name": "BASE",
"nodeType": "VariableDeclaration",
"scope": 26023,
"src": "1010:30:91",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25943,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1010:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_1000000000000000000_by_1",
"typeString": "int_const 1000000000000000000"
},
"id": 25946,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"hexValue": "3130",
"id": 25944,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1034:2:91",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_10_by_1",
"typeString": "int_const 10"
},
"value": "10"
},
"nodeType": "BinaryOperation",
"operator": "**",
"rightExpression": {
"argumentTypes": null,
"hexValue": "3138",
"id": 25945,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1038:2:91",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_18_by_1",
"typeString": "int_const 18"
},
"value": "18"
},
"src": "1034:6:91",
"typeDescriptions": {
"typeIdentifier": "t_rational_1000000000000000000_by_1",
"typeString": "int_const 1000000000000000000"
}
},
"visibility": "internal"
},
{
"canonicalName": "Decimal.D256",
"id": 25950,
"members": [
{
"constant": false,
"id": 25949,
"name": "value",
"nodeType": "VariableDeclaration",
"scope": 25950,
"src": "1111:13:91",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25948,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1111:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "D256",
"nodeType": "StructDefinition",
"scope": 26023,
"src": "1089:42:91",
"visibility": "public"
},
{
"body": {
"id": 25959,
"nodeType": "Block",
"src": "1261:42:91",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "30",
"id": 25956,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1292:1:91",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
}
],
"id": 25955,
"name": "D256",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25950,
"src": "1278:4:91",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_D256_$25950_storage_ptr_$",
"typeString": "type(struct Decimal.D256 storage pointer)"
}
},
"id": 25957,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [
"value"
],
"nodeType": "FunctionCall",
"src": "1278:18:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory",
"typeString": "struct Decimal.D256 memory"
}
},
"functionReturnParameters": 25954,
"id": 25958,
"nodeType": "Return",
"src": "1271:25:91"
}
]
},
"documentation": null,
"id": 25960,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "zero",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 25951,
"nodeType": "ParameterList",
"parameters": [],
"src": "1194:2:91"
},
"returnParameters": {
"id": 25954,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25953,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 25960,
"src": "1244:11:91",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256"
},
"typeName": {
"contractScope": null,
"id": 25952,
"name": "D256",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25950,
"src": "1244:4:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_storage_ptr",
"typeString": "struct Decimal.D256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1243:13:91"
},
"scope": 26023,
"src": "1181:122:91",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 25969,
"nodeType": "Block",
"src": "1388:45:91",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 25966,
"name": "BASE",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25947,
"src": "1419:4:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 25965,
"name": "D256",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25950,
"src": "1405:4:91",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_D256_$25950_storage_ptr_$",
"typeString": "type(struct Decimal.D256 storage pointer)"
}
},
"id": 25967,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [
"value"
],
"nodeType": "FunctionCall",
"src": "1405:21:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory",
"typeString": "struct Decimal.D256 memory"
}
},
"functionReturnParameters": 25964,
"id": 25968,
"nodeType": "Return",
"src": "1398:28:91"
}
]
},
"documentation": null,
"id": 25970,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "one",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 25961,
"nodeType": "ParameterList",
"parameters": [],
"src": "1321:2:91"
},
"returnParameters": {
"id": 25964,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25963,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 25970,
"src": "1371:11:91",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256"
},
"typeName": {
"contractScope": null,
"id": 25962,
"name": "D256",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25950,
"src": "1371:4:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_storage_ptr",
"typeString": "struct Decimal.D256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1370:13:91"
},
"scope": 26023,
"src": "1309:124:91",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 25985,
"nodeType": "Block",
"src": "1549:58:91",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 25981,
"name": "BASE",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25947,
"src": "1592:4:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 25978,
"name": "d",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25972,
"src": "1580:1:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256 memory"
}
},
"id": 25979,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": 25949,
"src": "1580:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 25980,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "add",
"nodeType": "MemberAccess",
"referencedDeclaration": 37205,
"src": "1580:11:91",
"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": 25982,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1580:17:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 25977,
"name": "D256",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25950,
"src": "1566:4:91",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_D256_$25950_storage_ptr_$",
"typeString": "type(struct Decimal.D256 storage pointer)"
}
},
"id": 25983,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [
"value"
],
"nodeType": "FunctionCall",
"src": "1566:34:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory",
"typeString": "struct Decimal.D256 memory"
}
},
"functionReturnParameters": 25976,
"id": 25984,
"nodeType": "Return",
"src": "1559:41:91"
}
]
},
"documentation": null,
"id": 25986,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "onePlus",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 25973,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25972,
"name": "d",
"nodeType": "VariableDeclaration",
"scope": 25986,
"src": "1465:13:91",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256"
},
"typeName": {
"contractScope": null,
"id": 25971,
"name": "D256",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25950,
"src": "1465:4:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_storage_ptr",
"typeString": "struct Decimal.D256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1455:29:91"
},
"returnParameters": {
"id": 25976,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25975,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 25986,
"src": "1532:11:91",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256"
},
"typeName": {
"contractScope": null,
"id": 25974,
"name": "D256",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25950,
"src": "1532:4:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_storage_ptr",
"typeString": "struct Decimal.D256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1531:13:91"
},
"scope": 26023,
"src": "1439:168:91",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 26003,
"nodeType": "Block",
"src": "1739:76:91",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 25997,
"name": "target",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25988,
"src": "1786:6:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 25998,
"name": "d",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25990,
"src": "1794:1:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256 memory"
}
},
"id": 25999,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": 25949,
"src": "1794:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,
"id": 26000,
"name": "BASE",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25947,
"src": "1803:4:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 25995,
"name": "DolomiteMarginMath",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26238,
"src": "1756:18:91",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_DolomiteMarginMath_$26238_$",
"typeString": "type(library DolomiteMarginMath)"
}
},
"id": 25996,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "getPartial",
"nodeType": "MemberAccess",
"referencedDeclaration": 26056,
"src": "1756:29:91",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$_t_uint256_$returns$_t_uint256_$",
"typeString": "function (uint256,uint256,uint256) pure returns (uint256)"
}
},
"id": 26001,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1756:52:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"functionReturnParameters": 25994,
"id": 26002,
"nodeType": "Return",
"src": "1749:59:91"
}
]
},
"documentation": null,
"id": 26004,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "mul",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 25991,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25988,
"name": "target",
"nodeType": "VariableDeclaration",
"scope": 26004,
"src": "1635:14:91",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25987,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1635:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25990,
"name": "d",
"nodeType": "VariableDeclaration",
"scope": 26004,
"src": "1659:13:91",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256"
},
"typeName": {
"contractScope": null,
"id": 25989,
"name": "D256",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25950,
"src": "1659:4:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_storage_ptr",
"typeString": "struct Decimal.D256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1625:53:91"
},
"returnParameters": {
"id": 25994,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25993,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 26004,
"src": "1726:7:91",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25992,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1726:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1725:9:91"
},
"scope": 26023,
"src": "1613:202:91",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 26021,
"nodeType": "Block",
"src": "1947:76:91",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 26015,
"name": "target",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26006,
"src": "1994:6:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,
"id": 26016,
"name": "BASE",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25947,
"src": "2002:4:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 26017,
"name": "d",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26008,
"src": "2008:1:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256 memory"
}
},
"id": 26018,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": 25949,
"src": "2008:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 26013,
"name": "DolomiteMarginMath",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 26238,
"src": "1964:18:91",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_DolomiteMarginMath_$26238_$",
"typeString": "type(library DolomiteMarginMath)"
}
},
"id": 26014,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "getPartial",
"nodeType": "MemberAccess",
"referencedDeclaration": 26056,
"src": "1964:29:91",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$_t_uint256_$returns$_t_uint256_$",
"typeString": "function (uint256,uint256,uint256) pure returns (uint256)"
}
},
"id": 26019,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1964:52:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"functionReturnParameters": 26012,
"id": 26020,
"nodeType": "Return",
"src": "1957:59:91"
}
]
},
"documentation": null,
"id": 26022,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "div",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 26009,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 26006,
"name": "target",
"nodeType": "VariableDeclaration",
"scope": 26022,
"src": "1843:14:91",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26005,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1843:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 26008,
"name": "d",
"nodeType": "VariableDeclaration",
"scope": 26022,
"src": "1867:13:91",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_memory_ptr",
"typeString": "struct Decimal.D256"
},
"typeName": {
"contractScope": null,
"id": 26007,
"name": "D256",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25950,
"src": "1867:4:91",
"typeDescriptions": {
"typeIdentifier": "t_struct$_D256_$25950_storage_ptr",
"typeString": "struct Decimal.D256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1833:53:91"
},
"returnParameters": {
"id": 26012,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 26011,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 26022,
"src": "1934:7:91",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 26010,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1934:7:91",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1933:9:91"
},
"scope": 26023,
"src": "1821:202:91",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
}
],
"scope": 26024,
"src": "911:1114:91"
}
],
"src": "603:1423:91"
},
"legacyAST": {
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol",
"exportedSymbols": {
"Decimal": [
26023
]
},
"id": 26024,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 25934,
"literals": [
"solidity",
"^",
"0.5",
".7"
],
"nodeType": "PragmaDirective",
"src": "603:23:91"
},
{
"id": 25935,
"literals": [
"experimental",
"ABIEncoderV2"
],
"nodeType": "PragmaDirective",
"src": "627:33:91"
},
{
"absolutePath": "@openzeppelin/contracts/math/SafeMath.sol",
"file": "@openzeppelin/contracts/math/SafeMath.sol",
"id": 25937,
"nodeType": "ImportDirective",
"scope": 26024,
"sourceUnit": 37366,
"src": "662:69:91",
"symbolAliases": [
{
"foreign": 25936,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol",
"file": "./DolomiteMarginMath.sol",
"id": 25939,
"nodeType": "ImportDirective",
"scope": 26024,
"sourceUnit": 26239,
"src": "732:62:91",
"symbolAliases": [
{
"foreign": 25938,
"local": null
}
],
"unitAlias": ""
},
{
"base