Commit Graph

53 Commits

Author SHA1 Message Date
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
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
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
af449562b0 feat: Refactor callback to use transient storage
With this, we don't need the univ3 specific method in the router contract. This should be flexible enough for most protocols that integrate

TODO: is this safe enough??

--- don't change below this line ---
ENG-4411 Took 1 hour 52 minutes

Took 4 minutes

Took 5 minutes
2025-04-09 13:05:53 +01:00
Diana Carvalho
ce7189423f fix: Curve factory addresses are utf-8 encoded
Took 30 minutes
2025-04-08 19:18:52 +01:00
Diana Carvalho
739fb46d20 feat: Add protocol_specific_addresses.json file
This way we can define protocol and chain specific addresses in this file and use them in the Encoders

--- don't change below this line ---
ENG-4306 Took 1 hour 4 minutes
2025-04-08 09:30:29 +01:00
Diana Carvalho
913d677ffb feat: Support Curve ETH
Curve pools use a different address from ETH (native token)

- Pass Chain into the SwapEncoderBuilder and SwapEncoder
- Add native_token_curve_address and native_token_address to CurveSwapEncoder
- Added integration test for this curve case

--- don't change below this line ---
ENG-4306 Took 1 hour 4 minutes


Took 11 seconds
2025-04-08 09:30:29 +01:00
Diana Carvalho
1e47d0e25b feat(curve): Add integration test
Bonus fix of a shameful typo :|

--- don't change below this line ---
ENG-4306 Took 21 minutes
2025-04-08 09:30:29 +01:00
Diana Carvalho
e9bb8c576a feat(curve): Add CurveEncoder
We don't know the pool tokens in the ProtocolComponent, so we can't infer the indexes correctly. Added a call to the MetaRegistry curve contract to get the correct token indexes. To do this, I had to move the get_client to utils. We could actually refactor the transaction logic into its' own struct and use it here and in the approval logic
It was assumed that all the pools will have a "factory" static attribute, even if empty

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


Took 27 seconds
2025-04-08 09:30:29 +01:00
TAMARA LIPOWSKI
b397ddd2be fix: fix Solution.router_address for Ekubo 2025-04-02 11:24:12 +02:00
TAMARA LIPOWSKI
8865e22116 feat: Make EncodingContext.router_address optional 2025-04-02 11:24:04 +02:00
die-herdplatte
485e5fd13e Merge remote-tracking branch 'upstream/main' into ekubo 2025-03-29 10:31:33 +01:00
kayibal
0836bf7d53 feat: switch to tycho_commons 2025-03-27 16:58:34 +01:00
die-herdplatte
47d96c2347 Add integration test 2025-03-26 16:50:03 +01:00
die-herdplatte
92b5a8adb5 Remove split check 2025-03-26 12:15:50 +01:00
die-herdplatte
9e6af4b99f cargo fmt & clippy 2025-03-20 14:18:15 +01:00
die-herdplatte
ce7362ef24 Error on unsupported options 2025-03-20 14:17:20 +01:00
die-herdplatte
af5742550f Add encoder tests 2025-03-20 11:27:06 +01:00
die-herdplatte
e954bc7e59 Fix attribute name 2025-03-20 11:26:52 +01:00
die-herdplatte
3c982c5824 Ekubo integration 2025-03-20 09:58:40 +01:00
Diana Carvalho
9eb4299ffe fix: the key for univ4 fee is key_lp_fee
Update tests with new executor addresses as well

--- don't change below this line ---
ENG-4260 Took 6 minutes
2025-02-27 11:49:03 +00:00
royvardhan
892726e07b chore: cleanup 2025-02-24 21:41:19 +05:30
royvardhan
570aa50497 test: fix encoder tests after removing the selector 2025-02-24 20:48:55 +05:30
royvardhan
18efe0305b fix: usv4 integration tests and remove selector from swap/strategy encoder 2025-02-24 19:48:25 +05:30
TAMARA LIPOWSKI
2c92596681 chore: merge main 2025-02-20 12:33:59 -05:00
TAMARA LIPOWSKI
d65d575003 feat: Don't encode min amount for USV4
We aren't checking min amount for any other executor. This would be overkill (since we are already checking in the main router) and also inconsistent.
2025-02-20 12:15:40 -05:00
royvardhan
29bc662ba9 refactor: use chain and protocol component from tycho_core::models 2025-02-20 22:36:50 +05:30
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
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
royvardhan
f7ddace559 feat: early return in usv4 swap encoder for second swap, add utils 2025-02-19 21:42:13 +05:30
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
royvardhan
789416b2cd feat: add usv4 swap encoder with single swap test 2025-02-18 20:58:00 +05:30
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
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
TAMARA LIPOWSKI
44e8e0bb96 docs: Address comments, make clippy happy 2025-02-05 15:44:27 -05:00
TAMARA LIPOWSKI
52cce5f5c6 docs: (WIP) In-code docs for encoders
- TODO double check all this, look for missing docs
2025-02-04 18:14:32 -05:00
Diana Carvalho
23875b8b02 feat: Refactor Registries
Interface changes:
- Rename StrategySelector to StrategyEncoderRegistry
- Implement clone for SwapEncoder

The StrategyEncoderRegistry needs to be initialised at the highest level and the passed to the TychoEncoder.
The TychoEncoder doesn't hold the chain nor the signer_pk as attributes anymore
The StrategyEncoderRegistry does:
- Initialises the SwapEncoderRegistry
- Initialises all the strategies and saves them in a HashMap
- Later, the TychoEncoder only reads from this hashmap

The StrategyEncoder now each holds a SwapEncoderRegistry as an attribute and they use this to get the correct SwapEncoder instead of reading from the global SWAP_ENCODER_REGISTRY

Simplified the SwapEncoderRegistry to not need a Config (everything is done inside itself)
All SwapEncoders implement clone

Took 2 hours 29 minutes

Took 11 seconds

Took 2 minutes
2025-02-04 17:30:10 +00:00
royvardhan
6333072178 feat: add swap encoder test in balancer v2 executor 2025-02-04 19:56:52 +05:30