@sonicxchain/soxswap-periphery
Version:
Peripheral smart contracts for interacting with Soxswap
1,078 lines (1,077 loc) • 574 kB
JSON
{
"contractName": "SoxswapLibrary",
"abi": [],
"bytecode": "0x604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a723058209c598181eb6d80b2b3356a8879d34adecbe83fb762de02060324dd62581462fd0029",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a723058209c598181eb6d80b2b3356a8879d34adecbe83fb762de02060324dd62581462fd0029",
"sourceMap": "220:4236:5:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24",
"deployedSourceMap": "220:4236:5:-;;;;;;;;",
"source": "pragma solidity >=0.4.23 <0.6.0;\r\n\r\nimport '@sonicxchain/soxswap-core/contracts/interfaces/ISoxswapFactory.sol';\r\nimport '@sonicxchain/soxswap-core/contracts/interfaces/ISoxswapPair.sol';\r\n\r\nimport \"./SafeMath2.sol\";\r\n\r\nlibrary SoxswapLibrary {\r\n using SafeMath2 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, 'SoxswapLibrary: IDENTICAL_ADDRESSES');\r\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\r\n require(token0 != address(0), 'SoxswapLibrary: 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 view returns (address payable pair) {\r\n address pairAddress = ISoxswapFactory(factory).getPair(tokenA, tokenB);\r\n require(pairAddress != address(0), 'SoxswapLibrary: ZERO_PAIR_ADDRESS');\r\n return address(uint160(pairAddress));\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,) = ISoxswapPair(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, 'SoxswapLibrary: INSUFFICIENT_AMOUNT');\r\n require(reserveA > 0 && reserveB > 0, 'SoxswapLibrary: 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, 'SoxswapLibrary: INSUFFICIENT_INPUT_AMOUNT');\r\n require(reserveIn > 0 && reserveOut > 0, 'SoxswapLibrary: 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, 'SoxswapLibrary: INSUFFICIENT_OUTPUT_AMOUNT');\r\n require(reserveIn > 0 && reserveOut > 0, 'SoxswapLibrary: 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, 'SoxswapLibrary: 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, 'SoxswapLibrary: 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:\\40_SonicX_DEX\\soxswap-periphery\\contracts\\libraries\\SoxswapLibrary.sol",
"ast": {
"absolutePath": "/D/40_SonicX_DEX/soxswap-periphery/contracts/libraries/SoxswapLibrary.sol",
"exportedSymbols": {
"SoxswapLibrary": [
3043
]
},
"id": 3044,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 2581,
"literals": [
"solidity",
">=",
"0.4",
".23",
"<",
"0.6",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:32:5"
},
{
"absolutePath": "@sonicxchain/soxswap-core/contracts/interfaces/ISoxswapFactory.sol",
"file": "@sonicxchain/soxswap-core/contracts/interfaces/ISoxswapFactory.sol",
"id": 2582,
"nodeType": "ImportDirective",
"scope": 3044,
"sourceUnit": 3275,
"src": "36:76:5",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@sonicxchain/soxswap-core/contracts/interfaces/ISoxswapPair.sol",
"file": "@sonicxchain/soxswap-core/contracts/interfaces/ISoxswapPair.sol",
"id": 2583,
"nodeType": "ImportDirective",
"scope": 3044,
"sourceUnit": 3517,
"src": "114:73:5",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "/D/40_SonicX_DEX/soxswap-periphery/contracts/libraries/SafeMath2.sol",
"file": "./SafeMath2.sol",
"id": 2584,
"nodeType": "ImportDirective",
"scope": 3044,
"sourceUnit": 2580,
"src": "191:25:5",
"symbolAliases": [],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": null,
"fullyImplemented": true,
"id": 3043,
"linearizedBaseContracts": [
3043
],
"name": "SoxswapLibrary",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 2587,
"libraryName": {
"contractScope": null,
"id": 2585,
"name": "SafeMath2",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 2579,
"src": "256:9:5",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeMath2_$2579",
"typeString": "library SafeMath2"
}
},
"nodeType": "UsingForDirective",
"src": "250:25:5",
"typeName": {
"id": 2586,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "270:4:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"body": {
"id": 2629,
"nodeType": "Block",
"src": "491:238:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"id": 2601,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 2599,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2589,
"src": "510:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "BinaryOperation",
"operator": "!=",
"rightExpression": {
"argumentTypes": null,
"id": 2600,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2591,
"src": "520:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"src": "510:16:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "536f78737761704c6962726172793a204944454e544943414c5f414444524553534553",
"id": 2602,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "528:37:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_faaa31946cda3af27db3af35a446c465fca139873a0eb3322e31a6eba5567f8f",
"typeString": "literal_string \"SoxswapLibrary: IDENTICAL_ADDRESSES\""
},
"value": "SoxswapLibrary: IDENTICAL_ADDRESSES"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_faaa31946cda3af27db3af35a446c465fca139873a0eb3322e31a6eba5567f8f",
"typeString": "literal_string \"SoxswapLibrary: IDENTICAL_ADDRESSES\""
}
],
"id": 2598,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
4577,
4578
],
"referencedDeclaration": 4578,
"src": "502:7:5",
"typeDescriptions": {
"typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$",
"typeString": "function (bool,string memory) pure"
}
},
"id": 2603,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "502:64:5",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 2604,
"nodeType": "ExpressionStatement",
"src": "502:64:5"
},
{
"expression": {
"argumentTypes": null,
"id": 2618,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"id": 2605,
"name": "token0",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2594,
"src": "578:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 2606,
"name": "token1",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2596,
"src": "586:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"id": 2607,
"isConstant": false,
"isInlineArray": false,
"isLValue": true,
"isPure": false,
"lValueRequested": true,
"nodeType": "TupleExpression",
"src": "577:16:5",
"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": 2610,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 2608,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2589,
"src": "596:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "BinaryOperation",
"operator": "<",
"rightExpression": {
"argumentTypes": null,
"id": 2609,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2591,
"src": "605:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"src": "596:15:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"id": 2614,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2591,
"src": "634:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 2615,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2589,
"src": "642:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"id": 2616,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "633:16:5",
"typeDescriptions": {
"typeIdentifier": "t_tuple$_t_address_$_t_address_$",
"typeString": "tuple(address,address)"
}
},
"id": 2617,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "Conditional",
"src": "596:53:5",
"trueExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"id": 2611,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2589,
"src": "615:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 2612,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2591,
"src": "623:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"id": 2613,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "614:16:5",
"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": "577:72:5",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 2619,
"nodeType": "ExpressionStatement",
"src": "577:72:5"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"id": 2625,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 2621,
"name": "token0",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2594,
"src": "668:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "BinaryOperation",
"operator": "!=",
"rightExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "30",
"id": 2623,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "686:1:5",
"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": 2622,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "678:7:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_address_$",
"typeString": "type(address)"
},
"typeName": "address"
},
"id": 2624,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "678:10:5",
"typeDescriptions": {
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
}
},
"src": "668:20:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "536f78737761704c6962726172793a205a45524f5f41444452455353",
"id": 2626,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "690:30:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_5899e358313fb78c04b6845e59222ca49afbbc28fcc4ec0d8d984cb4835a8483",
"typeString": "literal_string \"SoxswapLibrary: ZERO_ADDRESS\""
},
"value": "SoxswapLibrary: ZERO_ADDRESS"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_5899e358313fb78c04b6845e59222ca49afbbc28fcc4ec0d8d984cb4835a8483",
"typeString": "literal_string \"SoxswapLibrary: ZERO_ADDRESS\""
}
],
"id": 2620,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
4577,
4578
],
"referencedDeclaration": 4578,
"src": "660:7:5",
"typeDescriptions": {
"typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$",
"typeString": "function (bool,string memory) pure"
}
},
"id": 2627,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "660:61:5",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 2628,
"nodeType": "ExpressionStatement",
"src": "660:61:5"
}
]
},
"documentation": null,
"id": 2630,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "sortTokens",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 2592,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 2589,
"name": "tokenA",
"nodeType": "VariableDeclaration",
"scope": 2630,
"src": "404:14:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 2588,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "404:7:5",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 2591,
"name": "tokenB",
"nodeType": "VariableDeclaration",
"scope": 2630,
"src": "420:14:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 2590,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "420:7:5",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "403:32:5"
},
"returnParameters": {
"id": 2597,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 2594,
"name": "token0",
"nodeType": "VariableDeclaration",
"scope": 2630,
"src": "459:14:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 2593,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "459:7:5",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 2596,
"name": "token1",
"nodeType": "VariableDeclaration",
"scope": 2630,
"src": "475:14:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 2595,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "475:7:5",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "458:32:5"
},
"scope": 3043,
"src": "384:345:5",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 2666,
"nodeType": "Block",
"src": "932:218:5",
"statements": [
{
"assignments": [
2642
],
"declarations": [
{
"constant": false,
"id": 2642,
"name": "pairAddress",
"nodeType": "VariableDeclaration",
"scope": 2666,
"src": "943:19:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 2641,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "943:7:5",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 2650,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 2647,
"name": "tokenA",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2634,
"src": "998:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 2648,
"name": "tokenB",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2636,
"src": "1006:6:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
},
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 2644,
"name": "factory",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2632,
"src": "981:7:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 2643,
"name": "ISoxswapFactory",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3274,
"src": "965:15:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_ISoxswapFactory_$3274_$",
"typeString": "type(contract ISoxswapFactory)"
}
},
"id": 2645,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "965:24:5",
"typeDescriptions": {
"typeIdentifier": "t_contract$_ISoxswapFactory_$3274",
"typeString": "contract ISoxswapFactory"
}
},
"id": 2646,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "getPair",
"nodeType": "MemberAccess",
"referencedDeclaration": 3178,
"src": "965:32:5",
"typeDescriptions": {
"typeIdentifier": "t_function_external_view$_t_address_$_t_address_$returns$_t_address_$",
"typeString": "function (address,address) view external returns (address)"
}
},
"id": 2649,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "965:48:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "943:70:5"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"id": 2656,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 2652,
"name": "pairAddress",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2642,
"src": "1032:11:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "BinaryOperation",
"operator": "!=",
"rightExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "30",
"id": 2654,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1055:1:5",
"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": 2653,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1047:7:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_address_$",
"typeString": "type(address)"
},
"typeName": "address"
},
"id": 2655,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1047:10:5",
"typeDescriptions": {
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
}
},
"src": "1032:25:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "536f78737761704c6962726172793a205a45524f5f504149525f41444452455353",
"id": 2657,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1059:35:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_fbd70614ab24d7d2480c670767cc2dd4866a45cb7ec0aeae6559dd8b1ad5915b",
"typeString": "literal_string \"SoxswapLibrary: ZERO_PAIR_ADDRESS\""
},
"value": "SoxswapLibrary: ZERO_PAIR_ADDRESS"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_fbd70614ab24d7d2480c670767cc2dd4866a45cb7ec0aeae6559dd8b1ad5915b",
"typeString": "literal_string \"SoxswapLibrary: ZERO_PAIR_ADDRESS\""
}
],
"id": 2651,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
4577,
4578
],
"referencedDeclaration": 4578,
"src": "1024:7:5",
"typeDescriptions": {
"typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$",
"typeString": "function (bool,string memory) pure"
}
},
"id": 2658,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1024:71:5",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 2659,
"nodeType": "ExpressionStatement",
"src": "1024:71:5"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 2662,
"name": "pairAddress",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2642,
"src": "1129:11:5",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 2661,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1121:7:5",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint160_$",
"typeString": "type(uint160)"
},
"typeName": "uint160"