@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
1,060 lines (1,059 loc) • 325 kB
JSON
{
"contractName": "Cache",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"author\":\"dYdX * Library for caching information about markets\",\"methods\":{},\"title\":\"Cache\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Cache.sol\":\"Cache\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Bits.sol\":{\"keccak256\":\"0x6d9a641163b2dd25e648c65f5d9e4949a57938e29ddc4c9dddefd74a9964aeef\",\"urls\":[\"bzz-raw://67e5a04ed4055faafbc100d6ccca9c54448ed378a1a8c71171562edda7bcbf7c\",\"dweb:/ipfs/QmYRikK3Xbgiq3UBJkgoo2zNUSSrShVabpRHmQj6iQHhrc\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Cache.sol\":{\"keccak256\":\"0xe57c80a7621a77fcb2acb9f883fb5248e71a6dce03bc2db56df0db3fee332950\",\"urls\":[\"bzz-raw://28e221c04629674490b9a0041d4f9a5f15e669dc0cc192a5df6e2c701c36369f\",\"dweb:/ipfs/QmaL3oh8c7v9cx91pB175pyCEuzxnhNTab4UxmBMsDYfUx\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol\":{\"keccak256\":\"0xd9a348c2b1eec076609ba12bbec6b9c2e4ea135790a7ef4f5411feb050af2144\",\"urls\":[\"bzz-raw://d5bcff29e47d5cd02d7a9966e9f44c46ccbb4f0e4adfc4b0b86646880677db39\",\"dweb:/ipfs/QmRKfJD4FFM1AvTynSFNx1NcDg94o9SAcjz7dvMaJCfecp\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol\":{\"keccak256\":\"0x53f205f6a779d579be29faa9412c806a892b3e605fff092dfd9d14d936fa019f\",\"urls\":[\"bzz-raw://0ff936f89602a63b8e6a4eb4ce8f87673c0f45b7ce29694920905a3f0b5a6a69\",\"dweb:/ipfs/QmbYME9BeEvPC1ndV8EaUDX5fDMghLc3rocNUxFtgHmg8m\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol\":{\"keccak256\":\"0x141a0ecb4a746f0e5767df4b99dbe33c6362df507ae9d5c02da1c1c17bc26df3\",\"urls\":[\"bzz-raw://9ff03e64a8ce5231acde07788624bf8c7a8ff55d90b157fa32f62fa887a0eff0\",\"dweb:/ipfs/QmUVxxWeE954RDXbmHJAYnHsXcit6rSXGqZUigu8t9oH2z\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Monetary.sol\":{\"keccak256\":\"0x5257274f2d4d3605f3e97ec45fb902111fe9a22506f0b4cf308ea933bc81bfe2\",\"urls\":[\"bzz-raw://85b8023b78805063a2ec8d376f1f5983994eabd96efd8ceadb0224dbb71c5678\",\"dweb:/ipfs/QmaDhzCzRqsuHuJfhToEC4pATQHwhh7yWWsjwfuRzFT1kG\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Require.sol\":{\"keccak256\":\"0x05a2a90b41b6a5f42f0a72da63d015fb0b406a9ba2172823352e522e8bf3a606\",\"urls\":[\"bzz-raw://19883f0c6d33266f756ec5c3d17539524aa24b993c46c33f8400801d09373a6c\",\"dweb:/ipfs/QmYX2fwK3vQQDSZLMrc5wMfeb8RWrcC9CGX8XECLty8QDk\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Time.sol\":{\"keccak256\":\"0x87ee8d3c1d6e315a116426d8c8fc6f083e220fd14dda27fad4e8d7cab3dc7305\",\"urls\":[\"bzz-raw://7c20f2c52da682c3b5917fb6a19e81f43699b1d13c62b569ed723f34da72e766\",\"dweb:/ipfs/QmbXWYXi67nHBVNDKYUpo2E9ZaEVcHLvmXQkpYLMm1d5Vm\"]},\"/home/cdc218/projects/dolomite/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": "0x60636023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a72315820f0853b835951bace51b28d7fe3a1adc3a82032df266a2f029a411fb6ab4817446c6578706572696d656e74616cf564736f6c63430005100040",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a72315820f0853b835951bace51b28d7fe3a1adc3a82032df266a2f029a411fb6ab4817446c6578706572696d656e74616cf564736f6c63430005100040",
"sourceMap": "918:3738:90:-;;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": "918:3738:90:-;;;;;;;;",
"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 { Bits } from \"./Bits.sol\";\nimport { Interest } from \"./Interest.sol\";\nimport { Monetary } from \"./Monetary.sol\";\nimport { Require } from \"./Require.sol\";\n\n\n/**\n * @title Cache\n * @author dYdX\n *\n * Library for caching information about markets\n */\nlibrary Cache {\n\n // ============ Constants ============\n\n bytes32 private constant FILE = \"Cache\";\n\n // ============ Structs ============\n\n struct MarketInfo {\n uint marketId;\n address token;\n bool isClosing;\n uint128 borrowPar;\n uint128 supplyPar;\n Interest.Index index;\n Monetary.Price price;\n }\n\n struct MarketCache {\n MarketInfo[] markets;\n uint256 counter; // used for iterating through the bitmaps and incrementing\n uint256[] marketBitmaps;\n uint256 marketsLength;\n }\n\n // ============ Setter Functions ============\n\n /**\n * Initialize an empty cache for some given number of total markets.\n */\n function create(\n uint256 numMarkets\n )\n internal\n pure\n returns (MarketCache memory)\n {\n return MarketCache({\n markets: new MarketInfo[](0),\n counter: 0,\n marketBitmaps: Bits.createBitmaps(numMarkets),\n marketsLength: 0\n });\n }\n\n // ============ Getter Functions ============\n\n function getNumMarkets(\n MarketCache memory cache\n )\n internal\n pure\n returns (uint256)\n {\n return cache.markets.length;\n }\n\n function hasMarket(\n MarketCache memory cache,\n uint256 marketId\n )\n internal\n pure\n returns (bool)\n {\n return Bits.hasBit(cache.marketBitmaps, marketId);\n }\n\n function get(\n MarketCache memory cache,\n uint256 marketId\n )\n internal\n pure\n returns (MarketInfo memory)\n {\n Require.that(\n cache.markets.length != 0,\n FILE,\n \"not initialized\"\n );\n return _getInternal(\n cache.markets,\n 0,\n cache.marketsLength,\n marketId\n );\n }\n\n function set(\n MarketCache memory cache,\n uint256 marketId\n )\n internal\n pure\n {\n // Devs should not be able to call this function once the `markets` array has been initialized (non-zero length)\n Require.that(\n cache.markets.length == 0,\n FILE,\n \"already initialized\"\n );\n\n Bits.setBit(cache.marketBitmaps, marketId);\n\n cache.marketsLength += 1;\n }\n\n function getAtIndex(\n MarketCache memory cache,\n uint256 index\n )\n internal\n pure\n returns (MarketInfo memory)\n {\n Require.that(\n index < cache.markets.length,\n FILE,\n \"invalid index\",\n index,\n cache.markets.length\n );\n return cache.markets[index];\n }\n\n // ============ Private Functions ============\n\n function _getInternal(\n MarketInfo[] memory data,\n uint beginInclusive,\n uint endExclusive,\n uint marketId\n ) private pure returns (MarketInfo memory) {\n uint len = endExclusive - beginInclusive;\n // If length equals 0 OR length equals 1 but the item wasn't found, revert\n assert(!(len == 0 || (len == 1 && data[beginInclusive].marketId != marketId)));\n\n uint mid = beginInclusive + (len >> 1);\n uint midMarketId = data[mid].marketId;\n if (marketId < midMarketId) {\n return _getInternal(\n data,\n beginInclusive,\n mid,\n marketId\n );\n } else if (marketId > midMarketId) {\n return _getInternal(\n data,\n mid + 1,\n endExclusive,\n marketId\n );\n } else {\n return data[mid];\n }\n }\n\n}\n",
"sourcePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Cache.sol",
"ast": {
"absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Cache.sol",
"exportedSymbols": {
"Cache": [
25932
]
},
"id": 25933,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 25658,
"literals": [
"solidity",
"^",
"0.5",
".7"
],
"nodeType": "PragmaDirective",
"src": "603:23:90"
},
{
"id": 25659,
"literals": [
"experimental",
"ABIEncoderV2"
],
"nodeType": "PragmaDirective",
"src": "627:33:90"
},
{
"absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Bits.sol",
"file": "./Bits.sol",
"id": 25661,
"nodeType": "ImportDirective",
"scope": 25933,
"sourceUnit": 25657,
"src": "662:34:90",
"symbolAliases": [
{
"foreign": 25660,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol",
"file": "./Interest.sol",
"id": 25663,
"nodeType": "ImportDirective",
"scope": 25933,
"sourceUnit": 27751,
"src": "697:42:90",
"symbolAliases": [
{
"foreign": 25662,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Monetary.sol",
"file": "./Monetary.sol",
"id": 25665,
"nodeType": "ImportDirective",
"scope": 25933,
"sourceUnit": 27761,
"src": "740:42:90",
"symbolAliases": [
{
"foreign": 25664,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Require.sol",
"file": "./Require.sol",
"id": 25667,
"nodeType": "ImportDirective",
"scope": 25933,
"sourceUnit": 28453,
"src": "783:40:90",
"symbolAliases": [
{
"foreign": 25666,
"local": null
}
],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@title Cache\n@author dYdX\n * Library for caching information about markets",
"fullyImplemented": true,
"id": 25932,
"linearizedBaseContracts": [
25932
],
"name": "Cache",
"nodeType": "ContractDefinition",
"nodes": [
{
"constant": true,
"id": 25670,
"name": "FILE",
"nodeType": "VariableDeclaration",
"scope": 25932,
"src": "983:39:90",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 25668,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "983:7:90",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": {
"argumentTypes": null,
"hexValue": "4361636865",
"id": 25669,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1015:7:90",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_ae23ae76ade5c90c9befce8f022bdd8f930bbd66dd5fd4eb31341a4923a85082",
"typeString": "literal_string \"Cache\""
},
"value": "Cache"
},
"visibility": "private"
},
{
"canonicalName": "Cache.MarketInfo",
"id": 25685,
"members": [
{
"constant": false,
"id": 25672,
"name": "marketId",
"nodeType": "VariableDeclaration",
"scope": 25685,
"src": "1099:13:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25671,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "1099:4:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25674,
"name": "token",
"nodeType": "VariableDeclaration",
"scope": 25685,
"src": "1122:13:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 25673,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1122:7:90",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25676,
"name": "isClosing",
"nodeType": "VariableDeclaration",
"scope": 25685,
"src": "1145:14:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 25675,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "1145:4:90",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25678,
"name": "borrowPar",
"nodeType": "VariableDeclaration",
"scope": 25685,
"src": "1169:17:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
},
"typeName": {
"id": 25677,
"name": "uint128",
"nodeType": "ElementaryTypeName",
"src": "1169:7:90",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25680,
"name": "supplyPar",
"nodeType": "VariableDeclaration",
"scope": 25685,
"src": "1196:17:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
},
"typeName": {
"id": 25679,
"name": "uint128",
"nodeType": "ElementaryTypeName",
"src": "1196:7:90",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25682,
"name": "index",
"nodeType": "VariableDeclaration",
"scope": 25685,
"src": "1223:20:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Index_$27471_storage_ptr",
"typeString": "struct Interest.Index"
},
"typeName": {
"contractScope": null,
"id": 25681,
"name": "Interest.Index",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 27471,
"src": "1223:14:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Index_$27471_storage_ptr",
"typeString": "struct Interest.Index"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25684,
"name": "price",
"nodeType": "VariableDeclaration",
"scope": 25685,
"src": "1253:20:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Price_$27756_storage_ptr",
"typeString": "struct Monetary.Price"
},
"typeName": {
"contractScope": null,
"id": 25683,
"name": "Monetary.Price",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 27756,
"src": "1253:14:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Price_$27756_storage_ptr",
"typeString": "struct Monetary.Price"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "MarketInfo",
"nodeType": "StructDefinition",
"scope": 25932,
"src": "1071:209:90",
"visibility": "public"
},
{
"canonicalName": "Cache.MarketCache",
"id": 25696,
"members": [
{
"constant": false,
"id": 25688,
"name": "markets",
"nodeType": "VariableDeclaration",
"scope": 25696,
"src": "1315:20:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_MarketInfo_$25685_storage_$dyn_storage_ptr",
"typeString": "struct Cache.MarketInfo[]"
},
"typeName": {
"baseType": {
"contractScope": null,
"id": 25686,
"name": "MarketInfo",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25685,
"src": "1315:10:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketInfo_$25685_storage_ptr",
"typeString": "struct Cache.MarketInfo"
}
},
"id": 25687,
"length": null,
"nodeType": "ArrayTypeName",
"src": "1315:12:90",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_MarketInfo_$25685_storage_$dyn_storage_ptr",
"typeString": "struct Cache.MarketInfo[]"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25690,
"name": "counter",
"nodeType": "VariableDeclaration",
"scope": 25696,
"src": "1345:15:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25689,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1345:7:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25693,
"name": "marketBitmaps",
"nodeType": "VariableDeclaration",
"scope": 25696,
"src": "1429:23:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr",
"typeString": "uint256[]"
},
"typeName": {
"baseType": {
"id": 25691,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1429:7:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 25692,
"length": null,
"nodeType": "ArrayTypeName",
"src": "1429:9:90",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr",
"typeString": "uint256[]"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 25695,
"name": "marketsLength",
"nodeType": "VariableDeclaration",
"scope": 25696,
"src": "1462:21:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25694,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1462:7:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "MarketCache",
"nodeType": "StructDefinition",
"scope": 25932,
"src": "1286:204:90",
"visibility": "public"
},
{
"body": {
"id": 25717,
"nodeType": "Block",
"src": "1757:202:90",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "30",
"id": 25707,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1826:1:90",
"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": 25706,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "NewExpression",
"src": "1809:16:90",
"typeDescriptions": {
"typeIdentifier": "t_function_objectcreation_pure$_t_uint256_$returns$_t_array$_t_struct$_MarketInfo_$25685_memory_$dyn_memory_$",
"typeString": "function (uint256) pure returns (struct Cache.MarketInfo memory[] memory)"
},
"typeName": {
"baseType": {
"contractScope": null,
"id": 25704,
"name": "MarketInfo",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25685,
"src": "1813:10:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketInfo_$25685_storage_ptr",
"typeString": "struct Cache.MarketInfo"
}
},
"id": 25705,
"length": null,
"nodeType": "ArrayTypeName",
"src": "1813:12:90",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_MarketInfo_$25685_storage_$dyn_storage_ptr",
"typeString": "struct Cache.MarketInfo[]"
}
}
},
"id": 25708,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1809:19:90",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_MarketInfo_$25685_memory_$dyn_memory",
"typeString": "struct Cache.MarketInfo memory[] memory"
}
},
{
"argumentTypes": null,
"hexValue": "30",
"id": 25709,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1851:1:90",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 25712,
"name": "numMarkets",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25698,
"src": "1900:10:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 25710,
"name": "Bits",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25656,
"src": "1881:4:90",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Bits_$25656_$",
"typeString": "type(library Bits)"
}
},
"id": 25711,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "createBitmaps",
"nodeType": "MemberAccess",
"referencedDeclaration": 25400,
"src": "1881:18:90",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$returns$_t_array$_t_uint256_$dyn_memory_ptr_$",
"typeString": "function (uint256) pure returns (uint256[] memory)"
}
},
"id": 25713,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1881:30:90",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[] memory"
}
},
{
"argumentTypes": null,
"hexValue": "30",
"id": 25714,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1940:1:90",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_array$_t_struct$_MarketInfo_$25685_memory_$dyn_memory",
"typeString": "struct Cache.MarketInfo memory[] memory"
},
{
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
{
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[] memory"
},
{
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
}
],
"id": 25703,
"name": "MarketCache",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25696,
"src": "1774:11:90",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_struct$_MarketCache_$25696_storage_ptr_$",
"typeString": "type(struct Cache.MarketCache storage pointer)"
}
},
"id": 25715,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "structConstructorCall",
"lValueRequested": false,
"names": [
"markets",
"counter",
"marketBitmaps",
"marketsLength"
],
"nodeType": "FunctionCall",
"src": "1774:178:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketCache_$25696_memory",
"typeString": "struct Cache.MarketCache memory"
}
},
"functionReturnParameters": 25702,
"id": 25716,
"nodeType": "Return",
"src": "1767:185:90"
}
]
},
"documentation": "Initialize an empty cache for some given number of total markets.",
"id": 25718,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "create",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 25699,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25698,
"name": "numMarkets",
"nodeType": "VariableDeclaration",
"scope": 25718,
"src": "1661:18:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25697,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1661:7:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1651:34:90"
},
"returnParameters": {
"id": 25702,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25701,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 25718,
"src": "1733:18:90",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketCache_$25696_memory_ptr",
"typeString": "struct Cache.MarketCache"
},
"typeName": {
"contractScope": null,
"id": 25700,
"name": "MarketCache",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25696,
"src": "1733:11:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketCache_$25696_storage_ptr",
"typeString": "struct Cache.MarketCache"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1732:20:90"
},
"scope": 25932,
"src": "1636:323:90",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 25729,
"nodeType": "Block",
"src": "2139:44:90",
"statements": [
{
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 25725,
"name": "cache",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25720,
"src": "2156:5:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketCache_$25696_memory_ptr",
"typeString": "struct Cache.MarketCache memory"
}
},
"id": 25726,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "markets",
"nodeType": "MemberAccess",
"referencedDeclaration": 25688,
"src": "2156:13:90",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_MarketInfo_$25685_memory_$dyn_memory",
"typeString": "struct Cache.MarketInfo memory[] memory"
}
},
"id": 25727,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "length",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "2156:20:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"functionReturnParameters": 25724,
"id": 25728,
"nodeType": "Return",
"src": "2149:27:90"
}
]
},
"documentation": null,
"id": 25730,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getNumMarkets",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 25721,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25720,
"name": "cache",
"nodeType": "VariableDeclaration",
"scope": 25730,
"src": "2048:24:90",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketCache_$25696_memory_ptr",
"typeString": "struct Cache.MarketCache"
},
"typeName": {
"contractScope": null,
"id": 25719,
"name": "MarketCache",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 25696,
"src": "2048:11:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketCache_$25696_storage_ptr",
"typeString": "struct Cache.MarketCache"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "2038:40:90"
},
"returnParameters": {
"id": 25724,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 25723,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 25730,
"src": "2126:7:90",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 25722,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "2126:7:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "2125:9:90"
},
"scope": 25932,
"src": "2016:167:90",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 25746,
"nodeType": "Block",
"src": "2331:66:90",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 25741,
"name": "cache",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25732,
"src": "2360:5:90",
"typeDescriptions": {
"typeIdentifier": "t_struct$_MarketCache_$25696_memory_ptr",
"typeString": "struct Cache.MarketCache memory"
}
},
"id": 25742,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "marketBitmaps",
"nodeType": "MemberAccess",
"referencedDeclaration": 25693,
"src": "2360:19:90",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory",
"typeString": "uint256[] memory"
}
},
{
"argumentTypes": null,
"id": 25743,
"name": "marketId",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25734,
"src": "2381:8:90",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_array$_t_uint256_$dyn_memory",
"typeString": "uint256[] memory"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 25739,
"name": "Bits",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25656,
"src": "2348:4:90",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Bits_$25656_$",
"typeString": "type(library Bits)"
}
},
"id": 25740,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "hasBit",
"nodeType": "MemberAccess",
"referencedDeclaration": 25485,
"src": "2348:11:90",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_array$_t_uint256_$dyn_memory_ptr_$_t_uint256_$returns$_t_bool_$",
"typeString": "function (uint256[] memory,uint256) pure returns (bool)"
}
},
"id": 25744,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],