Skip to content

Commit

Permalink
feat: add start of Universal Router encoder/decoder algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Mar 15, 2024
1 parent e166794 commit 8ecb277
Show file tree
Hide file tree
Showing 2 changed files with 439 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/functional/test_universal_router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest
from hexbytes import HexBytes

from uniswap_sdk.universal_router import Plan


@pytest.mark.parametrize(
"plan_commands,plan_inputs,expected_plan",
[
(
"0b",
[
"000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
"000000000000000000000000000000000000000000000000016345785d8a0000"
],
Plan().wrap_eth("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", int(10**17)),
),
],
)
def test_decode_plan(plan_commands, plan_inputs, expected_plan):
plan_commands, plan_inputs = HexBytes(plan_commands), list(HexBytes(i) for i in plan_inputs)
actual_plan = Plan.decode(plan_commands, plan_inputs)

assert actual_plan == expected_plan
assert actual_plan.encoded_commands == plan_commands
assert actual_plan.encode_inputs() == plan_inputs
Loading

0 comments on commit 8ecb277

Please sign in to comment.