Commit Graph

344 Commits

Author SHA1 Message Date
Diana Carvalho
7bf0b48ea6 fix: Make clippy happy after new format! format
Took 19 minutes
2025-04-24 13:34:08 +01:00
Diana Carvalho
2b48293b3d fix: After merge format fixes
Took 5 minutes
2025-04-23 12:57:14 +01:00
dianacarvalho1
eae7dfafc5 Merge branch 'main' into encoding/dc/bin-update 2025-04-23 12:31:53 +01:00
Diana Carvalho
aba280acd0 feat: Update tycho-encode bin with new arguments
--- don't change below this line ---
ENG-4446 Took 51 minutes


Took 9 seconds
2025-04-23 12:31:53 +01:00
Diana Carvalho
02cbb67b38 fix: After merge test fixes
Took 11 minutes
2025-04-23 12:31:53 +01:00
dianacarvalho1
fc249d5977 Merge branch 'main' into router/tnl/more-protocol-integration 2025-04-23 12:31:53 +01:00
TAMARA LIPOWSKI
132eed4bb9 test: 5-hop Multi-protocol integration test
- Needed to add ekubo and uniswap v4 to callback-limited protocols.
- I had to bump the fork block in all of our integration tests: The way it was before meant that certain integration tests were using certain executor addresses, and others were using different ones, because of the redeployment. This was a pain to account for on the rust side. Instead, all tests now use an Ekubo-compatible fork block. Values needed to be updated because of price changes between blocks.
2025-04-23 12:31:53 +01:00
Diana Carvalho
7614e36f18 Merge branch 'refs/heads/main' into feature/gas-optimization
# Conflicts:
#	foundry/src/Dispatcher.sol
#	foundry/test/executors/CurveExecutor.t.sol

Took 4 minutes

Took 12 seconds
2025-04-23 12:31:51 +01:00
Diana Carvalho
dff4a345fc chore: Move get_receiver logic inside TransferOptimization
Added tests for all cases

--- don't change below this line ---
ENG-4446 Took 1 hour 8 minutes
2025-04-23 12:31:42 +01:00
Diana Carvalho
4a61de56b7 feat: Support using the TransferType in uniswap v4
Update tests

--- don't change below this line ---
ENG-4437 Took 1 hour 3 minutes

Took 2 minutes
2025-04-23 12:31:42 +01:00
Diana Carvalho
cebacc68fe test: Add integration test for it
--- don't change below this line ---
ENG-4446 Took 12 minutes
2025-04-23 12:31:42 +01:00
Diana Carvalho
df92be8875 feat: Allow for token_in_already_in_router
--- don't change below this line ---
ENG-4446 Took 31 minutes


Took 26 seconds
2025-04-23 12:31:42 +01:00
Diana Carvalho
304740574b chore: get_transfer_type should receive a SwapGroup and not a Swap
Only the first swap of a SwapGroup would actually get a transfer in, so we don't need to do this inside of the swaps loop
Rename in_token and out_token to token_in and token_out in SwapGroup

--- don't change below this line ---
ENG-4446 Took 22 minutes
2025-04-23 12:31:42 +01:00
Diana Carvalho
87de8bd637 chore: Refactor TransferOptimization to be a struct instead of a trait
--- don't change below this line ---
ENG-4446 Took 39 minutes
2025-04-23 12:31:42 +01:00
Diana Carvalho
0751e0d153 chore: Rename test module from chained_swaps to optimized_transfers
--- don't change below this line ---
ENG-4327 Took 17 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
a951dfb21a chore: Improve tests:
In both encoding and contracts:
- Make sure that the tests names/encoder match what is happening (we had test_split_... that was only a single swap).
- Made modules inside the encodings tests
  - In swap_encoders: there is one module per protocol
  - In strategy_encoders: there is one module per strategy and an extra protocol_integration module. Inside the sequential module there is another module called chained_swaps
- In contracts, each strategy has its own file. Integration tests per strategy should also be here. Renamed TychoRouterIntegration to TychoRouterProtocolIntegration. Only protocol integration tests should be in this file

--- don't change below this line ---
ENG-4327 Took 1 hour 13 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
244b7d3482 fix: Rename constants and update docstrings for clarity
--- don't change below this line ---
ENG-4314 Took 44 minutes


Took 9 seconds
2025-04-23 12:31:41 +01:00
Diana Carvalho
8aa5b08b41 fix: unsupported protocols for chained swaps are always unsupported
not only when the previous swap if of the same protocol!
Improve docs and naming

--- don't change below this line ---
ENG-4314 Took 15 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
efe12cfcd6 feat: Support in between swaps optimizations
--- don't change below this line ---
ENG-4314 Took 31 seconds
2025-04-23 12:31:41 +01:00
Diana Carvalho
d447551e20 fix: Bring back receiver address zero check
Add small docs and rename variables

--- don't change below this line ---
ENG-4314 Took 1 hour 39 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
8145f416b7 fix: After rebase fixes
- In Tycho Router
  - Fix integration tests
  - If the trade is cyclical, we can't do the balance check for the correctness of the amountOut transfers
- In encoding,
  - if it is a wrap trade, the transfer should be just a normal Transfer (not TransferFrom nor a Permit2Transfer)
  - add test names to println! statements

--- don't change below this line ---
ENG-4315 Took 1 hour 0 minutes

Took 30 seconds

Took 21 seconds

Took 16 seconds


Took 17 seconds
2025-04-23 12:31:41 +01:00
Diana Carvalho
ec87969aa6 feat: Add transfer out for Uniswap V4
Add transfer in Executor and pass receiver address in encoding
This is done by using the TAKE action instead of TAKE_ALL

--- don't change below this line ---
ENG-4315 Took 1 hour 36 minutes

Took 2 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
328a281a44 feat: Add transfer out for Curve
Add transfer in Executor and pass receiver address in encoding
Remove integration test with StETH pool because we don't support it at simulation level and there is something weird with the amounts (that it is not worth it to investigate now)

--- don't change below this line ---
ENG-4315 Took 34 minutes

Took 2 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
9bcb58e5aa feat: Support out transfer straight to the receiver
- The out transfer is now a responsibility of the Executors -> remove this from router methods
- Also adding a check that the receiver got the full amount out
- In encoding, if it is the last swap, pass the receiver as the trade receiver and not the router address (fix encoding tests)
- Fixed some solidity tests (after rebasing with a PR that is still open, I will fix them all)

TODO: Adapt curve and uniswap v4 to support this

--- don't change below this line ---
ENG-4315 Took 3 hours 7 minutes

Took 20 minutes

Took 59 seconds


Took 7 minutes
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
11886b3ac1 fix: properly add ekubo_v2 to constants
Mistakenly added "ekubo"
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
d9066d0a09 feat: Use TokenTransfer optimization helper in Ekubo 2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
30dc3f7682 chore: renamings for clarity
- Also added a check for length in the Curve executor.
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
3a73fef933 feat: Add TokenTransfer class to BalancerV2
- This needed to be in BalancerV2 so that the executor can also take care of transfers from the user into the tycho router, to avoid having transfer actions mixed between the router and executors
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
462be5463b feat: Add TokenTransfer class to Curve
- This needed to be in Curve so that the executor can also take care of transfers from the user into the tycho router, to avoid having transfer actions mixed between the router and executors
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
dbc9042a2f fix: consider wrapping scenario when getting transfer type 2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
7ba99561db chore: nightly fmt.
Somehow missed.
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
e96ea1b10b fix: Test+formatting fixes after rebase. 2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
a301a1cef3 feat: (WIP) Support selection of transfer into router
- For protocols like Balancer and Curve, which expect funds to be in the router at the time of swap, we must support also transferring funds from the user into the router. Doing this in the router would mean we are dealing with transfers in two different places: in the router main methods and in the executors. To avoid this, we are now performing transfers just in the executors, and two transfer types have been added to support transfers into the router.

TODO:
- Add this for Balancer and Curve (only added for USV4 atm).
- TODO consider renaming TRANSFER_FROM and TRANSFER_PERMIT2 to include "pool" in the name
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
59a80dc392 feat: Optimize transfer to first pool
TODO: Update integration tests on solidity side, since a few were now updated on the encoding side to use a transferFrom.
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
f3c4128eda fix: USV3 encoding/decoding after rebase
- Also do some renamings and comment improvements:
transfer method -> type
- Remove integration tests since we no longer support direct calls to USV3 executor, even for testing.
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
61c0163bee fix: test fix after rebase 2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
d3ff9fd0e2 fix: Fix integration tests with transfer in method support
- For now, hardcode them to TRANSFER on the rust encoder side. This will be fixed in an upcoming PR.
- Remove the split swap simple route integration test - seemed overkill since simple routes are tested in many other integration tests, the original rust test named doesn't exist anymore, and simple routes should anyway be passing through the single endpoint.
2025-04-23 12:31:40 +01:00
Diana Carvalho
26ec30852d fix: Fixes after merge with feature branch
Update some tests calldata

Took 9 minutes
2025-04-23 12:31:40 +01:00
Diana Carvalho
b391c0e2f3 Merge branch 'refs/heads/feature/gas-optimization' into router/dc/ENG-4411-refactor-callback-transient-storage
# Conflicts:
#	foundry/test/TychoRouter.t.sol
#	src/encoding/evm/strategy_encoder/strategy_encoders.rs

Took 5 minutes

Took 35 seconds
2025-04-23 12:31:38 +01:00
Diana Carvalho
fff8ef0d87 fix: Fix after merge with main
Mostly had to delete some tests (because they were moved) and fix others

Took 17 minutes

Took 8 seconds

Took 17 seconds
2025-04-23 12:31:15 +01:00
Diana Carvalho
35441456ac Merge branch 'refs/heads/main' into feature/gas-optimization
# Conflicts:
#	foundry/test/TychoRouter.t.sol
#	src/encoding/evm/strategy_encoder/strategy_encoders.rs
#	src/encoding/evm/utils.rs

Took 3 minutes

Took 35 seconds
2025-04-23 12:30:46 +01:00
Diana Carvalho
f5e712e0ff feat(tycho-router-encoder): Select strategy depending on the solution
- The tycho router address default is set at the EncoderBuilder level (not inside the strategies)
- Rename TychoCoreChain to TychoCommonChain
- Only take TychoCommonChain as an argument at the outermost level: EncoderBuilder. Everywhere else we use the execution Chain right away

--- don't change below this line ---
ENG-4332 Took 1 hour 10 minutes
2025-04-23 12:30:13 +01:00
Diana Carvalho
6fd0ab54c1 docs: Improve doc
--- don't change below this line ---
ENG-4306 Took 4 minutes
2025-04-23 12:30:13 +01:00
Diana Carvalho
8b4b79b353 feat: Refactor TychoEncoder
We have a trait TychoEncoder and then two implementations: TychoRouterEncoder and TychoExecutorEncoder.
This way we go a level above with the decision if it is a direct execution or if it should use the tycho router.

- Created two builders: one for each tycho encoder
- Delete ExecutorStrategyEncoder and move code straight into the TychoExecutorEncoder
- Add validate_solution to trait TychoEncoder
- Move group_swaps.rs a level up
- Update tests and usage cases

Doing this we get rid of all that weird stuff we were doing before

--- don't change below this line ---
ENG-4306 Took 2 hours 6 minutes


Took 12 seconds
2025-04-23 12:30:13 +01:00
Tamara
899f0efeff Merge pull request #154 from propeller-heads/encoding/dc/4318-single-strategy-integration-test
feat: Add SingleSwap integration test
2025-04-23 12:30:13 +01:00
Tamara
1d298a371d Merge pull request #132 from propeller-heads/encoding/tnl/ENG-4318-sequential-strategy
feat: SequentialSwapStrategyEncoder
2025-04-23 12:30:13 +01:00
Diana Carvalho
df1c05ea00 feat: Add SingleSwap integration test and fix bug in method signatures
--- don't change below this line ---
ENG-4306 Took 27 minutes


Took 15 seconds
2025-04-23 12:30:13 +01:00
Diana Carvalho
6e7bf3c019 feat: Add SequentialSwap integration test with regular approvals
Improve docstrings

--- don't change below this line ---
ENG-4306 Took 20 minutes
2025-04-23 12:30:13 +01:00
Diana Carvalho
6430c99d76 feat: Delete EVMStrategyEncoder (this is now unnecessary)
Moved ple_encode into utils.rs

--- don't change below this line ---
ENG-4306 Took 5 minutes
2025-04-23 12:30:13 +01:00
Diana Carvalho
2f81b167d4 fix: Fix executor address in test and remove duplicated test
--- don't change below this line ---
ENG-4306 Took 12 minutes


Took 18 seconds
2025-04-23 12:30:13 +01:00