Commit Graph

675 Commits

Author SHA1 Message Date
Diana Carvalho
03506fabe9 feat: Create a EVMEncoderBuilder
- It has two three methods to be created:
  - new: where the user can pass any custom StrategyEncoder
  - tycho_router: where the default SplitSwapStrategyEncoder with Tycho Router will be used
  - direct_execution: where the user can encode only the execution data and integrate this into their workflow.
- This replaces StrategyEncoderRegistry
- EVMTychoEncoder holds directly the StrategyEncoder and not the registry (per one init of the EVMTychoEncoder there is only one possible StrategyEncoder)
- Update quickstart
- Update bin (add subcommands to bin to create a different instance of EVMEncoderBuilder)

--- don't change below this line ---
ENG-4246 Took 33 minutes

Took 38 seconds

Took 38 seconds
2025-02-19 17:03:10 +00:00
royvardhan
7f3aca90ba fix: update EncodingContext in strategy_encoder 2025-02-19 21:50:43 +05:30
Harsh Vardhan Roy
78bc045d14 Merge branch 'main' into router/hr/ENG-4239-usv4-swap-encoder 2025-02-19 21:45:30 +05:30
royvardhan
f7ddace559 feat: early return in usv4 swap encoder for second swap, add utils 2025-02-19 21:42:13 +05:30
semantic-release-bot
f76e320ff7 chore(release): 0.42.0 [skip ci]
## [0.42.0](https://github.com/propeller-heads/tycho-execution/compare/0.41.0...0.42.0) (2025-02-19)

### Features

* Support swap grouping for executor strategy ([ac83117](ac831176d4))
2025-02-19 15:31:58 +00:00
Tamara
f6c33da13c Merge pull request #71 from propeller-heads/encoding/tnl/ENG-4248-direct-execution-usv4
feat: Support swap grouping optimizations for direct execution
2025-02-19 10:29:17 -05:00
TAMARA LIPOWSKI
5ab233ed0a refactor: PR comments
- rename utils.rs to group_swaps.rs
- extend instead of push in order to avoid calling abi_encode_packed again
2025-02-19 10:25:16 -05:00
royvardhan
5e9b38876e feat: add integration test for complex swaps 2025-02-19 20:32:55 +05:30
royvardhan
baeebb9fe4 feat: update test_encode_uniswap_v4_grouped 2025-02-19 19:08:06 +05:30
royvardhan
5b183b6690 chore: update executor_selector to swap_selector in swap encoder trait and attribute 2025-02-19 19:01:32 +05:30
royvardhan
9219dd329d feat: add util fns, change callback_selector to string, update first_swap check 2025-02-19 18:56:32 +05:30
royvardhan
1bfe656e6b feat: add new attributes in encoding context, update usv4 swap encoder and tests 2025-02-19 08:39:21 +05:30
TAMARA LIPOWSKI
ac831176d4 feat: Support swap grouping for executor strategy
- Also make sure the strategy errors if > 1 group.
2025-02-18 14:03:06 -05:00
TAMARA LIPOWSKI
962e460e34 refactor: Make group_swaps a util method
- In preparation for also using this for the executor encoder.
This also make test setup much easier for swap grouping - not having to init the encoder every time.
2025-02-18 12:12:08 -05:00
royvardhan
529456f40c feat: add single swap integration test for usv4 executor 2025-02-18 21:24:49 +05:30
royvardhan
789416b2cd feat: add usv4 swap encoder with single swap test 2025-02-18 20:58:00 +05:30
semantic-release-bot
4f37cd392b chore(release): 0.41.0 [skip ci]
## [0.41.0](https://github.com/propeller-heads/tycho-execution/compare/0.40.0...0.41.0) (2025-02-18)

### Features

* add back uniswapV3SwapCallback in router ([260f9d8](260f9d866f))
* add uniswapV3SwapCallback in USV3 executor ([9d3b96f](9d3b96f997))
* Change signature of _handleCallback to take only bytes calldata ([2aa63d7](2aa63d7ec0))
* fix input decoding in usv3 executor and execution dispatcher ([80500e6](80500e615e))
* move callback testing to usv3 executor ([5853de6](5853de679a))
* rename execution dispatcher to dispatcher and use dispatcher for USV4 callback ([ad91e48](ad91e485d3))
* update _handleCallback, add verifyCallback with docs ([076586d](076586d776))
* update handleCallback in USV3 to do verification ([cccb252](cccb252bf2))
* update new interface in codebase ([bd19713](bd1971334e))
2025-02-18 15:11:09 +00:00
Harsh Vardhan Roy
83a966ba7c Merge pull request #66 from propeller-heads/router/hr/ENG-4237-refactor-usv3-callback
feat: refactor usv3 callback
2025-02-18 20:39:02 +05:30
dianacarvalho1
adcb1c69ae Merge branch 'main' into router/hr/ENG-4237-refactor-usv3-callback 2025-02-18 15:01:44 +00:00
dianacarvalho1
a7c30a9edb Merge pull request #68 from propeller-heads/router/dc/refactor-univ3-callback
feat: Change signature of _handleCallback to take only bytes calldata
2025-02-18 15:01:28 +00:00
Diana Carvalho
c940d8b536 docs(univ3): Add comment explaining msg.data
Took 55 minutes
2025-02-18 14:59:26 +00:00
semantic-release-bot
fde870f57a chore(release): 0.40.0 [skip ci]
## [0.40.0](https://github.com/propeller-heads/tycho-execution/compare/0.39.0...0.40.0) (2025-02-18)

### Features

* (WIP) UniswapV4 encoding ([f32210b](f32210bb1f))
* Generalize group_swaps method ([47b6180](47b61802ee))
* Merge USV4 strategy back into split strategy ([44aabf1](44aabf1761))

### Bug Fixes

* Do not count intermediary tokens in indices ([e94154b](e94154bc2d))
* Do not group split swaps ([957bf89](957bf898f2))
2025-02-18 14:21:36 +00:00
Tamara
f6fa38b6f7 Merge pull request #65 from propeller-heads/encoding/tnl/ENG-4071-usv4
feat: UniswapV4 encoding
2025-02-18 09:18:50 -05:00
Diana Carvalho
2aa63d7ec0 feat: Change signature of _handleCallback to take only bytes calldata
The selector and executor are decoded inside this function now.
For Uniswap V3 I had to manually slice the msg.data from uniswapV3SwapCallback to get the data that matters for the callback

Took 3 hours 12 minutes
2025-02-18 11:11:43 +00:00
Tamara
f029cd5baf Merge branch 'main' into encoding/tnl/ENG-4071-usv4 2025-02-17 23:57:21 -05:00
TAMARA LIPOWSKI
8f1e372c90 refactor: PR comments (moving things around/docs)...
- Move the validator into its own file, for organization purposes.
- Add missing elements to `SplitSwapStrategyEncoder` docstring
2025-02-17 23:57:01 -05:00
TAMARA LIPOWSKI
44aabf1761 feat: Merge USV4 strategy back into split strategy
- Since the group_swaps method is now generalized, there is no need to have an entirely separate method here.
2025-02-17 23:44:58 -05:00
TAMARA LIPOWSKI
47b61802ee feat: Generalize group_swaps method
- This can now be used for any groupable protocols - not just USV4.
2025-02-17 17:23:29 -05:00
TAMARA LIPOWSKI
957bf898f2 fix: Do not group split swaps
As far as we know, Uniswap V4 has no support for optimizing split swaps - only sequential swaps. We must make sure we don't accidentally group split swaps too - as this will likely revert due to mismatched input and output values.
2025-02-17 16:50:59 -05:00
royvardhan
2604935609 chore: update unlockCallback and uniswapV3SwapCallback 2025-02-17 22:51:40 +05:30
Harsh Vardhan Roy
0d5c55c546 Merge branch 'main' into router/hr/ENG-4237-refactor-usv3-callback 2025-02-17 21:56:49 +05:30
royvardhan
076586d776 feat: update _handleCallback, add verifyCallback with docs 2025-02-17 21:51:09 +05:30
TAMARA LIPOWSKI
e94154bc2d fix: Do not count intermediary tokens in indices
To achieve this, a small refactor was necessary with the introduction of a SwapGroup object, and a separate method to create a vec of these objects. This then separates all logic related to combining protocol data nicely and cleanly into its own method with its own tests.

TODO:
- Deal with split swaps and add test for split swap scenario
- Clean up all existing PR comments
2025-02-14 18:48:39 -05:00
royvardhan
14e5c127c6 chore: rm safecallback from router 2025-02-15 01:06:23 +05:30
royvardhan
9b8175aff9 chore: cleanup 2025-02-15 01:01:16 +05:30
royvardhan
ad91e485d3 feat: rename execution dispatcher to dispatcher and use dispatcher for USV4 callback 2025-02-15 00:44:28 +05:30
royvardhan
9d3b96f997 feat: add uniswapV3SwapCallback in USV3 executor 2025-02-15 00:34:07 +05:30
royvardhan
cccb252bf2 feat: update handleCallback in USV3 to do verification 2025-02-14 23:27:44 +05:30
royvardhan
d0027e6cf2 refactor: rm callback verifier dispatcher 2025-02-14 23:11:01 +05:30
royvardhan
260f9d866f feat: add back uniswapV3SwapCallback in router 2025-02-14 23:00:23 +05:30
semantic-release-bot
002d049501 chore(release): 0.39.0 [skip ci]
## [0.39.0](https://github.com/propeller-heads/tycho-execution/compare/0.38.0...0.39.0) (2025-02-14)

### Features

* **univ4:** Implement swapping with multiple hops ([21a8c1a](21a8c1a27a))
* **univ4:** Refactor input and handle single swap case ([be7883a](be7883affc))

### Bug Fixes

* Fix PLE tests that break after foundry update ([69d03f0](69d03f0608))
* **univ4:** Append callback data instead of prepending ([4d0f5ce](4d0f5cec64))
* **univ4:** Make slither happy ([8a8bc69](8a8bc697eb))
2025-02-14 17:11:31 +00:00
dianacarvalho1
165e53e5fe Merge pull request #67 from propeller-heads/router/dc/ENG-4222-univ4-refactor-input
feat(univ4): Refactor execution input and handle all swap cases
2025-02-14 17:08:43 +00:00
Diana Carvalho
69d03f0608 fix: Fix PLE tests that break after foundry update
--- don't change below this line ---
ENG-4222 Took 12 minutes

Took 15 seconds
2025-02-14 12:39:36 +00:00
Diana Carvalho
8a8bc697eb fix(univ4): Make slither happy
--- don't change below this line ---
ENG-4222 Took 17 minutes

Took 47 seconds


Took 14 seconds
2025-02-14 12:39:36 +00:00
Diana Carvalho
4d0f5cec64 fix(univ4): Append callback data instead of prepending
Bring back tests on the executor level. This way the executor can actually be used alone

--- don't change below this line ---
ENG-4222 Took 12 minutes
2025-02-14 12:02:07 +00:00
Diana Carvalho
21a8c1a27a feat(univ4): Implement swapping with multiple hops
--- don't change below this line ---
ENG-4222 Took 47 minutes
2025-02-14 12:02:07 +00:00
Diana Carvalho
be7883affc feat(univ4): Refactor input and handle single swap case
Construct the uniswap v4 specific objects inside the executor
The swap test in the executor alone doesn't work anymore because of the callback data prepended to the rest of he calldata

--- don't change below this line ---
ENG-4222 Took 4 hours 0 minutes


Took 40 seconds
2025-02-14 12:02:07 +00:00
TAMARA LIPOWSKI
556af0253d test: Add test for USV4 sequential swap 2025-02-14 00:51:06 -05:00
TAMARA LIPOWSKI
b452372714 refactor: deduplicate validation for Split & USV4 strategy
We use the same validation for both SplitSwapStrategy and UniswapV4Strategy - so, instead, put the validation into a Validator trait that gets initialized in both swap strategies in order to avoid duplication.
2025-02-13 15:30:09 -05:00
royvardhan
5853de679a feat: move callback testing to usv3 executor 2025-02-14 01:29:30 +05:30