UNPKG

@gnosis.pm/dex-contracts

Version:

Contracts for dFusion multi-token batch auction exchange

1,059 lines 287 kB
{ "contractName": "TokenConservation", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.5.10+commit.5a6ea5b1\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"author\":\"@gnosis/dfusion-team <https://github.com/orgs/gnosis/teams/dfusion-team/members>\",\"methods\":{},\"title\":\"Token Conservation A library for updating and verifying the tokenConservation contraint for BatchExchange's batch auction\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/felixleupold/Gnosis/dex-contracts/contracts/libraries/TokenConservation.sol\":\"TokenConservation\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/felixleupold/Gnosis/dex-contracts/contracts/libraries/TokenConservation.sol\":{\"keccak256\":\"0x674557850e56ef6a716bb1dc528479e290238c592d0764bc7144cc1e811cedea\",\"urls\":[\"bzzr://f6a943472678132ef59cf3b2f131daf28952c1b72cd0e28bda46050dd577a29b\",\"dweb:/ipfs/QmbQsAgu7Fd6i84A98DxXemSnW3UkgccXxNnZLKvtuzHdE\"]},\"@openzeppelin/contracts/drafts/SignedSafeMath.sol\":{\"keccak256\":\"0xf1587a6daea33c93e85fff4e205967183de459159aafcb01b7397fb7ec1f9f77\",\"urls\":[\"bzzr://3fa5ad67118819b61448882baec9ca9964dde65630f574ab3c38841110082923\",\"dweb:/ipfs/QmTaR64X6RsWzXvVGxPCaAoW7ZZ8Fhiii4ddRo7QpQGBrx\"]}},\"version\":1}", "bytecode": "0x60556023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723058208367123e792e7b1955b543b9864599c198f064eb4ca790100b9b2bcbf2a9db2964736f6c634300050a0032", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723058208367123e792e7b1955b543b9864599c198f064eb4ca790100b9b2bcbf2a9db2964736f6c634300050a0032", "sourceMap": "320:3983:6:-;;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": "320:3983:6:-;;;;;;;;", "source": "pragma solidity ^0.5.0;\n\nimport \"@openzeppelin/contracts/drafts/SignedSafeMath.sol\";\n\n/** @title Token Conservation\n * A library for updating and verifying the tokenConservation contraint for BatchExchange's batch auction\n * @author @gnosis/dfusion-team <https://github.com/orgs/gnosis/teams/dfusion-team/members>\n */\nlibrary TokenConservation {\n using SignedSafeMath for int256;\n\n /** @dev initialize the token conservation data structure\n * @param tokenIdsForPrice sorted list of tokenIds for which token conservation should be checked\n */\n function init(uint16[] memory tokenIdsForPrice) internal pure returns (int256[] memory) {\n return new int256[](tokenIdsForPrice.length + 1);\n }\n\n /** @dev returns the token imbalance of the fee token\n * @param self internal datastructure created by TokenConservation.init()\n */\n function feeTokenImbalance(int256[] memory self) internal pure returns (int256) {\n return self[0];\n }\n\n /** @dev updated token conservation array.\n * @param self internal datastructure created by TokenConservation.init()\n * @param buyToken id of token whose imbalance should be subtracted from\n * @param sellToken id of token whose imbalance should be added to\n * @param tokenIdsForPrice sorted list of tokenIds\n * @param buyAmount amount to be subtracted at `self[buyTokenIndex]`\n * @param sellAmount amount to be added at `self[sellTokenIndex]`\n */\n function updateTokenConservation(\n int256[] memory self,\n uint16 buyToken,\n uint16 sellToken,\n uint16[] memory tokenIdsForPrice,\n uint128 buyAmount,\n uint128 sellAmount\n ) internal pure {\n uint256 buyTokenIndex = findPriceIndex(buyToken, tokenIdsForPrice);\n uint256 sellTokenIndex = findPriceIndex(sellToken, tokenIdsForPrice);\n self[buyTokenIndex] = self[buyTokenIndex].sub(int256(buyAmount));\n self[sellTokenIndex] = self[sellTokenIndex].add(int256(sellAmount));\n }\n\n /** @dev Ensures all array's elements are zero except the first.\n * @param self internal datastructure created by TokenConservation.init()\n * @return true if all, but first element of self are zero else false\n */\n function checkTokenConservation(int256[] memory self) internal pure {\n require(self[0] > 0, \"Token conservation at 0 must be positive.\");\n for (uint256 i = 1; i < self.length; i++) {\n require(self[i] == 0, \"Token conservation does not hold\");\n }\n }\n\n /** @dev Token ordering is verified by submitSolution. Required because binary search is used to fetch token info.\n * @param tokenIdsForPrice list of tokenIds\n * @return true if tokenIdsForPrice is sorted else false\n */\n function checkPriceOrdering(uint16[] memory tokenIdsForPrice) internal pure returns (bool) {\n for (uint256 i = 1; i < tokenIdsForPrice.length; i++) {\n if (tokenIdsForPrice[i] <= tokenIdsForPrice[i - 1]) {\n return false;\n }\n }\n return true;\n }\n\n /** @dev implementation of binary search on sorted list returns token id\n * @param tokenId element whose index is to be found\n * @param tokenIdsForPrice list of (sorted) tokenIds for which binary search is applied.\n * @return `index` in `tokenIdsForPrice` where `tokenId` appears (reverts if not found).\n */\n function findPriceIndex(uint16 tokenId, uint16[] memory tokenIdsForPrice) private pure returns (uint256) {\n // Fee token is not included in tokenIdsForPrice\n if (tokenId == 0) {\n return 0;\n }\n // binary search for the other tokens\n uint256 leftValue = 0;\n uint256 rightValue = tokenIdsForPrice.length - 1;\n while (rightValue >= leftValue) {\n uint256 middleValue = (leftValue + rightValue) / 2;\n if (tokenIdsForPrice[middleValue] == tokenId) {\n // shifted one to the right to account for fee token at index 0\n return middleValue + 1;\n } else if (tokenIdsForPrice[middleValue] < tokenId) {\n leftValue = middleValue + 1;\n } else {\n rightValue = middleValue - 1;\n }\n }\n revert(\"Price not provided for token\");\n }\n}\n", "sourcePath": "/Users/felixleupold/Gnosis/dex-contracts/contracts/libraries/TokenConservation.sol", "ast": { "absolutePath": "/Users/felixleupold/Gnosis/dex-contracts/contracts/libraries/TokenConservation.sol", "exportedSymbols": { "TokenConservation": [ 4661 ] }, "id": 4662, "nodeType": "SourceUnit", "nodes": [ { "id": 4413, "literals": [ "solidity", "^", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:6" }, { "absolutePath": "@openzeppelin/contracts/drafts/SignedSafeMath.sol", "file": "@openzeppelin/contracts/drafts/SignedSafeMath.sol", "id": 4414, "nodeType": "ImportDirective", "scope": 4662, "sourceUnit": 8468, "src": "25:59:6", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": "@title Token Conservation\n A library for updating and verifying the tokenConservation contraint for BatchExchange's batch auction\n @author @gnosis/dfusion-team <https://github.com/orgs/gnosis/teams/dfusion-team/members>", "fullyImplemented": true, "id": 4661, "linearizedBaseContracts": [ 4661 ], "name": "TokenConservation", "nodeType": "ContractDefinition", "nodes": [ { "id": 4417, "libraryName": { "contractScope": null, "id": 4415, "name": "SignedSafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 8467, "src": "358:14:6", "typeDescriptions": { "typeIdentifier": "t_contract$_SignedSafeMath_$8467", "typeString": "library SignedSafeMath" } }, "nodeType": "UsingForDirective", "src": "352:32:6", "typeName": { "id": 4416, "name": "int256", "nodeType": "ElementaryTypeName", "src": "377:6:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } } }, { "body": { "id": 4435, "nodeType": "Block", "src": "650:65:6", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 4432, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 4429, "name": "tokenIdsForPrice", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4420, "src": "680:16:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_uint16_$dyn_memory_ptr", "typeString": "uint16[] memory" } }, "id": 4430, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "length", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "680:23:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "+", "rightExpression": { "argumentTypes": null, "hexValue": "31", "id": 4431, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "706:1:6", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "1" }, "src": "680:27:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 4428, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "NewExpression", "src": "667:12:6", "typeDescriptions": { "typeIdentifier": "t_function_objectcreation_pure$_t_uint256_$returns$_t_array$_t_int256_$dyn_memory_$", "typeString": "function (uint256) pure returns (int256[] memory)" }, "typeName": { "baseType": { "id": 4426, "name": "int256", "nodeType": "ElementaryTypeName", "src": "671:6:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "id": 4427, "length": null, "nodeType": "ArrayTypeName", "src": "671:8:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr", "typeString": "int256[]" } } }, "id": 4433, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "667:41:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_memory", "typeString": "int256[] memory" } }, "functionReturnParameters": 4425, "id": 4434, "nodeType": "Return", "src": "660:48:6" } ] }, "documentation": "@dev initialize the token conservation data structure\n@param tokenIdsForPrice sorted list of tokenIds for which token conservation should be checked", "id": 4436, "implemented": true, "kind": "function", "modifiers": [], "name": "init", "nodeType": "FunctionDefinition", "parameters": { "id": 4421, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4420, "name": "tokenIdsForPrice", "nodeType": "VariableDeclaration", "scope": 4436, "src": "576:32:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_array$_t_uint16_$dyn_memory_ptr", "typeString": "uint16[]" }, "typeName": { "baseType": { "id": 4418, "name": "uint16", "nodeType": "ElementaryTypeName", "src": "576:6:6", "typeDescriptions": { "typeIdentifier": "t_uint16", "typeString": "uint16" } }, "id": 4419, "length": null, "nodeType": "ArrayTypeName", "src": "576:8:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_uint16_$dyn_storage_ptr", "typeString": "uint16[]" } }, "value": null, "visibility": "internal" } ], "src": "575:34:6" }, "returnParameters": { "id": 4425, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4424, "name": "", "nodeType": "VariableDeclaration", "scope": 4436, "src": "633:15:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr", "typeString": "int256[]" }, "typeName": { "baseType": { "id": 4422, "name": "int256", "nodeType": "ElementaryTypeName", "src": "633:6:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "id": 4423, "length": null, "nodeType": "ArrayTypeName", "src": "633:8:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr", "typeString": "int256[]" } }, "value": null, "visibility": "internal" } ], "src": "632:17:6" }, "scope": 4661, "src": "562:153:6", "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, { "body": { "id": 4448, "nodeType": "Block", "src": "945:31:6", "statements": [ { "expression": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 4444, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4439, "src": "962:4:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr", "typeString": "int256[] memory" } }, "id": 4446, "indexExpression": { "argumentTypes": null, "hexValue": "30", "id": 4445, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "967:1:6", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "962:7:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "functionReturnParameters": 4443, "id": 4447, "nodeType": "Return", "src": "955:14:6" } ] }, "documentation": "@dev returns the token imbalance of the fee token\n@param self internal datastructure created by TokenConservation.init()", "id": 4449, "implemented": true, "kind": "function", "modifiers": [], "name": "feeTokenImbalance", "nodeType": "FunctionDefinition", "parameters": { "id": 4440, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4439, "name": "self", "nodeType": "VariableDeclaration", "scope": 4449, "src": "892:20:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr", "typeString": "int256[]" }, "typeName": { "baseType": { "id": 4437, "name": "int256", "nodeType": "ElementaryTypeName", "src": "892:6:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "id": 4438, "length": null, "nodeType": "ArrayTypeName", "src": "892:8:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr", "typeString": "int256[]" } }, "value": null, "visibility": "internal" } ], "src": "891:22:6" }, "returnParameters": { "id": 4443, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4442, "name": "", "nodeType": "VariableDeclaration", "scope": 4449, "src": "937:6:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" }, "typeName": { "id": 4441, "name": "int256", "nodeType": "ElementaryTypeName", "src": "937:6:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "value": null, "visibility": "internal" } ], "src": "936:8:6" }, "scope": 4661, "src": "865:111:6", "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, { "body": { "id": 4506, "nodeType": "Block", "src": "1692:312:6", "statements": [ { "assignments": [ 4467 ], "declarations": [ { "constant": false, "id": 4467, "name": "buyTokenIndex", "nodeType": "VariableDeclaration", "scope": 4506, "src": "1702:21:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4466, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1702:7:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 4472, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4469, "name": "buyToken", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4454, "src": "1741:8:6", "typeDescriptions": { "typeIdentifier": "t_uint16", "typeString": "uint16" } }, { "argumentTypes": null, "id": 4470, "name": "tokenIdsForPrice", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4459, "src": "1751:16:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_uint16_$dyn_memory_ptr", "typeString": "uint16[] memory" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint16", "typeString": "uint16" }, { "typeIdentifier": "t_array$_t_uint16_$dyn_memory_ptr", "typeString": "uint16[] memory" } ], "id": 4468, "name": "findPriceIndex", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4660, "src": "1726:14:6", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_uint16_$_t_array$_t_uint16_$dyn_memory_ptr_$returns$_t_uint256_$", "typeString": "function (uint16,uint16[] memory) pure returns (uint256)" } }, "id": 4471, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1726:42:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "1702:66:6" }, { "assignments": [ 4474 ], "declarations": [ { "constant": false, "id": 4474, "name": "sellTokenIndex", "nodeType": "VariableDeclaration", "scope": 4506, "src": "1778:22:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4473, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1778:7:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 4479, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4476, "name": "sellToken", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4456, "src": "1818:9:6", "typeDescriptions": { "typeIdentifier": "t_uint16", "typeString": "uint16" } }, { "argumentTypes": null, "id": 4477, "name": "tokenIdsForPrice", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4459, "src": "1829:16:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_uint16_$dyn_memory_ptr", "typeString": "uint16[] memory" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint16", "typeString": "uint16" }, { "typeIdentifier": "t_array$_t_uint16_$dyn_memory_ptr", "typeString": "uint16[] memory" } ], "id": 4475, "name": "findPriceIndex", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4660, "src": "1803:14:6", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_uint16_$_t_array$_t_uint16_$dyn_memory_ptr_$returns$_t_uint256_$", "typeString": "function (uint16,uint16[] memory) pure returns (uint256)" } }, "id": 4478, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1803:43:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "1778:68:6" }, { "expression": { "argumentTypes": null, "id": 4491, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 4480, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4452, "src": "1856:4:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr", "typeString": "int256[] memory" } }, "id": 4482, "indexExpression": { "argumentTypes": null, "id": 4481, "name": "buyTokenIndex", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4467, "src": "1861:13:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", "src": "1856:19:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4488, "name": "buyAmount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4461, "src": "1909:9:6", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint128", "typeString": "uint128" } ], "id": 4487, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1902:6:6", "typeDescriptions": { "typeIdentifier": "t_type$_t_int256_$", "typeString": "type(int256)" }, "typeName": "int256" }, "id": 4489, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1902:17:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int256", "typeString": "int256" } ], "expression": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 4483, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4452, "src": "1878:4:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr", "typeString": "int256[] memory" } }, "id": 4485, "indexExpression": { "argumentTypes": null, "id": 4484, "name": "buyTokenIndex", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4467, "src": "1883:13:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "1878:19:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "id": 4486, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sub", "nodeType": "MemberAccess", "referencedDeclaration": 8427, "src": "1878:23:6", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_int256_$_t_int256_$returns$_t_int256_$bound_to$_t_int256_$", "typeString": "function (int256,int256) pure returns (int256)" } }, "id": 4490, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1878:42:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "src": "1856:64:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "id": 4492, "nodeType": "ExpressionStatement", "src": "1856:64:6" }, { "expression": { "argumentTypes": null, "id": 4504, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 4493, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4452, "src": "1930:4:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr", "typeString": "int256[] memory" } }, "id": 4495, "indexExpression": { "argumentTypes": null, "id": 4494, "name": "sellTokenIndex", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4474, "src": "1935:14:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", "src": "1930:20:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4501, "name": "sellAmount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4463, "src": "1985:10:6", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint128", "typeString": "uint128" } ], "id": 4500, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1978:6:6", "typeDescriptions": { "typeIdentifier": "t_type$_t_int256_$", "typeString": "type(int256)" }, "typeName": "int256" }, "id": 4502, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1978:18:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int256", "typeString": "int256" } ], "expression": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 4496, "name": "self", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4452, "src": "1953:4:6", "typeDescriptions": { "typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr", "typeString": "int256[] memory" } }, "id": 4498, "indexExpression": { "argumentTypes": null, "id": 4497, "name": "sellTokenIndex", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4474, "src": "1958:14:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "1953:20:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "id": 4499, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "add", "nodeType": "MemberAccess", "referencedDeclaration": 8466, "src": "1953:24:6", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_int256_$_t_int256_$returns$_t_int256_$bound_to$_t_int256_$", "typeString": "function (int256,int256) pure returns (int256)" } }, "id": 4503, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1953:44:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "src": "1930:67:6", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "id": 4505, "nodeType": "ExpressionStatement", "src": "1930:67:6" } ] }, "documentation": "@dev updated token conservation array.\n@param self internal datastructure created by TokenConservation.init()\n@param buyToken id of token whose imbalance should be subtracted from\n@param sellToken id of token whose imbalance should be added to\n@param tokenIdsForPrice sorted list of tokenIds\n@param buyAmount amount