UNPKG

@windfallswap/periphery

Version:

🎚 Peripheral smart contracts for interacting with Windfall Swap

1,009 lines • 606 kB
{ "contractName": "WindfallLibrary", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/D/defi/windfall/windfallswap-periphery/contracts/libraries/WindfallLibrary.sol\":\"WindfallLibrary\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"/D/defi/windfall/windfallswap-periphery/contracts/libraries/SafeMath.sol\":{\"keccak256\":\"0x977f38b601109ee7a0c1b70a32e08b7aecf5b4672bdea39fa6b7fec810943b80\",\"urls\":[\"bzz-raw://50296b94e299cd690f4a7966a93ac6ac58128080b0a14fdb1c2e07d71b50930c\",\"dweb:/ipfs/QmSCqtcNbmcXUekQk2NYGDQcWt34sASe6ru1v2FLBX9coc\"]},\"/D/defi/windfall/windfallswap-periphery/contracts/libraries/WindfallLibrary.sol\":{\"keccak256\":\"0xef9f068e0d54b9983f422d53ef84a9ad5eddcd958b49d0f399098e22685256ff\",\"urls\":[\"bzz-raw://b10953e2c9840475757ca40e8d91cf4981be5f53373229d55dcfa12115dd9c8d\",\"dweb:/ipfs/QmXRTeceMcnouqwnCeLJ3hspiUTEusZHiQ1kyGpYyCKwL6\"]},\"@windfallswap/core/contracts/interfaces/IWindfallPair.sol\":{\"keccak256\":\"0x5ad5b5543c1f18cb9ad8d30196a8b77e5d0a1dff66a8c34b604d8f9a677b4304\",\"urls\":[\"bzz-raw://42362060f9a3b3c9c5d704093722d2511df7ff6db91c987a906f82c0e424843a\",\"dweb:/ipfs/QmWh7ZGPVmgHanrt3o3xe6UTraPJ3hZ3vuYXHvBKwXL5Z5\"]}},\"version\":1}", "bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220658cbf3595b598283649669ad47fbd97eef1a8de6624b506f5266baedf1b808564736f6c63430006060033", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220658cbf3595b598283649669ad47fbd97eef1a8de6624b506f5266baedf1b808564736f6c63430006060033", "immutableReferences": {}, "sourceMap": "127:4396:7:-: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": "127:4396:7:-:0;;;;;;12:1:-1;9;2:12", "source": "pragma solidity >=0.5.0;\r\n\r\nimport '@windfallswap/core/contracts/interfaces/IWindfallPair.sol';\r\n\r\nimport \"./SafeMath.sol\";\r\n\r\nlibrary WindfallLibrary {\r\n using SafeMath for uint;\r\n\r\n // returns sorted token addresses, used to handle return values from pairs sorted in this order\r\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\r\n require(tokenA != tokenB, 'WindfallLibrary: IDENTICAL_ADDRESSES');\r\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\r\n require(token0 != address(0), 'WindfallLibrary: ZERO_ADDRESS');\r\n }\r\n\r\n // calculates the CREATE2 address for a pair without making any external calls\r\n function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {\r\n (address token0, address token1) = sortTokens(tokenA, tokenB);\r\n pair = address(uint(keccak256(abi.encodePacked(\r\n hex'ff',\r\n factory,\r\n keccak256(abi.encodePacked(token0, token1)),\r\n hex'92e66f968597fe3a84c49d43531b5bbf4a321f86adc21174339ec9369e2aeda2' // init code hash\r\n ))));\r\n }\r\n\r\n // fetches and sorts the reserves for a pair\r\n function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {\r\n (address token0,) = sortTokens(tokenA, tokenB);\r\n (uint reserve0, uint reserve1,) = IWindfallPair(pairFor(factory, tokenA, tokenB)).getReserves();\r\n (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\r\n }\r\n\r\n // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset\r\n function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {\r\n require(amountA > 0, 'WindfallLibrary: INSUFFICIENT_AMOUNT');\r\n require(reserveA > 0 && reserveB > 0, 'WindfallLibrary: INSUFFICIENT_LIQUIDITY');\r\n amountB = amountA.mul(reserveB) / reserveA;\r\n }\r\n\r\n // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset\r\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {\r\n require(amountIn > 0, 'WindfallLibrary: INSUFFICIENT_INPUT_AMOUNT');\r\n require(reserveIn > 0 && reserveOut > 0, 'WindfallLibrary: INSUFFICIENT_LIQUIDITY');\r\n uint amountInWithFee = amountIn.mul(997);\r\n uint numerator = amountInWithFee.mul(reserveOut);\r\n uint denominator = reserveIn.mul(1000).add(amountInWithFee);\r\n amountOut = numerator / denominator;\r\n }\r\n\r\n // given an output amount of an asset and pair reserves, returns a required input amount of the other asset\r\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {\r\n require(amountOut > 0, 'WindfallLibrary: INSUFFICIENT_OUTPUT_AMOUNT');\r\n require(reserveIn > 0 && reserveOut > 0, 'WindfallLibrary: INSUFFICIENT_LIQUIDITY');\r\n uint numerator = reserveIn.mul(amountOut).mul(1000);\r\n uint denominator = reserveOut.sub(amountOut).mul(997);\r\n amountIn = (numerator / denominator).add(1);\r\n }\r\n\r\n // performs chained getAmountOut calculations on any number of pairs\r\n function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {\r\n require(path.length >= 2, 'WindfallLibrary: INVALID_PATH');\r\n amounts = new uint[](path.length);\r\n amounts[0] = amountIn;\r\n for (uint i; i < path.length - 1; i++) {\r\n (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);\r\n amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);\r\n }\r\n }\r\n\r\n // performs chained getAmountIn calculations on any number of pairs\r\n function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {\r\n require(path.length >= 2, 'WindfallLibrary: INVALID_PATH');\r\n amounts = new uint[](path.length);\r\n amounts[amounts.length - 1] = amountOut;\r\n for (uint i = path.length - 1; i > 0; i--) {\r\n (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);\r\n amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);\r\n }\r\n }\r\n}\r\n", "sourcePath": "D:\\defi\\windfall\\windfallswap-periphery\\contracts\\libraries\\WindfallLibrary.sol", "ast": { "absolutePath": "/D/defi/windfall/windfallswap-periphery/contracts/libraries/WindfallLibrary.sol", "exportedSymbols": { "WindfallLibrary": [ 3359 ] }, "id": 3360, "nodeType": "SourceUnit", "nodes": [ { "id": 2889, "literals": [ "solidity", ">=", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:24:7" }, { "absolutePath": "@windfallswap/core/contracts/interfaces/IWindfallPair.sol", "file": "@windfallswap/core/contracts/interfaces/IWindfallPair.sol", "id": 2890, "nodeType": "ImportDirective", "scope": 3360, "sourceUnit": 5153, "src": "28:67:7", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/D/defi/windfall/windfallswap-periphery/contracts/libraries/SafeMath.sol", "file": "./SafeMath.sol", "id": 2891, "nodeType": "ImportDirective", "scope": 3360, "sourceUnit": 2888, "src": "99:24:7", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 3359, "linearizedBaseContracts": [ 3359 ], "name": "WindfallLibrary", "nodeType": "ContractDefinition", "nodes": [ { "id": 2894, "libraryName": { "contractScope": null, "id": 2892, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 2887, "src": "164:8:7", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$2887", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "158:24:7", "typeName": { "id": 2893, "name": "uint", "nodeType": "ElementaryTypeName", "src": "177:4:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "body": { "id": 2937, "nodeType": "Block", "src": "398:240:7", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 2908, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 2906, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2896, "src": "417:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "id": 2907, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2898, "src": "427:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "src": "417:16:7", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "argumentTypes": null, "hexValue": "57696e6466616c6c4c6962726172793a204944454e544943414c5f414444524553534553", "id": 2909, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "435:38:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_6357c06e513d6e1a8065a6988204d2de484ed8a3ee5901f32ae7aeca6552b5a6", "typeString": "literal_string \"WindfallLibrary: IDENTICAL_ADDRESSES\"" }, "value": "WindfallLibrary: IDENTICAL_ADDRESSES" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_6357c06e513d6e1a8065a6988204d2de484ed8a3ee5901f32ae7aeca6552b5a6", "typeString": "literal_string \"WindfallLibrary: IDENTICAL_ADDRESSES\"" } ], "id": 2905, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ -18, -18 ], "referencedDeclaration": -18, "src": "409:7:7", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 2910, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "409:65:7", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 2911, "nodeType": "ExpressionStatement", "src": "409:65:7" }, { "expression": { "argumentTypes": null, "id": 2925, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "components": [ { "argumentTypes": null, "id": 2912, "name": "token0", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2901, "src": "486:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 2913, "name": "token1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2903, "src": "494:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 2914, "isConstant": false, "isInlineArray": false, "isLValue": true, "isPure": false, "lValueRequested": true, "nodeType": "TupleExpression", "src": "485:16:7", "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": 2917, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 2915, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2896, "src": "504:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "argumentTypes": null, "id": 2916, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2898, "src": "513:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "src": "504:15:7", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseExpression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "id": 2921, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2898, "src": "542:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 2922, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2896, "src": "550:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 2923, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "TupleExpression", "src": "541:16:7", "typeDescriptions": { "typeIdentifier": "t_tuple$_t_address_$_t_address_$", "typeString": "tuple(address,address)" } }, "id": 2924, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "Conditional", "src": "504:53:7", "trueExpression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "id": 2918, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2896, "src": "523:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 2919, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2898, "src": "531:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 2920, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "TupleExpression", "src": "522:16:7", "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": "485:72:7", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 2926, "nodeType": "ExpressionStatement", "src": "485:72:7" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 2933, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 2928, "name": "token0", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2901, "src": "576:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 2931, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "594:1:7", "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": 2930, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "586:7:7", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 2929, "name": "address", "nodeType": "ElementaryTypeName", "src": "586:7:7", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 2932, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "586:10:7", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "src": "576:20:7", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "argumentTypes": null, "hexValue": "57696e6466616c6c4c6962726172793a205a45524f5f41444452455353", "id": 2934, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "598:31:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_e3bf843b2ade867d560037772afb78216d986b77cfee93055286db9757f8d9f0", "typeString": "literal_string \"WindfallLibrary: ZERO_ADDRESS\"" }, "value": "WindfallLibrary: ZERO_ADDRESS" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_e3bf843b2ade867d560037772afb78216d986b77cfee93055286db9757f8d9f0", "typeString": "literal_string \"WindfallLibrary: ZERO_ADDRESS\"" } ], "id": 2927, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ -18, -18 ], "referencedDeclaration": -18, "src": "568:7:7", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 2935, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "568:62:7", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 2936, "nodeType": "ExpressionStatement", "src": "568:62:7" } ] }, "documentation": null, "id": 2938, "implemented": true, "kind": "function", "modifiers": [], "name": "sortTokens", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 2899, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 2896, "mutability": "mutable", "name": "tokenA", "nodeType": "VariableDeclaration", "overrides": null, "scope": 2938, "src": "311:14:7", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 2895, "name": "address", "nodeType": "ElementaryTypeName", "src": "311:7:7", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 2898, "mutability": "mutable", "name": "tokenB", "nodeType": "VariableDeclaration", "overrides": null, "scope": 2938, "src": "327:14:7", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 2897, "name": "address", "nodeType": "ElementaryTypeName", "src": "327:7:7", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "310:32:7" }, "returnParameters": { "id": 2904, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 2901, "mutability": "mutable", "name": "token0", "nodeType": "VariableDeclaration", "overrides": null, "scope": 2938, "src": "366:14:7", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 2900, "name": "address", "nodeType": "ElementaryTypeName", "src": "366:7:7", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 2903, "mutability": "mutable", "name": "token1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 2938, "src": "382:14:7", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 2902, "name": "address", "nodeType": "ElementaryTypeName", "src": "382:7:7", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "365:32:7" }, "scope": 3359, "src": "291:347:7", "stateMutability": "pure", "virtual": false, "visibility": "internal" }, { "body": { "id": 2982, "nodeType": "Block", "src": "833:375:7", "statements": [ { "assignments": [ 2950, 2952 ], "declarations": [ { "constant": false, "id": 2950, "mutability": "mutable", "name": "token0", "nodeType": "VariableDeclaration", "overrides": null, "scope": 2982, "src": "845:14:7", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 2949, "name": "address", "nodeType": "ElementaryTypeName", "src": "845:7:7", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 2952, "mutability": "mutable", "name": "token1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 2982, "src": "861:14:7", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 2951, "name": "address", "nodeType": "ElementaryTypeName", "src": "861:7:7", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "id": 2957, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 2954, "name": "tokenA", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2942, "src": "890:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 2955, "name": "tokenB", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2944, "src": "898:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 2953, "name": "sortTokens", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2938, "src": "879:10:7", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_address_$_t_address_$returns$_t_address_$_t_address_$", "typeString": "function (address,address) pure returns (address,address)" } }, "id": 2956, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "879:26:7", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$_t_address_$_t_address_$", "typeString": "tuple(address,address)" } }, "nodeType": "VariableDeclarationStatement", "src": "844:61:7" }, { "expression": { "argumentTypes": null, "id": 2980, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 2958, "name": "pair", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2947, "src": "916:4:7", "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": 2966, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "981:7:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9", "typeString": "literal_string (contains invalid UTF-8 sequence at position 0)" }, "value": null }, { "argumentTypes": null, "id": 2967, "name": "factory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2940, "src": "1007:7:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 2971, "name": "token0", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2950, "src": "1060:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 2972, "name": "token1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2952, "src": "1068:6:7", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_address", "typeString": "address" } ], "expression": { "argumentTypes": null, "id": 2969, "name": "abi", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -1, "src": "1043:3:7", "typeDescriptions": { "typeIdentifier": "t_magic_abi", "typeString": "abi" } }, "id": 2970, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "memberName": "encodePacked", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "1043:16:7", "typeDescriptions": { "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", "typeString": "function () pure re