Skip to content

Commit

Permalink
Merge pull request #42 from Elnaril/v1.1.0.dev0
Browse files Browse the repository at this point in the history
Merge V1.1.0.dev0 into master
  • Loading branch information
Elnaril authored Feb 6, 2024
2 parents af911af + 0448f5d commit e3c8f83
Show file tree
Hide file tree
Showing 12 changed files with 360 additions and 47 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Elnaril
Copyright (c) 2024 Elnaril

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
44 changes: 35 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
---

## Release Notes
### v1.1.0
- Add support for the TRANSFER function
- Add support for decoding the "revert on fail" flag and prepare for encoding on UR functions that support it.
- Add support for encoding the `execute()` function without deadline
### v1.0.1
- Fix issue #35 - fails to decode input data when there is too many commands
### v1.0.0
Expand All @@ -27,12 +31,6 @@
- Remove useless parameter `payer_is_sender` from `v*_swap_exact_in_from_balance()` methods
- Update Router ABI
- Add uint48 and uint160 in ABI builder
### V0.9.1
- Fix lint error
- Change `v*_swap_exact_in_from_balance()` `payer_is_sender` default to False. This parameter will be removed in the next version.
### V0.9.0
- Add support for UNWRAP_WETH encoding
- Add `v2_swap_exact_in_from_balance()` and `v3_swap_exact_in_from_balance()`: 2 convenient methods which are used when the exact in_amount is not known when the transaction is built, typically chained after a `V*_SWAP_EXACT_IN`.

---

Expand All @@ -52,7 +50,7 @@ on Ethereum Mainnet). It is based on, and is intended to be used with [web3.py](
| 0x01 | V3_SWAP_EXACT_OUT | ✅ | ✅
| 0x02 - 0x03 | | ❌ | ❌
| 0x04 | SWEEP | ✅ | ✅
| 0x05 | TRANSFER | |
| 0x05 | TRANSFER | |
| 0x06 | PAY_PORTION | ✅ | ✅
| 0x07 | placeholder | N/A | N/A
| 0x08 | V2_SWAP_EXACT_IN | ✅ | ✅
Expand Down Expand Up @@ -109,7 +107,10 @@ Example of decoded input returned by `decode.function_input()`:
{ # and its parameters
'recipient': '0x0000000000000000000000000000000000000002', # code indicating the recipient of this command is the router
'amountMin': 4500000000000000000 # the amount in WEI to wrap
}
},
{
'revert_on_fail': True # flag indicating if the transaction must revert when this command fails
},
),
(
<Function V3_SWAP_EXACT_IN(address,uint256,uint256,bytes,bool)>, # the function corresponding to the second command
Expand All @@ -121,7 +122,10 @@ Example of decoded input returned by `decode.function_input()`:
b'\x00\x01\xf4\xa0\xb8i\x91\xc6!\x8b6\xc1\xd1\x9dJ.' # can be decoded with the method decode.v3_path()
b'\x9e\xb0\xce6\x06\xebH',
'payerIsSender': False # a bool indicating if the input tokens come from the sender or are already in the UR
}
},
{
'revert_on_fail': True # flag indicating if the transaction must revert when this command fails
},
)
],
'deadline': 1678441619 # The deadline after which the transaction is not valid any more.
Expand Down Expand Up @@ -360,5 +364,27 @@ transaction["data"] = encoded_data
# you can now sign and send the transaction to the UR
```

### Other chainable functions
(See integration tests for full examples)

#### PAY_PORTION
Example where a recipient is paid 1% of the USDC amount:
```python
.pay_portion(FunctionRecipient.CUSTOM, usdc_address, 100, recipient_address)

```
#### SWEEP
Example where the sender gets back all remaining USDC:
```python
.sweep(FunctionRecipient.SENDER, usdc_address, 0)
```

#### TRANSFER
Example where an USDC amount is sent to a recipient:
```python
.transfer(FunctionRecipient.CUSTOM, usdc_address, usdc_amount, recipient_address)
```


## Tutorials and Recipes:
See the [SDK Wiki](https://github.com/Elnaril/uniswap-universal-router-decoder/wiki).
2 changes: 1 addition & 1 deletion coverage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"meta": {"version": "7.3.2", "timestamp": "2023-10-26T12:01:24.826201", "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, 65, 66, 67, 69, 70, 71, 73, 74, 75, 77, 78, 79, 81, 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 97, 98, 99, 111, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 139, 140, 141, 142, 143, 145, 146, 147, 148, 150, 151, 152, 153, 154, 156, 157, 158, 159, 160, 162, 163, 164, 165, 167, 168, 169, 170], "summary": {"covered_lines": 108, "num_statements": 108, "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, 230, 239, 246, 247, 248, 249, 250, 252, 272, 273, 274, 285, 287, 294, 295, 296, 297, 298, 299, 301, 322, 323, 324, 335, 337, 356, 365, 372, 373, 374, 375, 376, 377, 379, 400, 401, 402, 413, 415, 419, 424, 425, 426, 427, 428, 430, 442, 443, 451, 453, 454, 455, 456, 457, 459, 474, 475, 476, 485, 487, 488, 489, 490, 491, 493, 509, 514, 516, 517, 518, 527, 529, 538, 543], "summary": {"covered_lines": 166, "num_statements": 166, "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": 392, "num_statements": 392, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}}
{"meta": {"format": 2, "version": "7.4.1", "timestamp": "2024-02-06T09:54:56.307613", "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, 65, 66, 67, 69, 70, 71, 73, 74, 75, 77, 78, 79, 81, 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 97, 98, 99, 112, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 126, 127, 128, 129, 130, 131, 132, 133, 135, 136, 137, 138, 140, 141, 142, 143, 144, 146, 147, 148, 149, 151, 152, 153, 154, 155, 157, 158, 159, 160, 161, 163, 164, 165, 166, 168, 169, 170, 171, 173, 174, 175, 176], "summary": {"covered_lines": 112, "num_statements": 112, "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, 19, 20, 22], "summary": {"covered_lines": 8, "num_statements": 8, "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, 34, 35, 36, 37, 38, 40, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 58, 59, 62, 63, 64, 65, 67, 76, 77, 78, 79, 80, 82, 83, 85, 86, 95, 96, 97, 98, 99, 100, 101, 108, 110, 111, 113], "summary": {"covered_lines": 51, "num_statements": 51, "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, 21, 22, 23, 24, 25, 26, 27, 33, 34, 41, 48, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 71, 72, 73, 75, 79, 82, 83, 84, 85, 86, 87, 88, 90, 91, 94, 99, 100, 101, 103, 108, 109, 110, 112, 113, 114, 115, 117, 118, 119, 120, 122, 123, 124, 125, 126, 128, 142, 143, 144, 145, 147, 148, 149, 150, 151, 153, 167, 168, 169, 170, 172, 179, 180, 181, 182, 183, 185, 206, 207, 208, 219, 221, 240, 249, 256, 257, 258, 259, 260, 262, 283, 284, 285, 296, 298, 305, 306, 307, 308, 309, 310, 312, 334, 335, 336, 347, 349, 369, 378, 385, 386, 387, 388, 389, 390, 392, 414, 415, 416, 427, 429, 433, 438, 439, 440, 441, 442, 444, 457, 458, 466, 468, 469, 470, 471, 472, 474, 490, 491, 492, 501, 503, 504, 505, 506, 507, 509, 526, 531, 533, 534, 535, 544, 546, 547, 548, 549, 550, 552, 570, 571, 572, 581, 583, 590, 591, 592, 594, 595], "summary": {"covered_lines": 180, "num_statements": 180, "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, 27, 30, 31, 38, 39, 40, 43, 45, 46, 47, 48, 49], "summary": {"covered_lines": 24, "num_statements": 24, "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": 417, "num_statements": 417, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}}
Loading

0 comments on commit e3c8f83

Please sign in to comment.