Commit Graph

343 Commits

Author SHA1 Message Date
TAMARA LIPOWSKI
45fdfc708d feat: UniswapV4 integration test and fixes
- Biggest issue: We must encode the executor address, not the router address, in the USV4 swap encoder
2025-02-19 18:12:11 -05:00
TAMARA LIPOWSKI
81c8a04cbb fix: Pass proper group tokens in EncodingContext...
Also:
- Remove amount_out_min. Our reasoning is that we perform high-level final amount checks anyway (and expect users to do the same). Lower-level USV4 min amount checks are redundant.
2025-02-19 16:27:56 -05:00
TAMARA LIPOWSKI
c3482a509a feat: TychoRouter swap method not requiring Permit2
- Assume the tokens have been transferred into our router beforehand.
2025-02-19 16:15:57 -05:00
Harsh Vardhan Roy
6c4bb376fd Merge branch 'main' into router/hr/ENG-4239-usv4-swap-encoder 2025-02-20 00:07:43 +05:30
royvardhan
c472cda697 refactor: make group tokens and amount out min non optional 2025-02-20 00:05:47 +05:30
royvardhan
e2a2aaaad1 refactor: usv4 swap encoder test, encoder 2025-02-19 23:59:27 +05:30
royvardhan
1e9b411ca5 chore: rm redundant pool params encoder fn 2025-02-19 23:07:26 +05:30
Diana Carvalho
4f29022c42 fix: After rebase fixes
--- don't change below this line ---
ENG-4246 Took 2 minutes
2025-02-19 17:05:46 +00:00
Diana Carvalho
359bb806f7 docs: Add docstrings to EVMEncoderBuilder
--- don't change below this line ---
ENG-4246 Took 41 minutes
2025-02-19 17:03:25 +00:00
Diana Carvalho
684de4fa60 feat: Add methods to builder to set chain and strategy independently
--- don't change below this line ---
ENG-4246 Took 15 minutes
2025-02-19 17:03:25 +00:00
Diana Carvalho
4741e628b8 chore: Simplify tycho-encode
Don't have a cli as a lib. Move that directly inside tycho-encode.rs for simplicity

--- don't change below this line ---
ENG-4246 Took 29 minutes
2025-02-19 17:03:25 +00:00
Diana Carvalho
d9d56e7a8c chore: Rename signer_pk to swapper_pk
--- don't change below this line ---
ENG-4246 Took 15 minutes
2025-02-19 17:03:25 +00:00
Diana Carvalho
8794dc674a chore: Delete unnecessary empty file
--- don't change below this line ---
ENG-4246 Took 3 minutes
2025-02-19 17:03:25 +00:00
Diana Carvalho
30b5ab9025 fix: After rebase fixes
Put the strategy_encoders.rs back inside the strategy_encoder directory

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

Took 12 seconds
2025-02-19 17:03:22 +00:00
Diana Carvalho
8537d27469 feat: Remove direct_execution from Solution
This is handled when creating a new TychoEncoder

--- don't change below this line ---
ENG-4246 Took 4 minutes
2025-02-19 17:03:13 +00:00
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
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
789416b2cd feat: add usv4 swap encoder with single swap test 2025-02-18 20:58:00 +05:30
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
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
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
TAMARA LIPOWSKI
f32210bb1f feat: (WIP) UniswapV4 encoding
- To keep any knowledge of USV4 separate from regular splits, I've made a new USV4 encoding strategy that will be used only if we detect sequential USV4 swaps.
- For single USV4 swaps without necessary optimizations, the regular split swap strategy can be used
- No need to change the swap struct interface to take multiple swaps - this concatenation can be done at the swap strategy level.

TODO:
- test
- deduplicate code from split strategy
- UniswapV4SwapEncoder
2025-02-13 14:51:08 -05:00
TAMARA LIPOWSKI
1c565deb57 refactor: (Solution) replace check_amount with checked_amount
- This is to have consistency with checked_token
2025-02-11 11:25:58 -05:00
Diana Carvalho
dd7ecac324 feat: Add selector to Transaction
Return selector in the StrategyEncoder. This is needed for the ExecutorStrategyEncoder

--- don't change below this line ---
ENG-4088 Took 12 minutes


Took 13 seconds
2025-02-11 12:20:47 +00:00
Diana Carvalho
a234ff701f feat: Remove router_address from TychoEncoder
Make the router address mandatory for the Solution attribute instead

--- don't change below this line ---
ENG-4088 Took 30 minutes
2025-02-07 14:58:09 +00:00
Diana Carvalho
d7f20aa74f fix: Don't have a DEFAULT_CONFIG_PATH in bin
This is unnecessary since we already have the executor address loaded at build time

--- don't change below this line ---
ENG-4088 Took 8 minutes


Took 7 seconds
2025-02-07 12:27:24 +00:00
Diana Carvalho
cad9f394cd feat: The execution structs should receiver tycho_core Chain
and convert it later to an execution model Chain

--- don't change below this line ---
ENG-4088 Took 8 minutes
2025-02-07 12:16:46 +00:00
Diana Carvalho
0c9050cf79 fix: Uniswap v3 pool fee is big endian, not little endian
--- don't change below this line ---
ENG-4088 Took 18 minutes


Took 17 seconds
2025-02-07 12:16:46 +00:00
Diana Carvalho
bef4740a1d fix: After rebase fixes
--- don't change below this line ---
ENG-4088 Took 2 minutes
2025-02-07 12:16:46 +00:00
Diana Carvalho
164d062ad9 fix(univ3): The fee keyword is just "fee" and not "pool_fee"
--- don't change below this line ---
ENG-4088 Took 1 minute
2025-02-07 12:16:46 +00:00
Diana Carvalho
d4af59d4dc feat: Use block_in_place instead of block_on
This is necessary when we run tycho-execution in an environment that already has a runtime.
Make sure that if no runtime exists, like in the testing scenario inside tycho-execution, we save the new runtime in an attribute of permit2. If we don't do this, then the runtime just dies and our handle points to nothing at all and all tests fail

--- don't change below this line ---
ENG-4088 Took 17 minutes

Took 5 seconds
2025-02-07 12:16:46 +00:00
Diana Carvalho
12f85ccc0a feat: Get current runtime if there is any
instead of creating a new one every time

--- don't change below this line ---
ENG-4088 Took 18 minutes

Took 6 seconds
2025-02-07 12:16:46 +00:00
Diana Carvalho
f5232f403e feat: Read default executors at compile time into a json
This way we don't have issues with paths and trying to read files that are at other locations after compile time

--- don't change below this line ---
ENG-4088 Took 44 seconds

Took 52 seconds
2025-02-07 12:16:46 +00:00
Diana Carvalho
c791c93cb5 feat: Add uniswap v3 to swap encoders list
--- don't change below this line ---
ENG-4088 Took 10 minutes
2025-02-07 12:16:46 +00:00
Diana Carvalho
dee8542b45 chore: Improve error message when reading executors file
--- don't change below this line ---
ENG-4088 Took 1 minute

Took 7 seconds
2025-02-07 12:16:46 +00:00
Diana Carvalho
b333d60d69 feat: Add clone to EVMTychoEncoder
--- don't change below this line ---
ENG-4088 Took 4 minutes

Took 8 seconds

Took 48 seconds
2025-02-07 12:16:46 +00:00