moonwalkerswap-v1-core
Version:
Moonwalkerswap v1 core
891 lines (890 loc) • 375 kB
JSON
{
"contractName": "SwapMath",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"Computes the result of a swap within ticks\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/SwapMath.sol\":\"SwapMath\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/FixedPoint96.sol\":{\"keccak256\":\"0xb466ea5c68592e0aab06e0ffa0937b047a2ec0916c2a181dee91f439e06c36d1\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://90e2d3770039b4430765a328d1abc6d035ad5a6e71906ab8f120220f3a9a9899\",\"dweb:/ipfs/QmTJFjBkBJGL98BjRnyH48yDZC94LU42SuuEPkd5qhgTnW\"]},\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/FullMath.sol\":{\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://bc5a6ae776be3e7dcbd23d49ffbc9d792fed0ddf4b111ebb64b9bb2133ec263e\",\"dweb:/ipfs/QmbAUtWqvipzEARQpFpkzYKBELy3qeW5WXnZxHFU84sxG7\"]},\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/LowGasSafeMath.sol\":{\"keccak256\":\"0xf2583083971cf8a4274e14515aabbf9f4855193e34fe2addb0ca7b1589519b0c\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://cbf0ada2bba8827d459101a2359e4682be749b9ddd0a3c44f26119c9a0898e82\",\"dweb:/ipfs/QmPmKotXLza9j7sjNaXSYY9XbyZhkkQ3nMeWE9tiHKeouC\"]},\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/SafeCast.sol\":{\"keccak256\":\"0x4a12ab60fdb663b341bb3a2f5c6631ba40b7b6fa9d131c9540b60dbb4196a27e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://d55e89b639f5ea027798cf3f246f38209308e812b8e568d19aa487bcdc8008a0\",\"dweb:/ipfs/QmfRWZGxKK21EgQea2PLxgJ6aypEbQjQSotHiruXGmKVm6\"]},\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/SqrtPriceMath.sol\":{\"keccak256\":\"0x4f69701d331d364b69a1cda77cd7b983a0079d36ae0e06b0bb1d64ae56c3705e\",\"license\":\"BUSL-1.1\",\"urls\":[\"bzz-raw://f9ed4f172da650484c97d31cce084e905e69c3f3b072141cb15363f4ed0cd03c\",\"dweb:/ipfs/QmPNDM667PxzbbR8YDbtibFaPMGrcbK71GKpFPkGgDEYvb\"]},\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/SwapMath.sol\":{\"keccak256\":\"0xcd310be830646d0d55bef86683847577f742704d227471ad7b4cab3df9c47cf7\",\"license\":\"BUSL-1.1\",\"urls\":[\"bzz-raw://e6029f7cbb62563f488ee9c4510fee69b5408b64119065d912c1bd682baeef84\",\"dweb:/ipfs/Qmed5zZvcEbqmDmkyGV2huNzrK3mk8KrF9UQohKWLTcc3n\"]},\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/UnsafeMath.sol\":{\"keccak256\":\"0x5f36d7d16348d8c37fe64fda932018d6e5e8acecd054f0f97d32db62d20c6c88\",\"license\":\"GPL-2.0-or-later\",\"urls\":[\"bzz-raw://4bd4e817ea3d2c26bb2be7e58db3eaa403119562c18d4c09cc92fb31aa231496\",\"dweb:/ipfs/QmbpjgL8Hf1mhmUyf9hpuPk4noGAggCdTqaRBFKqNF3AQw\"]}},\"version\":1}",
"bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212200774e267e47f9792f0641c4c634850f8e08ef1b6cf84e06c6eb7760fa3aa256964736f6c63430007060033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212200774e267e47f9792f0641c4c634850f8e08ef1b6cf84e06c6eb7760fa3aa256964736f6c63430007060033",
"immutableReferences": {},
"generatedSources": [],
"deployedGeneratedSources": [],
"sourceMap": "292:4340:27:-:0;;;;;;;;;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "292:4340:27:-:0;;;;;;;;",
"source": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.5.0;\n\nimport './FullMath.sol';\nimport './SqrtPriceMath.sol';\n\n/// @title Computes the result of a swap within ticks\n/// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\nlibrary SwapMath {\n /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap\n /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive\n /// @param sqrtRatioCurrentX96 The current sqrt price of the pool\n /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred\n /// @param liquidity The usable liquidity\n /// @param amountRemaining How much input or output amount is remaining to be swapped in/out\n /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip\n /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target\n /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap\n /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap\n /// @return feeAmount The amount of input that will be taken as a fee\n function computeSwapStep(\n uint160 sqrtRatioCurrentX96,\n uint160 sqrtRatioTargetX96,\n uint128 liquidity,\n int256 amountRemaining,\n uint24 feePips\n )\n internal\n pure\n returns (\n uint160 sqrtRatioNextX96,\n uint256 amountIn,\n uint256 amountOut,\n uint256 feeAmount\n )\n {\n bool zeroForOne = sqrtRatioCurrentX96 >= sqrtRatioTargetX96;\n bool exactIn = amountRemaining >= 0;\n\n if (exactIn) {\n uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);\n amountIn = zeroForOne\n ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);\n if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(\n sqrtRatioCurrentX96,\n liquidity,\n amountRemainingLessFee,\n zeroForOne\n );\n } else {\n amountOut = zeroForOne\n ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);\n if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(\n sqrtRatioCurrentX96,\n liquidity,\n uint256(-amountRemaining),\n zeroForOne\n );\n }\n\n bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;\n\n // get the input/output amounts\n if (zeroForOne) {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);\n } else {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);\n }\n\n // cap the output amount to not exceed the remaining output amount\n if (!exactIn && amountOut > uint256(-amountRemaining)) {\n amountOut = uint256(-amountRemaining);\n }\n\n if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {\n // we didn't reach the target, so take the remainder of the maximum input as fee\n feeAmount = uint256(amountRemaining) - amountIn;\n } else {\n feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);\n }\n }\n}\n",
"sourcePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/SwapMath.sol",
"ast": {
"absolutePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/SwapMath.sol",
"exportedSymbols": {
"FixedPoint96": [
3817
],
"FullMath": [
3990
],
"LowGasSafeMath": [
4172
],
"SafeCast": [
5150
],
"SqrtPriceMath": [
5666
],
"SwapMath": [
5927
],
"UnsafeMath": [
7237
]
},
"id": 5928,
"license": "BUSL-1.1",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 5668,
"literals": [
"solidity",
">=",
"0.5",
".0"
],
"nodeType": "PragmaDirective",
"src": "37:24:27"
},
{
"absolutePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/FullMath.sol",
"file": "./FullMath.sol",
"id": 5669,
"nodeType": "ImportDirective",
"scope": 5928,
"sourceUnit": 3991,
"src": "63:24:27",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/SqrtPriceMath.sol",
"file": "./SqrtPriceMath.sol",
"id": 5670,
"nodeType": "ImportDirective",
"scope": 5928,
"sourceUnit": 5667,
"src": "88:29:27",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": {
"id": 5671,
"nodeType": "StructuredDocumentation",
"src": "119:173:27",
"text": "@title Computes the result of a swap within ticks\n @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick."
},
"fullyImplemented": true,
"id": 5927,
"linearizedBaseContracts": [
5927
],
"name": "SwapMath",
"nodeType": "ContractDefinition",
"nodes": [
{
"body": {
"id": 5925,
"nodeType": "Block",
"src": "1769:2861:27",
"statements": [
{
"assignments": [
5694
],
"declarations": [
{
"constant": false,
"id": 5694,
"mutability": "mutable",
"name": "zeroForOne",
"nodeType": "VariableDeclaration",
"scope": 5925,
"src": "1779:15:27",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 5693,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "1779:4:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"visibility": "internal"
}
],
"id": 5698,
"initialValue": {
"commonType": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
},
"id": 5697,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"id": 5695,
"name": "sqrtRatioCurrentX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5674,
"src": "1797:19:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
"nodeType": "BinaryOperation",
"operator": ">=",
"rightExpression": {
"id": 5696,
"name": "sqrtRatioTargetX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5676,
"src": "1820:18:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
"src": "1797:41:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1779:59:27"
},
{
"assignments": [
5700
],
"declarations": [
{
"constant": false,
"id": 5700,
"mutability": "mutable",
"name": "exactIn",
"nodeType": "VariableDeclaration",
"scope": 5925,
"src": "1848:12:27",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 5699,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "1848:4:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"visibility": "internal"
}
],
"id": 5704,
"initialValue": {
"commonType": {
"typeIdentifier": "t_int256",
"typeString": "int256"
},
"id": 5703,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"id": 5701,
"name": "amountRemaining",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5680,
"src": "1863:15:27",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"nodeType": "BinaryOperation",
"operator": ">=",
"rightExpression": {
"hexValue": "30",
"id": 5702,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1882:1:27",
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "1863:20:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1848:35:27"
},
{
"condition": {
"id": 5705,
"name": "exactIn",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5700,
"src": "1898:7:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": {
"id": 5803,
"nodeType": "Block",
"src": "2629:619:27",
"statements": [
{
"expression": {
"id": 5775,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"id": 5758,
"name": "amountOut",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5689,
"src": "2643:9:27",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"condition": {
"id": 5759,
"name": "zeroForOne",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5694,
"src": "2655:10:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseExpression": {
"arguments": [
{
"id": 5769,
"name": "sqrtRatioCurrentX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5674,
"src": "2821:19:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
{
"id": 5770,
"name": "sqrtRatioTargetX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5676,
"src": "2842:18:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
{
"id": 5771,
"name": "liquidity",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5678,
"src": "2862:9:27",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
},
{
"hexValue": "66616c7365",
"id": 5772,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "bool",
"lValueRequested": false,
"nodeType": "Literal",
"src": "2873:5:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"value": "false"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint160",
"typeString": "uint160"
},
{
"typeIdentifier": "t_uint160",
"typeString": "uint160"
},
{
"typeIdentifier": "t_uint128",
"typeString": "uint128"
},
{
"typeIdentifier": "t_bool",
"typeString": "bool"
}
],
"expression": {
"id": 5767,
"name": "SqrtPriceMath",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5666,
"src": "2791:13:27",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_SqrtPriceMath_$5666_$",
"typeString": "type(library SqrtPriceMath)"
}
},
"id": 5768,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "getAmount0Delta",
"nodeType": "MemberAccess",
"referencedDeclaration": 5533,
"src": "2791:29:27",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint160_$_t_uint160_$_t_uint128_$_t_bool_$returns$_t_uint256_$",
"typeString": "function (uint160,uint160,uint128,bool) pure returns (uint256)"
}
},
"id": 5773,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2791:88:27",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 5774,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "Conditional",
"src": "2655:224:27",
"trueExpression": {
"arguments": [
{
"id": 5762,
"name": "sqrtRatioTargetX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5676,
"src": "2714:18:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
{
"id": 5763,
"name": "sqrtRatioCurrentX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5674,
"src": "2734:19:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
{
"id": 5764,
"name": "liquidity",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5678,
"src": "2755:9:27",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
},
{
"hexValue": "66616c7365",
"id": 5765,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "bool",
"lValueRequested": false,
"nodeType": "Literal",
"src": "2766:5:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"value": "false"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint160",
"typeString": "uint160"
},
{
"typeIdentifier": "t_uint160",
"typeString": "uint160"
},
{
"typeIdentifier": "t_uint128",
"typeString": "uint128"
},
{
"typeIdentifier": "t_bool",
"typeString": "bool"
}
],
"expression": {
"id": 5760,
"name": "SqrtPriceMath",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5666,
"src": "2684:13:27",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_SqrtPriceMath_$5666_$",
"typeString": "type(library SqrtPriceMath)"
}
},
"id": 5761,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "getAmount1Delta",
"nodeType": "MemberAccess",
"referencedDeclaration": 5581,
"src": "2684:29:27",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint160_$_t_uint160_$_t_uint128_$_t_bool_$returns$_t_uint256_$",
"typeString": "function (uint160,uint160,uint128,bool) pure returns (uint256)"
}
},
"id": 5766,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2684:88:27",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "2643:236:27",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 5776,
"nodeType": "ExpressionStatement",
"src": "2643:236:27"
},
{
"condition": {
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 5783,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"arguments": [
{
"id": 5780,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "UnaryOperation",
"operator": "-",
"prefix": true,
"src": "2905:16:27",
"subExpression": {
"id": 5779,
"name": "amountRemaining",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5680,
"src": "2906:15:27",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_int256",
"typeString": "int256"
}
],
"id": 5778,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "2897:7:27",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": {
"id": 5777,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "2897:7:27",
"typeDescriptions": {}
}
},
"id": 5781,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2897:25:27",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": ">=",
"rightExpression": {
"id": 5782,
"name": "amountOut",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5689,
"src": "2926:9:27",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "2897:38:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": {
"expression": {
"id": 5800,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"id": 5788,
"name": "sqrtRatioNextX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5685,
"src": "3009:16:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"arguments": [
{
"id": 5791,
"name": "sqrtRatioCurrentX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5674,
"src": "3090:19:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
{
"id": 5792,
"name": "liquidity",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5678,
"src": "3131:9:27",
"typeDescriptions": {
"typeIdentifier": "t_uint128",
"typeString": "uint128"
}
},
{
"arguments": [
{
"id": 5796,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "UnaryOperation",
"operator": "-",
"prefix": true,
"src": "3170:16:27",
"subExpression": {
"id": 5795,
"name": "amountRemaining",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5680,
"src": "3171:15:27",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_int256",
"typeString": "int256"
}
],
"id": 5794,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "3162:7:27",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": {
"id": 5793,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "3162:7:27",
"typeDescriptions": {}
}
},
"id": 5797,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "3162:25:27",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"id": 5798,
"name": "zeroForOne",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5694,
"src": "3209:10:27",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint160",
"typeString": "uint160"
},
{
"typeIdentifier": "t_uint128",
"typeString": "uint128"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
{
"typeIdentifier": "t_bool",
"typeString": "bool"
}
],
"expression": {
"id": 5789,
"name": "SqrtPriceMath",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5666,
"src": "3028:13:27",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_SqrtPriceMath_$5666_$",
"typeString": "type(library SqrtPriceMath)"
}
},
"id": 5790,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "getNextSqrtPriceFromOutput",
"nodeType": "MemberAccess",
"referencedDeclaration": 5463,
"src": "3028:40:27",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint160_$_t_uint128_$_t_uint256_$_t_bool_$returns$_t_uint160_$",
"typeString": "function (uint160,uint128,uint256,bool) pure returns (uint160)"
}
},
"id": 5799,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "3028:209:27",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
"src": "3009:228:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
"id": 5801,
"nodeType": "ExpressionStatement",
"src": "3009:228:27"
},
"id": 5802,
"nodeType": "IfStatement",
"src": "2893:344:27",
"trueBody": {
"expression": {
"id": 5786,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"id": 5784,
"name": "sqrtRatioNextX96",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5685,
"src": "2937:16:27",
"typeDescriptions": {
"typeIdentifier": "t_uint160",
"typeString": "uint160"
}
},
"nodeType": "Assignment",