UNPKG

@valueswap/v2-periphery

Version:

🎚 Peripheral smart contracts for interacting with Valueswap V2

1,009 lines (1,008 loc) • 639 kB
{ "contractName": "ValueswapV2Library", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2Library.sol\":\"ValueswapV2Library\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/SafeMath.sol\":{\"keccak256\":\"0x27f0ea82f879b3b01387b583e6d9d0ec858dca3b22b0aad173f8fbda06e761e1\",\"urls\":[\"bzz-raw://0db9cf37793eb7035f0bfced36323d240f0212150009c39a3a108701d9b50b6c\",\"dweb:/ipfs/QmUAdiG9XNcieXkKfiMB49zQqD34FbXFE15csV2KQzwEqg\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2Library.sol\":{\"keccak256\":\"0xf676dcf67bcef334c141c95ae2c8328c76bcaf316edd882fe9bf960dc7887904\",\"urls\":[\"bzz-raw://37aa805cf7db173d7465a186acb5d9a958c8d1628c2335807c054e7864501dc5\",\"dweb:/ipfs/QmbZhcmRJkPLzsfMoNbeRZ8UKrqsjF86QNiZjsYyfxg9t6\"]},\"@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol\":{\"keccak256\":\"0x4899f60670cbc336cd8f5fefb631d6ce27ae4226ad4aac5d0963cd23db2fc36a\",\"urls\":[\"bzz-raw://7aa68c3572d1a4713c4af9ba99dd1907a9dc5a104273dab86e1d02797f6b1dd6\",\"dweb:/ipfs/QmXq89Vb6D4XeA2PDqNy13VkNeevTJePCrLF7KUHkver4q\"]}},\"version\":1}", "bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220e5a2b0f9c79db1b2a9eff023db73c1a3eaa747a86821714080daf8f5076ae5f164736f6c63430006060033", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220e5a2b0f9c79db1b2a9eff023db73c1a3eaa747a86821714080daf8f5076ae5f164736f6c63430006060033", "immutableReferences": {}, "sourceMap": "124:4357:16:-:0;;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": "124:4357:16:-:0;;;;;;12:1:-1;9;2:12", "source": "pragma solidity >=0.5.0;\n\nimport '@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol';\n\nimport \"./SafeMath.sol\";\n\nlibrary ValueswapV2Library {\n using SafeMath for uint;\n\n // returns sorted token addresses, used to handle return values from pairs sorted in this order\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\n require(tokenA != tokenB, 'ValueswapV2Library: IDENTICAL_ADDRESSES');\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n require(token0 != address(0), 'ValueswapV2Library: ZERO_ADDRESS');\n }\n\n // calculates the CREATE2 address for a pair without making any external calls\n function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {\n (address token0, address token1) = sortTokens(tokenA, tokenB);\n pair = address(uint(keccak256(abi.encodePacked(\n hex'ff',\n factory,\n keccak256(abi.encodePacked(token0, token1)),\n hex'f27fee3fc000c2148077e3c1de2bfc88ca0e8881a5c9fbb18615dc16f0cc1b75' // INIT_CODE_HASH\n ))));\n }\n\n // fetches and sorts the reserves for a pair\n function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {\n (address token0,) = sortTokens(tokenA, tokenB);\n (uint reserve0, uint reserve1,) = IValueswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();\n (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\n }\n\n // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset\n function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {\n require(amountA > 0, 'ValueswapV2Library: INSUFFICIENT_AMOUNT');\n require(reserveA > 0 && reserveB > 0, 'ValueswapV2Library: INSUFFICIENT_LIQUIDITY');\n amountB = amountA.mul(reserveB) / reserveA;\n }\n\n // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {\n require(amountIn > 0, 'ValueswapV2Library: INSUFFICIENT_INPUT_AMOUNT');\n require(reserveIn > 0 && reserveOut > 0, 'ValueswapV2Library: INSUFFICIENT_LIQUIDITY');\n uint amountInWithFee = amountIn.mul(997);\n uint numerator = amountInWithFee.mul(reserveOut);\n uint denominator = reserveIn.mul(1000).add(amountInWithFee);\n amountOut = numerator / denominator;\n }\n\n // given an output amount of an asset and pair reserves, returns a required input amount of the other asset\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {\n require(amountOut > 0, 'ValueswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');\n require(reserveIn > 0 && reserveOut > 0, 'ValueswapV2Library: INSUFFICIENT_LIQUIDITY');\n uint numerator = reserveIn.mul(amountOut).mul(1000);\n uint denominator = reserveOut.sub(amountOut).mul(997);\n amountIn = (numerator / denominator).add(1);\n }\n\n // performs chained getAmountOut calculations on any number of pairs\n function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {\n require(path.length >= 2, 'ValueswapV2Library: INVALID_PATH');\n amounts = new uint[](path.length);\n amounts[0] = amountIn;\n for (uint i; i < path.length - 1; i++) {\n (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);\n amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);\n }\n }\n\n // performs chained getAmountIn calculations on any number of pairs\n function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {\n require(path.length >= 2, 'ValueswapV2Library: INVALID_PATH');\n amounts = new uint[](path.length);\n amounts[amounts.length - 1] = amountOut;\n for (uint i = path.length - 1; i > 0; i--) {\n (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);\n amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);\n }\n }\n}\n", "sourcePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2Library.sol", "ast": { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2Library.sol", "exportedSymbols": { "ValueswapV2Library": [ 6053 ] }, "id": 6054, "nodeType": "SourceUnit", "nodes": [ { "id": 5583, "literals": [ "solidity", ">=", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:24:16" }, { "absolutePath": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol", "file": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol", "id": 5584, "nodeType": "ImportDirective", "scope": 6054, "sourceUnit": 9359, "src": "26:70:16", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/SafeMath.sol", "file": "./SafeMath.sol", "id": 5585, "nodeType": "ImportDirective", "scope": 6054, "sourceUnit": 5582, "src": "98:24:16", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 6053, "linearizedBaseContracts": [ 6053 ], "name": "ValueswapV2Library", "nodeType": "ContractDefinition", "nodes": [ { "id": 5588, "libraryName": { "contractScope": null, "id": 5586, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5581, "src": "163:8:16", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$5581", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "157:24:16", "typeName": { "id": 5587, "name": "uint", "nodeType": "ElementaryTypeName", "src": "176:4:16", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "body": { "id": 5631, "nodeType": "Block", "src": "394:242:16", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 5602, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 5600, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5590, "src": "412:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "id": 5601, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5592, "src": "422:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "src": "412:16:16", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "argumentTypes": null, "hexValue": "56616c75657377617056324c6962726172793a204944454e544943414c5f414444524553534553", "id": 5603, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "430:41:16", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_b0baea2242c77d09eb2d8f3709018a7bb0af7d4f92e8f9b6f688b1cfc22914f5", "typeString": "literal_string \"ValueswapV2Library: IDENTICAL_ADDRESSES\"" }, "value": "ValueswapV2Library: IDENTICAL_ADDRESSES" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_b0baea2242c77d09eb2d8f3709018a7bb0af7d4f92e8f9b6f688b1cfc22914f5", "typeString": "literal_string \"ValueswapV2Library: IDENTICAL_ADDRESSES\"" } ], "id": 5599, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ -18, -18 ], "referencedDeclaration": -18, "src": "404:7:16", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 5604, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "404:68:16", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 5605, "nodeType": "ExpressionStatement", "src": "404:68:16" }, { "expression": { "argumentTypes": null, "id": 5619, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "components": [ { "argumentTypes": null, "id": 5606, "name": "token0", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5595, "src": "483:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 5607, "name": "token1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5597, "src": "491:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 5608, "isConstant": false, "isInlineArray": false, "isLValue": true, "isPure": false, "lValueRequested": true, "nodeType": "TupleExpression", "src": "482:16:16", "typeDescriptions": { "typeIdentifier": "t_tuple$_t_address_$_t_address_$", "typeString": "tuple(address,address)" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 5611, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 5609, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5590, "src": "501:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "argumentTypes": null, "id": 5610, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5592, "src": "510:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "src": "501:15:16", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseExpression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "id": 5615, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5592, "src": "539:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 5616, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5590, "src": "547:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 5617, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "TupleExpression", "src": "538:16:16", "typeDescriptions": { "typeIdentifier": "t_tuple$_t_address_$_t_address_$", "typeString": "tuple(address,address)" } }, "id": 5618, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "Conditional", "src": "501:53:16", "trueExpression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "id": 5612, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5590, "src": "520:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 5613, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5592, "src": "528:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 5614, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "TupleExpression", "src": "519:16:16", "typeDescriptions": { "typeIdentifier": "t_tuple$_t_address_$_t_address_$", "typeString": "tuple(address,address)" } }, "typeDescriptions": { "typeIdentifier": "t_tuple$_t_address_$_t_address_$", "typeString": "tuple(address,address)" } }, "src": "482:72:16", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 5620, "nodeType": "ExpressionStatement", "src": "482:72:16" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 5627, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 5622, "name": "token0", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5595, "src": "572:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 5625, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "590:1:16", "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": 5624, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "582:7:16", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 5623, "name": "address", "nodeType": "ElementaryTypeName", "src": "582:7:16", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 5626, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "582:10:16", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "src": "572:20:16", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "argumentTypes": null, "hexValue": "56616c75657377617056324c6962726172793a205a45524f5f41444452455353", "id": 5628, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "594:34:16", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_f866989a66d3c1669b71cec190ba50c394dbd25a40a0684ccf65ebf0071a1583", "typeString": "literal_string \"ValueswapV2Library: ZERO_ADDRESS\"" }, "value": "ValueswapV2Library: ZERO_ADDRESS" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_f866989a66d3c1669b71cec190ba50c394dbd25a40a0684ccf65ebf0071a1583", "typeString": "literal_string \"ValueswapV2Library: ZERO_ADDRESS\"" } ], "id": 5621, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ -18, -18 ], "referencedDeclaration": -18, "src": "564:7:16", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 5629, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "564:65:16", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 5630, "nodeType": "ExpressionStatement", "src": "564:65:16" } ] }, "documentation": null, "id": 5632, "implemented": true, "kind": "function", "modifiers": [], "name": "sortTokens", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 5593, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5590, "mutability": "mutable", "name": "tokenA", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5632, "src": "307:14:16", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5589, "name": "address", "nodeType": "ElementaryTypeName", "src": "307:7:16", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 5592, "mutability": "mutable", "name": "tokenB", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5632, "src": "323:14:16", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5591, "name": "address", "nodeType": "ElementaryTypeName", "src": "323:7:16", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "306:32:16" }, "returnParameters": { "id": 5598, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5595, "mutability": "mutable", "name": "token0", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5632, "src": "362:14:16", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5594, "name": "address", "nodeType": "ElementaryTypeName", "src": "362:7:16", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 5597, "mutability": "mutable", "name": "token1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5632, "src": "378:14:16", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5596, "name": "address", "nodeType": "ElementaryTypeName", "src": "378:7:16", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "361:32:16" }, "scope": 6053, "src": "287:349:16", "stateMutability": "pure", "virtual": false, "visibility": "internal" }, { "body": { "id": 5676, "nodeType": "Block", "src": "828:367:16", "statements": [ { "assignments": [ 5644, 5646 ], "declarations": [ { "constant": false, "id": 5644, "mutability": "mutable", "name": "token0", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5676, "src": "839:14:16", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5643, "name": "address", "nodeType": "ElementaryTypeName", "src": "839:7:16", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 5646, "mutability": "mutable", "name": "token1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 5676, "src": "855:14:16", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5645, "name": "address", "nodeType": "ElementaryTypeName", "src": "855:7:16", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "id": 5651, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 5648, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5636, "src": "884:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 5649, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5638, "src": "892:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 5647, "name": "sortTokens", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5632, "src": "873:10:16", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_address_$_t_address_$returns$_t_address_$_t_address_$", "typeString": "function (address,address) pure returns (address,address)" } }, "id": 5650, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "873:26:16", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$_t_address_$_t_address_$", "typeString": "tuple(address,address)" } }, "nodeType": "VariableDeclarationStatement", "src": "838:61:16" }, { "expression": { "argumentTypes": null, "id": 5674, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 5652, "name": "pair", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5641, "src": "909:4:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "ff", "id": 5660, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "973:7:16", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9", "typeString": "literal_string (contains invalid UTF-8 sequence at position 0)" }, "value": null }, { "argumentTypes": null, "id": 5661, "name": "factory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5634, "src": "998:7:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 5665, "name": "token0", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5644, "src": "1050:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 5666, "name": "token1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5646, "src": "1058:6:16", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_address", "typeString": "address" } ], "expression": { "argumentTypes": null, "id": 5663, "name": "abi", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -1, "src": "1033:3:16", "typeDescriptions": { "typeIdentifier": "t_magic_abi", "typeString": "abi" } }, "id": 5664, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "memberName": "encodePacked", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "1033:16:16", "typeDescriptions": { "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$",