diff --git a/coverage.json b/coverage.json index 5e1ffc0..ea1d92d 100644 --- a/coverage.json +++ b/coverage.json @@ -1 +1 @@ -{"meta": {"version": "7.2.7", "timestamp": "2023-08-04T15:17:52.837067", "branch_coverage": false, "show_contexts": false}, "files": {"uniswap_universal_router_decoder/__init__.py": {"executed_lines": [1, 2, 5], "summary": {"covered_lines": 3, "num_statements": 3, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_abi_builder.py": {"executed_lines": [1, 8, 10, 14, 21, 23, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 38, 39, 42, 43, 44, 45, 48, 51, 52, 53, 55, 56, 57, 59, 60, 61, 63, 64, 65, 67, 68, 69, 71, 72, 74, 75, 76, 78, 79, 80, 82, 83, 84, 87, 88, 89, 99, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 122, 123, 124, 125, 127, 128, 129, 130, 131, 133, 134, 135, 136, 138, 139, 140, 141, 142, 144, 145, 146, 147, 148], "summary": {"covered_lines": 93, "num_statements": 93, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_constants.py": {"executed_lines": [1, 8, 13, 16, 17, 18, 20], "summary": {"covered_lines": 6, "num_statements": 6, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_decoder.py": {"executed_lines": [1, 8, 9, 17, 18, 19, 26, 27, 28, 31, 32, 33, 34, 35, 37, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 69, 70, 71, 72, 73, 75, 76, 78, 79, 88, 89, 90, 91, 92, 93, 94, 101, 103, 104, 106], "summary": {"covered_lines": 49, "num_statements": 49, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_encoder.py": {"executed_lines": [1, 8, 10, 11, 22, 23, 24, 25, 26, 27, 28, 34, 35, 40, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 71, 75, 78, 79, 80, 81, 82, 83, 84, 86, 87, 90, 95, 96, 97, 99, 104, 105, 106, 107, 108, 109, 111, 112, 113, 114, 116, 117, 118, 119, 120, 122, 135, 136, 137, 138, 140, 141, 142, 143, 144, 146, 159, 160, 161, 162, 164, 171, 172, 173, 174, 175, 177, 197, 198, 199, 210, 212, 232, 241, 248, 249, 250, 251, 252, 254, 274, 275, 276, 287, 289, 296, 297, 298, 299, 300, 301, 303, 324, 325, 326, 337, 339, 360, 369, 376, 377, 378, 379, 380, 381, 383, 404, 405, 406, 417, 419, 423, 428, 429, 430, 431, 432, 434, 446, 447, 455, 457, 466, 471], "summary": {"covered_lines": 144, "num_statements": 144, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_enums.py": {"executed_lines": [1, 10, 12, 13, 16, 18, 19, 20, 21, 22, 23, 24, 27, 28, 29, 30, 33, 35, 36, 37], "summary": {"covered_lines": 19, "num_statements": 19, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/router_codec.py": {"executed_lines": [1, 8, 9, 16, 20, 21, 26, 27, 28, 29, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 49, 50, 54, 56, 57, 61, 63, 64, 68, 70, 71, 101, 107, 112, 113, 114, 115], "summary": {"covered_lines": 39, "num_statements": 39, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}}, "totals": {"covered_lines": 353, "num_statements": 353, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}} \ No newline at end of file +{"meta": {"version": "7.2.7", "timestamp": "2023-10-25T17:03:54.573245", "branch_coverage": false, "show_contexts": false}, "files": {"uniswap_universal_router_decoder/__init__.py": {"executed_lines": [1, 2, 5], "summary": {"covered_lines": 3, "num_statements": 3, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_abi_builder.py": {"executed_lines": [1, 8, 10, 14, 21, 23, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 38, 39, 42, 43, 44, 45, 48, 51, 52, 53, 55, 56, 57, 59, 60, 61, 63, 64, 65, 67, 68, 69, 71, 72, 74, 75, 76, 78, 79, 80, 82, 83, 84, 87, 88, 89, 101, 103, 104, 105, 106, 107, 109, 110, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 122, 124, 125, 126, 127, 129, 130, 131, 132, 133, 135, 136, 137, 138, 140, 141, 142, 143, 144, 146, 147, 148, 149, 150, 152, 153, 154, 155, 157, 158, 159, 160], "summary": {"covered_lines": 101, "num_statements": 101, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_constants.py": {"executed_lines": [1, 8, 13, 16, 17, 18, 20], "summary": {"covered_lines": 6, "num_statements": 6, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_decoder.py": {"executed_lines": [1, 8, 9, 17, 18, 19, 26, 27, 28, 31, 32, 33, 34, 35, 37, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 69, 70, 71, 72, 73, 75, 76, 78, 79, 88, 89, 90, 91, 92, 93, 94, 101, 103, 104, 106], "summary": {"covered_lines": 49, "num_statements": 49, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_encoder.py": {"executed_lines": [1, 8, 10, 11, 22, 23, 24, 25, 26, 27, 28, 34, 35, 40, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 71, 75, 78, 79, 80, 81, 82, 83, 84, 86, 87, 90, 95, 96, 97, 99, 104, 105, 106, 107, 108, 109, 111, 112, 113, 114, 116, 117, 118, 119, 120, 122, 135, 136, 137, 138, 140, 141, 142, 143, 144, 146, 159, 160, 161, 162, 164, 171, 172, 173, 174, 175, 177, 197, 198, 199, 210, 212, 232, 241, 248, 249, 250, 251, 252, 254, 274, 275, 276, 287, 289, 296, 297, 298, 299, 300, 301, 303, 324, 325, 326, 337, 339, 360, 369, 376, 377, 378, 379, 380, 381, 383, 404, 405, 406, 417, 419, 423, 428, 429, 430, 431, 432, 434, 446, 447, 455, 457, 466, 471], "summary": {"covered_lines": 144, "num_statements": 144, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/_enums.py": {"executed_lines": [1, 10, 12, 13, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 32, 35, 37, 38, 39], "summary": {"covered_lines": 21, "num_statements": 21, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/router_codec.py": {"executed_lines": [1, 8, 9, 16, 20, 21, 26, 27, 28, 29, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 49, 50, 54, 56, 57, 61, 63, 64, 68, 70, 71, 101, 107, 112, 113, 114, 115], "summary": {"covered_lines": 39, "num_statements": 39, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}}, "totals": {"covered_lines": 363, "num_statements": 363, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}} \ No newline at end of file diff --git a/tests/test_decoder.py b/tests/test_decoder.py index ee3a831..867ca01 100644 --- a/tests/test_decoder.py +++ b/tests/test_decoder.py @@ -26,7 +26,16 @@ expected_function_names_04 = ("WRAP_ETH", "V2_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "UNWRAP_WETH") trx_hash_05 = HexStr("0x47c0f1dd13edf9f1608f9f34bdba9ad40cb95dd081033cad69f5b88e451b4b55") -expected_function_names_05 = (None, None) +expected_function_names_05 = (None, "SWEEP") + +trx_hash_06 = HexStr("0xe648089f71b2d2e7b70bdcbfdcfeecce6c5248b8eb64b2c79089b7c74c835a45") +expected_function_names_06 = ("V3_SWAP_EXACT_IN", "V3_SWAP_EXACT_IN", "V3_SWAP_EXACT_IN", "SWEEP") + +trx_hash_07 = HexStr("0xb5a64e9935b46282080d9198f4478a4c4c1993d590eab8daa0f220c0dca5fe33") +expected_function_names_07 = ("V3_SWAP_EXACT_IN", "PAY_PORTION", "UNWRAP_WETH") + +trx_hash_08 = HexStr("0x62176a906ef7f178814a0924d390082053bd8992c2902f436756194693644c21") +expected_function_names_08 = ("WRAP_ETH", "V2_SWAP_EXACT_OUT", "PAY_PORTION", "SWEEP", "UNWRAP_WETH") @pytest.mark.parametrize( @@ -37,6 +46,9 @@ (trx_hash_03, w3_instance, None, expected_function_names_03), (trx_hash_04, w3_instance, None, expected_function_names_04), (trx_hash_05, w3_instance, None, expected_function_names_05), + (trx_hash_06, w3_instance, None, expected_function_names_06), + (trx_hash_07, w3_instance, None, expected_function_names_07), + (trx_hash_08, w3_instance, None, expected_function_names_08), ) ) def test_decode_transaction(trx_hash, w3, rpc_endpoint, expected_fct_names): diff --git a/uniswap_universal_router_decoder/_abi_builder.py b/uniswap_universal_router_decoder/_abi_builder.py index 56cffcc..e3508c8 100644 --- a/uniswap_universal_router_decoder/_abi_builder.py +++ b/uniswap_universal_router_decoder/_abi_builder.py @@ -95,6 +95,8 @@ def build_abi_map(self) -> _ABIMap: _RouterFunction.PERMIT2_PERMIT: self._add_mapping(self._build_permit2_permit), _RouterFunction.WRAP_ETH: self._add_mapping(self._build_wrap_eth), _RouterFunction.UNWRAP_WETH: self._add_mapping(self._build_unwrap_weth), + _RouterFunction.SWEEP: self._add_mapping(self._build_sweep), + _RouterFunction.PAY_PORTION: self._add_mapping(self._build_pay_portion), } return abi_map @@ -146,3 +148,13 @@ def _build_v3_swap_exact_out() -> _FunctionABI: builder = _FunctionABIBuilder("V3_SWAP_EXACT_OUT") builder.add_address("recipient").add_int("amountOut").add_int("amountInMax").add_bytes("path") return builder.add_bool("payerIsSender").build() + + @staticmethod + def _build_sweep() -> _FunctionABI: + builder = _FunctionABIBuilder("SWEEP") + return builder.add_address("token").add_address("recipient").add_int("amountMin").build() + + @staticmethod + def _build_pay_portion() -> _FunctionABI: + builder = _FunctionABIBuilder("PAY_PORTION") + return builder.add_address("token").add_address("recipient").add_int("bips").build() diff --git a/uniswap_universal_router_decoder/_enums.py b/uniswap_universal_router_decoder/_enums.py index be15b92..5edc88c 100644 --- a/uniswap_universal_router_decoder/_enums.py +++ b/uniswap_universal_router_decoder/_enums.py @@ -17,6 +17,8 @@ class _RouterFunction(Enum): # https://docs.uniswap.org/contracts/universal-router/technical-reference#command V3_SWAP_EXACT_IN = 0 V3_SWAP_EXACT_OUT = 1 + SWEEP = 4 + PAY_PORTION = 6 V2_SWAP_EXACT_IN = 8 V2_SWAP_EXACT_OUT = 9 PERMIT2_PERMIT = 10