UNPKG

moonwalkerswap-v1-core

Version:
1,045 lines (1,044 loc) 73.2 kB
{ "contractName": "LiquidityMath", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"Math library for liquidity\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/LiquidityMath.sol\":\"LiquidityMath\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/LiquidityMath.sol\":{\"keccak256\":\"0x2fcb84bece328675849d09dee9439901fd14c852efa2cb84a7dd1ada04a90a1e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ce303eb639ca62f247a8a49a65f15b25b931fbd64b176c2180a6ea790f99bb11\",\"dweb:/ipfs/QmXehfxvPATibRJ2JWWBnLbDyA7hMk5jWCxidpJfDKGQVD\"]}},\"version\":1}", "bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122056be4d48aabc504ec4c5a34b2aae0b37f268a067e54efd6c6cdb9d62ae9c7b9964736f6c63430007060033", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122056be4d48aabc504ec4c5a34b2aae0b37f268a067e54efd6c6cdb9d62ae9c7b9964736f6c63430007060033", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "96:512:21:-:0;;;;;;;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "96:512:21:-:0;;;;;;;;", "source": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math library for liquidity\nlibrary LiquidityMath {\n /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\n /// @param x The liquidity before change\n /// @param y The delta by which liquidity should be changed\n /// @return z The liquidity delta\n function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {\n if (y < 0) {\n require((z = x - uint128(-y)) < x, 'LS');\n } else {\n require((z = x + uint128(y)) >= x, 'LA');\n }\n }\n}\n", "sourcePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/LiquidityMath.sol", "ast": { "absolutePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/LiquidityMath.sol", "exportedSymbols": { "LiquidityMath": [ 4042 ] }, "id": 4043, "license": "MIT", "nodeType": "SourceUnit", "nodes": [ { "id": 3992, "literals": [ "solidity", ">=", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "32:24:21" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": { "id": 3993, "nodeType": "StructuredDocumentation", "src": "58:38:21", "text": "@title Math library for liquidity" }, "fullyImplemented": true, "id": 4042, "linearizedBaseContracts": [ 4042 ], "name": "LiquidityMath", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 4040, "nodeType": "Block", "src": "443:163:21", "statements": [ { "condition": { "commonType": { "typeIdentifier": "t_int128", "typeString": "int128" }, "id": 4005, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 4003, "name": "y", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3998, "src": "457:1:21", "typeDescriptions": { "typeIdentifier": "t_int128", "typeString": "int128" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "hexValue": "30", "id": 4004, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "461:1:21", "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "457:5:21", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": { "id": 4038, "nodeType": "Block", "src": "535:65:21", "statements": [ { "expression": { "arguments": [ { "commonType": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "id": 4034, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "components": [ { "id": 4031, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "id": 4024, "name": "z", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4001, "src": "558:1:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "commonType": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "id": 4030, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 4025, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3996, "src": "562:1:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "nodeType": "BinaryOperation", "operator": "+", "rightExpression": { "arguments": [ { "id": 4028, "name": "y", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3998, "src": "574:1:21", "typeDescriptions": { "typeIdentifier": "t_int128", "typeString": "int128" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int128", "typeString": "int128" } ], "id": 4027, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "566:7:21", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint128_$", "typeString": "type(uint128)" }, "typeName": { "id": 4026, "name": "uint128", "nodeType": "ElementaryTypeName", "src": "566:7:21", "typeDescriptions": {} } }, "id": 4029, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "566:10:21", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "src": "562:14:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "src": "558:18:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } } ], "id": 4032, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "TupleExpression", "src": "557:20:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "nodeType": "BinaryOperation", "operator": ">=", "rightExpression": { "id": 4033, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3996, "src": "581:1:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "src": "557:25:21", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "hexValue": "4c41", "id": 4035, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "584:4:21", "typeDescriptions": { "typeIdentifier": "t_stringliteral_ce8fc98a1432efc8ba166615239eb1702fbbbd0ddab9a5952502a98483035383", "typeString": "literal_string \"LA\"" }, "value": "LA" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_ce8fc98a1432efc8ba166615239eb1702fbbbd0ddab9a5952502a98483035383", "typeString": "literal_string \"LA\"" } ], "id": 4023, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 4294967278, 4294967278 ], "referencedDeclaration": 4294967278, "src": "549:7:21", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 4036, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "549:40:21", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 4037, "nodeType": "ExpressionStatement", "src": "549:40:21" } ] }, "id": 4039, "nodeType": "IfStatement", "src": "453:147:21", "trueBody": { "id": 4022, "nodeType": "Block", "src": "464:65:21", "statements": [ { "expression": { "arguments": [ { "commonType": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "id": 4018, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "components": [ { "id": 4015, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "id": 4007, "name": "z", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4001, "src": "487:1:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "commonType": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "id": 4014, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 4008, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3996, "src": "491:1:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "nodeType": "BinaryOperation", "operator": "-", "rightExpression": { "arguments": [ { "id": 4012, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "UnaryOperation", "operator": "-", "prefix": true, "src": "503:2:21", "subExpression": { "id": 4011, "name": "y", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3998, "src": "504:1:21", "typeDescriptions": { "typeIdentifier": "t_int128", "typeString": "int128" } }, "typeDescriptions": { "typeIdentifier": "t_int128", "typeString": "int128" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_int128", "typeString": "int128" } ], "id": 4010, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "495:7:21", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint128_$", "typeString": "type(uint128)" }, "typeName": { "id": 4009, "name": "uint128", "nodeType": "ElementaryTypeName", "src": "495:7:21", "typeDescriptions": {} } }, "id": 4013, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "495:11:21", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "src": "491:15:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "src": "487:19:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } } ], "id": 4016, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "TupleExpression", "src": "486:21:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "id": 4017, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3996, "src": "510:1:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "src": "486:25:21", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "hexValue": "4c53", "id": 4019, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "513:4:21", "typeDescriptions": { "typeIdentifier": "t_stringliteral_2be2231ccd52e7fedf30c30a3dfa3d6c9d9d3400159e305398a7b6d437f56985", "typeString": "literal_string \"LS\"" }, "value": "LS" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_2be2231ccd52e7fedf30c30a3dfa3d6c9d9d3400159e305398a7b6d437f56985", "typeString": "literal_string \"LS\"" } ], "id": 4006, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 4294967278, 4294967278 ], "referencedDeclaration": 4294967278, "src": "478:7:21", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 4020, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "478:40:21", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 4021, "nodeType": "ExpressionStatement", "src": "478:40:21" } ] } } ] }, "documentation": { "id": 3994, "nodeType": "StructuredDocumentation", "src": "124:241:21", "text": "@notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\n @param x The liquidity before change\n @param y The delta by which liquidity should be changed\n @return z The liquidity delta" }, "id": 4041, "implemented": true, "kind": "function", "modifiers": [], "name": "addDelta", "nodeType": "FunctionDefinition", "parameters": { "id": 3999, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 3996, "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", "scope": 4041, "src": "388:9:21", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "typeName": { "id": 3995, "name": "uint128", "nodeType": "ElementaryTypeName", "src": "388:7:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "visibility": "internal" }, { "constant": false, "id": 3998, "mutability": "mutable", "name": "y", "nodeType": "VariableDeclaration", "scope": 4041, "src": "399:8:21", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int128", "typeString": "int128" }, "typeName": { "id": 3997, "name": "int128", "nodeType": "ElementaryTypeName", "src": "399:6:21", "typeDescriptions": { "typeIdentifier": "t_int128", "typeString": "int128" } }, "visibility": "internal" } ], "src": "387:21:21" }, "returnParameters": { "id": 4002, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4001, "mutability": "mutable", "name": "z", "nodeType": "VariableDeclaration", "scope": 4041, "src": "432:9:21", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "typeName": { "id": 4000, "name": "uint128", "nodeType": "ElementaryTypeName", "src": "432:7:21", "typeDescriptions": { "typeIdentifier": "t_uint128", "typeString": "uint128" } }, "visibility": "internal" } ], "src": "431:11:21" }, "scope": 4042, "src": "370:236:21", "stateMutability": "pure", "virtual": false, "visibility": "internal" } ], "scope": 4043, "src": "96:512:21" } ], "src": "32:577:21" }, "legacyAST": { "attributes": { "absolutePath": "/Users/warrenmason/Documents/UniswapV3Contracts/Core/LiveContracts/MoonwalkerSwap-v1-Core/contracts/libraries/LiquidityMath.sol", "exportedSymbols": { "LiquidityMath": [ 4042 ] }, "license": "MIT" }, "children": [ { "attributes": { "literals": [ "solidity", ">=", "0.5", ".0" ] }, "id": 3992, "name": "PragmaDirective", "src": "32:24:21" }, { "attributes": { "abstract": false, "baseContracts": [ null ], "contractDependencies": [ null ], "contractKind": "library", "fullyImplemented": true, "linearizedBaseContracts": [ 4042 ], "name": "LiquidityMath", "scope": 4043 }, "children": [ { "attributes": { "text": "@title Math library for liquidity" }, "id": 3993, "name": "StructuredDocumentation", "src": "58:38:21" }, { "attributes": { "implemented": true, "isConstructor": false, "kind": "function", "modifiers": [ null ], "name": "addDelta", "scope": 4042, "stateMutability": "pure", "virtual": false, "visibility": "internal" }, "children": [ { "attributes": { "text": "@notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\n @param x The liquidity before change\n @param y The delta by which liquidity should be changed\n @return z The liquidity delta" }, "id": 3994, "name": "StructuredDocumentation", "src": "124:241:21" }, { "children": [ { "attributes": { "constant": false, "mutability": "mutable", "name": "x", "scope": 4041, "stateVariable": false, "storageLocation": "default", "type": "uint128", "visibility": "internal" }, "children": [ { "attributes": { "name": "uint128", "type": "uint128" }, "id": 3995, "name": "ElementaryTypeName", "src": "388:7:21" } ], "id": 3996, "name": "VariableDeclaration", "src": "388:9:21" }, { "attributes": { "constant": false, "mutability": "mutable", "name": "y", "scope": 4041, "stateVariable": false, "storageLocation": "default", "type": "int128", "visibility": "internal" }, "children": [ { "attributes": { "name": "int128", "type": "int128" }, "id": 3997, "name": "ElementaryTypeName", "src": "399:6:21" } ], "id": 3998, "name": "VariableDeclaration", "src": "399:8:21" } ], "id": 3999, "name": "ParameterList", "src": "387:21:21" }, { "children": [ { "attributes": { "constant": false, "mutability": "mutable", "name": "z", "scope": 4041, "stateVariable": false, "storageLocation": "default", "type": "uint128", "visibility": "internal" }, "children": [ { "attributes": { "name": "uint128", "type": "uint128" }, "id": 4000, "name": "ElementaryTypeName", "src": "432:7:21" } ], "id": 4001, "name": "VariableDeclaration", "src": "432:9:21" } ], "id": 4002, "name": "ParameterList", "src": "431:11:21" }, { "children": [ { "children": [ { "attributes": { "commonType": { "typeIdentifier": "t_int128", "typeString": "int128" }, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "<", "type": "bool" }, "children": [ { "attributes": { "overloadedDeclarations": [ null ], "referencedDeclaration": 3998, "type": "int128", "value": "y" }, "id": 4003, "name": "Identifier", "src": "457:1:21" }, { "attributes": { "hexvalue": "30", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "token": "number", "type": "int_const 0", "value": "0" }, "id": 4004, "name": "Literal", "src": "461:1:21" } ], "id": 4005, "name": "BinaryOperation", "src": "457:5:21" }, { "children": [ { "children": [ { "attributes": { "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, "names": [ null ], "tryCall": false, "type": "tuple()", "type_conversion": false }, "children": [ { "attributes": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_2be2231ccd52e7fedf30c30a3dfa3d6c9d9d3400159e305398a7b6d437f56985", "typeString": "literal_string \"LS\"" } ], "overloadedDeclarations": [ 4294967278, 4294967278 ], "referencedDeclaration": 4294967278, "type": "function (bool,string memory) pure", "value": "require" }, "id": 4006, "name": "Identifier", "src": "478:7:21" }, { "attributes": { "commonType": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "<", "type": "bool" }, "children": [ { "attributes": { "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, "type": "uint128" }, "children": [ { "attributes": { "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "=", "type": "uint128" }, "children": [ { "attributes": { "overloadedDeclarations": [ null ], "referencedDeclaration": 4001, "type": "uint128", "value": "z" }, "id": 4007, "name": "Identifier", "src": "487:1:21" }, { "attributes": { "commonType": { "typeIdentifier": "t_uint128", "typeString": "uint128" }, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "-", "type": "uint128" }, "children": [ { "attributes": { "overloadedDeclarations": [ null ], "referencedDeclaration": 3996, "type": "uint128", "value": "x" }, "id": 4008, "name": "Identifier", "src": "491:1:21" }, { "attributes": { "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, "names": [