@sonicswap/periphery
Version:
🎚 Peripheral smart contracts for interacting with the Sonicswap exchanges
1,011 lines (1,010 loc) • 639 kB
JSON
{
"contractName": "UniswapV2Library",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/var/www/Sonic/sonicswap-periphery/contracts/libraries/UniswapV2Library.sol\":\"UniswapV2Library\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/var/www/Sonic/sonicswap-periphery/contracts/libraries/SafeMath.sol\":{\"keccak256\":\"0x97845129a51dbb1869a765595d1c671fa473b97ef800756402afaadc7640a94e\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://5928803fe14654103d3f15b57b5b8df40b98f58cbe4e7044888f092f2462af04\",\"dweb:/ipfs/QmdnB83EBtNjwoKFHizxsTo6e2ytKN97SCvYnX28p75DCu\"]},\"/var/www/Sonic/sonicswap-periphery/contracts/libraries/UniswapV2Library.sol\":{\"keccak256\":\"0x97bae257510f91855e0f098176f8dbb967702f788492884bca5886dc1d1aec7d\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://310af80b5807f9ca7b8da55e529f44d41cd2f897511191f40d85d41e351bbeb4\",\"dweb:/ipfs/QmXMrQD79HZXN7JrHqNGYp3AKTSN7Kw8TjwrUw8Z33jFU6\"]},\"@sonicswap/core/contracts/interfaces/IUniswapV2Pair.sol\":{\"keccak256\":\"0xa87a1a8e9d72090e25812f396a9c0766a715dda52d8b6115ca0ab3f2a9c10f87\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://3b179da8f464eaa162ef0f9cfac56989d6fb5aa9667bebd23b355d93ea3ff10b\",\"dweb:/ipfs/QmcgYA55h3VJJRo7fFFNSDDDspdnJVTW83aH657v4E9bGZ\"]}},\"version\":1}",
"bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d27704ff65644fd9afcede206dcab204b5b1253e2bb65619dda60209db47e48664736f6c634300060c0033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d27704ff65644fd9afcede206dcab204b5b1253e2bb65619dda60209db47e48664736f6c634300060c0033",
"immutableReferences": {},
"sourceMap": "155:4333:16:-:0;;;;;;;;;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "155:4333:16:-:0;;;;;;;;",
"source": "// SPDX-License-Identifier: GPL-3.0\npragma solidity =0.6.12;\n\nimport '@sonicswap/core/contracts/interfaces/IUniswapV2Pair.sol';\n\nimport \"./SafeMath.sol\";\n\nlibrary UniswapV2Library {\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, 'UniswapV2Library: IDENTICAL_ADDRESSES');\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n require(token0 != address(0), 'UniswapV2Library: 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'4a8da68f30e6bab8a1cda432a2de48a79d41e83ccf07532497c0762037cdc0cb' // 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,) = IUniswapV2Pair(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, 'UniswapV2Library: INSUFFICIENT_AMOUNT');\n require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: 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, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');\n require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: 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, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');\n require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: 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, 'UniswapV2Library: 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, 'UniswapV2Library: 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": "/var/www/Sonic/sonicswap-periphery/contracts/libraries/UniswapV2Library.sol",
"ast": {
"absolutePath": "/var/www/Sonic/sonicswap-periphery/contracts/libraries/UniswapV2Library.sol",
"exportedSymbols": {
"UniswapV2Library": [
6080
]
},
"id": 6081,
"license": "GPL-3.0",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 5610,
"literals": [
"solidity",
"=",
"0.6",
".12"
],
"nodeType": "PragmaDirective",
"src": "36:24:16"
},
{
"absolutePath": "@sonicswap/core/contracts/interfaces/IUniswapV2Pair.sol",
"file": "@sonicswap/core/contracts/interfaces/IUniswapV2Pair.sol",
"id": 5611,
"nodeType": "ImportDirective",
"scope": 6081,
"sourceUnit": 8354,
"src": "62:65:16",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "/var/www/Sonic/sonicswap-periphery/contracts/libraries/SafeMath.sol",
"file": "./SafeMath.sol",
"id": 5612,
"nodeType": "ImportDirective",
"scope": 6081,
"sourceUnit": 5609,
"src": "129:24:16",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": null,
"fullyImplemented": true,
"id": 6080,
"linearizedBaseContracts": [
6080
],
"name": "UniswapV2Library",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 5615,
"libraryName": {
"contractScope": null,
"id": 5613,
"name": "SafeMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 5608,
"src": "192:8:16",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeMath_$5608",
"typeString": "library SafeMath"
}
},
"nodeType": "UsingForDirective",
"src": "186:24:16",
"typeName": {
"id": 5614,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "205:4:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"body": {
"id": 5658,
"nodeType": "Block",
"src": "423:238:16",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"id": 5629,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 5627,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5617,
"src": "441:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "BinaryOperation",
"operator": "!=",
"rightExpression": {
"argumentTypes": null,
"id": 5628,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5619,
"src": "451:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"src": "441:16:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "556e697377617056324c6962726172793a204944454e544943414c5f414444524553534553",
"id": 5630,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "459:39:16",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_4ddc3ca35a8b7ccaa016ab70252fdf3396ded4f4fd8375f95b1e9d99790fcdca",
"typeString": "literal_string \"UniswapV2Library: IDENTICAL_ADDRESSES\""
},
"value": "UniswapV2Library: IDENTICAL_ADDRESSES"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_4ddc3ca35a8b7ccaa016ab70252fdf3396ded4f4fd8375f95b1e9d99790fcdca",
"typeString": "literal_string \"UniswapV2Library: IDENTICAL_ADDRESSES\""
}
],
"id": 5626,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
-18,
-18
],
"referencedDeclaration": -18,
"src": "433:7:16",
"typeDescriptions": {
"typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$",
"typeString": "function (bool,string memory) pure"
}
},
"id": 5631,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "433:66:16",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 5632,
"nodeType": "ExpressionStatement",
"src": "433:66:16"
},
{
"expression": {
"argumentTypes": null,
"id": 5646,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"id": 5633,
"name": "token0",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5622,
"src": "510:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 5634,
"name": "token1",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5624,
"src": "518:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"id": 5635,
"isConstant": false,
"isInlineArray": false,
"isLValue": true,
"isPure": false,
"lValueRequested": true,
"nodeType": "TupleExpression",
"src": "509: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": 5638,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 5636,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5617,
"src": "528:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "BinaryOperation",
"operator": "<",
"rightExpression": {
"argumentTypes": null,
"id": 5637,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5619,
"src": "537:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"src": "528:15:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"id": 5642,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5619,
"src": "566:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 5643,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5617,
"src": "574:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"id": 5644,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "565:16:16",
"typeDescriptions": {
"typeIdentifier": "t_tuple$_t_address_$_t_address_$",
"typeString": "tuple(address,address)"
}
},
"id": 5645,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "Conditional",
"src": "528:53:16",
"trueExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"id": 5639,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5617,
"src": "547:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 5640,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5619,
"src": "555:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"id": 5641,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "546: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": "509:72:16",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 5647,
"nodeType": "ExpressionStatement",
"src": "509:72:16"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"id": 5654,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 5649,
"name": "token0",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5622,
"src": "599:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "BinaryOperation",
"operator": "!=",
"rightExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "30",
"id": 5652,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "617: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": 5651,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "609:7:16",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_address_$",
"typeString": "type(address)"
},
"typeName": {
"id": 5650,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "609:7:16",
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
}
}
},
"id": 5653,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "609:10:16",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
}
},
"src": "599:20:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "556e697377617056324c6962726172793a205a45524f5f41444452455353",
"id": 5655,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "621:32:16",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_db0dda5a73ac3122e17df097fa2cbce2c5161b45d20c7d6cf363d3b147392c83",
"typeString": "literal_string \"UniswapV2Library: ZERO_ADDRESS\""
},
"value": "UniswapV2Library: ZERO_ADDRESS"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_db0dda5a73ac3122e17df097fa2cbce2c5161b45d20c7d6cf363d3b147392c83",
"typeString": "literal_string \"UniswapV2Library: ZERO_ADDRESS\""
}
],
"id": 5648,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
-18,
-18
],
"referencedDeclaration": -18,
"src": "591:7:16",
"typeDescriptions": {
"typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$",
"typeString": "function (bool,string memory) pure"
}
},
"id": 5656,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "591:63:16",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 5657,
"nodeType": "ExpressionStatement",
"src": "591:63:16"
}
]
},
"documentation": null,
"id": 5659,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "sortTokens",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 5620,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 5617,
"mutability": "mutable",
"name": "tokenA",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5659,
"src": "336:14:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 5616,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "336:7:16",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 5619,
"mutability": "mutable",
"name": "tokenB",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5659,
"src": "352:14:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 5618,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "352:7:16",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "335:32:16"
},
"returnParameters": {
"id": 5625,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 5622,
"mutability": "mutable",
"name": "token0",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5659,
"src": "391:14:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 5621,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "391:7:16",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 5624,
"mutability": "mutable",
"name": "token1",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5659,
"src": "407:14:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 5623,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "407:7:16",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "390:32:16"
},
"scope": 6080,
"src": "316:345:16",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 5703,
"nodeType": "Block",
"src": "853:367:16",
"statements": [
{
"assignments": [
5671,
5673
],
"declarations": [
{
"constant": false,
"id": 5671,
"mutability": "mutable",
"name": "token0",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5703,
"src": "864:14:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 5670,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "864:7:16",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 5673,
"mutability": "mutable",
"name": "token1",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5703,
"src": "880:14:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 5672,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "880:7:16",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 5678,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 5675,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5663,
"src": "909:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 5676,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5665,
"src": "917:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
},
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 5674,
"name": "sortTokens",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5659,
"src": "898: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": 5677,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "898:26:16",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$_t_address_$_t_address_$",
"typeString": "tuple(address,address)"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "863:61:16"
},
{
"expression": {
"argumentTypes": null,
"id": 5701,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 5679,
"name": "pair",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5668,
"src": "934: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": 5687,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "998: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": 5688,
"name": "factory",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5661,
"src": "1023:7:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 5692,
"name": "token0",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5671,
"src": "1075:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 5693,
"name": "token1",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5673,
"src": "1083:6:16",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
},
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"expression": {
"argumentTypes": null,
"id": 5690,
"name": "abi",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": -1,
"src": "1058:3:16",
"typeDescriptions": {
"typeIdentifier": "t_magic_abi",
"typeString": "abi"
}
},
"id": 5691,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"memberName": "encodePacked",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "1058:16:16",
"typeDescriptions": {
"typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$",
"typeString": "function () pure returns (bytes memory)"