@fleupold/dex-contracts
Version:
Contracts for dFusion multi-token batch auction exchange
1,059 lines • 287 kB
JSON
{
"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:5:-;;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:5:-;;;;;;;;",
"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": [
4498
]
},
"id": 4499,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 4250,
"literals": [
"solidity",
"^",
"0.5",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:23:5"
},
{
"absolutePath": "@openzeppelin/contracts/drafts/SignedSafeMath.sol",
"file": "@openzeppelin/contracts/drafts/SignedSafeMath.sol",
"id": 4251,
"nodeType": "ImportDirective",
"scope": 4499,
"sourceUnit": 8389,
"src": "25:59:5",
"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": 4498,
"linearizedBaseContracts": [
4498
],
"name": "TokenConservation",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 4254,
"libraryName": {
"contractScope": null,
"id": 4252,
"name": "SignedSafeMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8388,
"src": "358:14:5",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SignedSafeMath_$8388",
"typeString": "library SignedSafeMath"
}
},
"nodeType": "UsingForDirective",
"src": "352:32:5",
"typeName": {
"id": 4253,
"name": "int256",
"nodeType": "ElementaryTypeName",
"src": "377:6:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
}
},
{
"body": {
"id": 4272,
"nodeType": "Block",
"src": "650:65:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 4269,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 4266,
"name": "tokenIdsForPrice",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4257,
"src": "680:16:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint16_$dyn_memory_ptr",
"typeString": "uint16[] memory"
}
},
"id": 4267,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "length",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "680:23:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "+",
"rightExpression": {
"argumentTypes": null,
"hexValue": "31",
"id": 4268,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "706:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
},
"src": "680:27:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"id": 4265,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "NewExpression",
"src": "667:12:5",
"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": 4263,
"name": "int256",
"nodeType": "ElementaryTypeName",
"src": "671:6:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"id": 4264,
"length": null,
"nodeType": "ArrayTypeName",
"src": "671:8:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",
"typeString": "int256[]"
}
}
},
"id": 4270,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "667:41:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_memory",
"typeString": "int256[] memory"
}
},
"functionReturnParameters": 4262,
"id": 4271,
"nodeType": "Return",
"src": "660:48:5"
}
]
},
"documentation": "@dev initialize the token conservation data structure\n@param tokenIdsForPrice sorted list of tokenIds for which token conservation should be checked",
"id": 4273,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "init",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 4258,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 4257,
"name": "tokenIdsForPrice",
"nodeType": "VariableDeclaration",
"scope": 4273,
"src": "576:32:5",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint16_$dyn_memory_ptr",
"typeString": "uint16[]"
},
"typeName": {
"baseType": {
"id": 4255,
"name": "uint16",
"nodeType": "ElementaryTypeName",
"src": "576:6:5",
"typeDescriptions": {
"typeIdentifier": "t_uint16",
"typeString": "uint16"
}
},
"id": 4256,
"length": null,
"nodeType": "ArrayTypeName",
"src": "576:8:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint16_$dyn_storage_ptr",
"typeString": "uint16[]"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "575:34:5"
},
"returnParameters": {
"id": 4262,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 4261,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 4273,
"src": "633:15:5",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",
"typeString": "int256[]"
},
"typeName": {
"baseType": {
"id": 4259,
"name": "int256",
"nodeType": "ElementaryTypeName",
"src": "633:6:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"id": 4260,
"length": null,
"nodeType": "ArrayTypeName",
"src": "633:8:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",
"typeString": "int256[]"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "632:17:5"
},
"scope": 4498,
"src": "562:153:5",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 4285,
"nodeType": "Block",
"src": "945:31:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 4281,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4276,
"src": "962:4:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",
"typeString": "int256[] memory"
}
},
"id": 4283,
"indexExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 4282,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "967:1:5",
"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:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"functionReturnParameters": 4280,
"id": 4284,
"nodeType": "Return",
"src": "955:14:5"
}
]
},
"documentation": "@dev returns the token imbalance of the fee token\n@param self internal datastructure created by TokenConservation.init()",
"id": 4286,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "feeTokenImbalance",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 4277,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 4276,
"name": "self",
"nodeType": "VariableDeclaration",
"scope": 4286,
"src": "892:20:5",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",
"typeString": "int256[]"
},
"typeName": {
"baseType": {
"id": 4274,
"name": "int256",
"nodeType": "ElementaryTypeName",
"src": "892:6:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"id": 4275,
"length": null,
"nodeType": "ArrayTypeName",
"src": "892:8:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_storage_ptr",
"typeString": "int256[]"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "891:22:5"
},
"returnParameters": {
"id": 4280,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 4279,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 4286,
"src": "937:6:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
},
"typeName": {
"id": 4278,
"name": "int256",
"nodeType": "ElementaryTypeName",
"src": "937:6:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "936:8:5"
},
"scope": 4498,
"src": "865:111:5",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 4343,
"nodeType": "Block",
"src": "1692:312:5",
"statements": [
{
"assignments": [
4304
],
"declarations": [
{
"constant": false,
"id": 4304,
"name": "buyTokenIndex",
"nodeType": "VariableDeclaration",
"scope": 4343,
"src": "1702:21:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 4303,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1702:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 4309,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 4306,
"name": "buyToken",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4291,
"src": "1741:8:5",
"typeDescriptions": {
"typeIdentifier": "t_uint16",
"typeString": "uint16"
}
},
{
"argumentTypes": null,
"id": 4307,
"name": "tokenIdsForPrice",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4296,
"src": "1751:16:5",
"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": 4305,
"name": "findPriceIndex",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4497,
"src": "1726:14:5",
"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": 4308,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1726:42:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1702:66:5"
},
{
"assignments": [
4311
],
"declarations": [
{
"constant": false,
"id": 4311,
"name": "sellTokenIndex",
"nodeType": "VariableDeclaration",
"scope": 4343,
"src": "1778:22:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 4310,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1778:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 4316,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 4313,
"name": "sellToken",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4293,
"src": "1818:9:5",
"typeDescriptions": {
"typeIdentifier": "t_uint16",
"typeString": "uint16"
}
},
{
"argumentTypes": null,
"id": 4314,
"name": "tokenIdsForPrice",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4296,
"src": "1829:16:5",
"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": 4312,
"name": "findPriceIndex",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4497,
"src": "1803:14:5",
"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": 4315,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1803:43:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1778:68:5"
},
{
"expression": {
"argumentTypes": null,
"id": 4328,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 4317,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4289,
"src": "1856:4:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",
"typeString": "int256[] memory"
}
},
"id": 4319,
"indexExpression": {
"argumentTypes": null,
"id": 4318,
"name": "buyTokenIndex",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4304,
"src": "1861:13:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": true,
"nodeType": "IndexAccess",
"src": "1856:19:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 4325,
"name": "buyAmount",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4298,
"src": "1909:9:5",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
],
"id": 4324,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1902:6:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_int256_$",
"typeString": "type(int256)"
},
"typeName": "int256"
},
"id": 4326,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1902:17:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_int256",
"typeString": "int256"
}
],
"expression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 4320,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4289,
"src": "1878:4:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",
"typeString": "int256[] memory"
}
},
"id": 4322,
"indexExpression": {
"argumentTypes": null,
"id": 4321,
"name": "buyTokenIndex",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4304,
"src": "1883:13:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "1878:19:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"id": 4323,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "sub",
"nodeType": "MemberAccess",
"referencedDeclaration": 8348,
"src": "1878:23:5",
"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": 4327,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1878:42:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"src": "1856:64:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"id": 4329,
"nodeType": "ExpressionStatement",
"src": "1856:64:5"
},
{
"expression": {
"argumentTypes": null,
"id": 4341,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 4330,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4289,
"src": "1930:4:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",
"typeString": "int256[] memory"
}
},
"id": 4332,
"indexExpression": {
"argumentTypes": null,
"id": 4331,
"name": "sellTokenIndex",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4311,
"src": "1935:14:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": true,
"nodeType": "IndexAccess",
"src": "1930:20:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 4338,
"name": "sellAmount",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4300,
"src": "1985:10:5",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
],
"id": 4337,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1978:6:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_int256_$",
"typeString": "type(int256)"
},
"typeName": "int256"
},
"id": 4339,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1978:18:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_int256",
"typeString": "int256"
}
],
"expression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 4333,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4289,
"src": "1953:4:5",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_int256_$dyn_memory_ptr",
"typeString": "int256[] memory"
}
},
"id": 4335,
"indexExpression": {
"argumentTypes": null,
"id": 4334,
"name": "sellTokenIndex",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 4311,
"src": "1958:14:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "1953:20:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"id": 4336,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "add",
"nodeType": "MemberAccess",
"referencedDeclaration": 8387,
"src": "1953:24:5",
"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": 4340,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1953:44:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"src": "1930:67:5",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"id": 4342,
"nodeType": "ExpressionStatement",
"src": "1930:67:5"
}
]
},
"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