36 Commits

Author SHA1 Message Date
Diana Carvalho
5eb9973dbd feat: Add estimated_amount_in to Swap. Add SwapBuilder
Use SwapBuilder everywhere inside crate
Integration tests will be done later

--- don't change below this line ---
ENG-4696 Took 1 hour 56 minutes

Took 4 minutes
2025-08-13 18:05:17 +01:00
TAMARA LIPOWSKI
95c51247f7 fix: Replace smart pointer with regular pointer
Apparently was not necessary and was causing clippy warnings.

```
warning: you seem to be trying to use `&Box<T>`. Consider using just `&T`
  --> src/encoding/models.rs:91:32
   |
91 |     pub protocol_state: Option<&'a Box<dyn ProtocolSim>>,
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a dyn ProtocolSim`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
   = note: `#[warn(clippy::borrowed_box)]` on by default
   ```
2025-07-22 12:18:54 -04:00
TAMARA LIPOWSKI
c217702560 feat: Add protocol state to Swap object
- This consists of lots of necessary battles with lifetimes.
2025-07-22 12:13:39 -04:00
TAMARA LIPOWSKI
7aa292ef82 chore: small polishings to example
- Add note in readme that order will need to be encoded still
- Fix log
- Don't pass executors to builder
2025-07-14 11:24:05 -04:00
TAMARA LIPOWSKI
2d4b0b995b feat: UniswapX encoding example 2025-07-11 18:12:27 -04:00
Diana Carvalho
eec50f8822 feat: Extend Swap to hold user_data: Option<Bytes>
Took 25 minutes
2025-06-05 15:47:40 +01:00
Diana Carvalho
73c1a2db6a chore: Rename selector to function signature
Took 8 minutes
2025-05-27 09:37:24 +01:00
Diana Carvalho
c62af2f232 feat: Don't sign permit2 objects
We don't want to be responsible for holding private keys -> the user is the one that should do this outside of tycho-execution

Done:
- Remove signature from EncodedSolution
- Introduce UserTransferType and pass that everywhere instead of is_permit2_active and token_in_already_in_router
- Remove signing from permit2. Added it to the encoding_utils.rs only
- Mark encode_full_calldata as deprecated
- Backwards compatibility: still accept a signer for the encode_full_calldata case
- Update all tests

Took 2 hours 10 minutes


Took 13 minutes
2025-05-26 12:50:11 +01:00
Diana Carvalho
facdf716bd feat: Add interacting_with to EncodedSolution
- Remove encode_full_calldata from the TychoEncoder trait
- Make the TychoExecutorEncoder use encode_solutions instead of encode_full_calldata
- Update tycho-encode.rs accordingly

Took 1 hour 3 minutes


Took 12 seconds
2025-05-22 14:43:12 +01:00
Diana Carvalho
08056c4a6c feat: Remove slippage and expected_amount from Solution
The user is responsible for coming up with a sensible value for this themselves

Took 37 minutes
2025-05-22 14:43:12 +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
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
Diana Carvalho
c0b50c0661 fix: Add empty dicts for unichain and base in config
Also fix example: we need a checked amount or slippage set now

--- don't change below this line ---
ENG-4332 Took 6 minutes
2025-04-08 16:18:44 +01:00
TAMARA LIPOWSKI
d5c589d2c0 feat: Remove router_address from Solution, set default
- The router address can be set when creating the SplitSwapStrategy, which now takes an Option<Bytes> as input during initialization (another breaking interface change)
- This change allows us to change our router address in the future with minimal effect on the users. Users should only pass the router address in the split swap initialization if they intend to use their own router for execution.
- This change also means that the router address does not need to be passed with the solution, even when using the executor strategy (which was pointless).
- I thought of having a router_address() method to set this in the encoder builder - but it seemed too messy, since we don't need the router address for execution for example. We would then potentially unnecessarily load and set the default router address when not needed. It is also not even used at the highest level EVMTychoEncoder, so it makes more sense for it to be directly associated with the swap strategy instead.
- Users will now not be able to encode for different routers without re-initializing the strategy. We assumed this use case to be very rare and not worth supporting.
2025-04-02 11:18:30 +02:00
kayibal
0836bf7d53 feat: switch to tycho_commons 2025-03-27 16:58:34 +01:00
Diana Carvalho
6f572eed01 feat: Rename shortcut methods of encoder builder
Also moved executors_file_path to be an independent attribute

--- don't change below this line ---
ENG-4286 Took 19 minutes
2025-03-03 12:59:42 +00:00
Diana Carvalho
36d2f23fba docs: Clean up readme and rename quickstart->encoding example
--- don't change below this line ---
ENG-4261 Took 17 minutes
2025-02-28 09:57:06 +00:00
Diana Carvalho
918bc27e39 chore: Don't call Chain TychoCoreChain unnecessarily
--- don't change below this line ---
ENG-4255 Took 2 minutes
2025-02-20 18:31:28 +00:00
Diana Carvalho
20e6419a20 feat: Adapt SplitSwapStrategyEncoder to have optional permit2 logic
- If the signer_pk is not passed -> use the swap method that expects the tokens to be already in the Router
- If it is passed -> compute permit2 and use swap method that does the token in transfer
- Extend builder to have another shortcut
- Add integration test with contract
- Update bin (and simplified it) and quickstart

--- don't change below this line ---
ENG-4255 Took 1 hour 51 minutes

Took 2 minutes

Took 7 seconds
2025-02-20 18:29:11 +00:00
royvardhan
29bc662ba9 refactor: use chain and protocol component from tycho_core::models 2025-02-20 22:36:50 +05:30
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
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
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
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
c8a200dc55 docs: Add mention to the quickstart in the main README.md
--- don't change below this line ---
ENG-4088 Took 5 minutes
2025-02-07 16:16:55 +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
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
4680a4be24 feat: Make executors_file_path optional and use a default value if None
--- don't change below this line ---
ENG-4088 Took 4 minutes

Took 59 seconds
2025-02-07 12:16:46 +00:00
TAMARA LIPOWSKI
1a07c7dc61 Fix: Do not let user specify the native/wrapped token
This puts too much burden on the user. Instead, specify native and wrapped tokens as methods which return hardcoded values.
2025-02-06 11:08:06 -05:00
TAMARA LIPOWSKI
e83b8d9aef feat: Take Chain object containing native/wrapped addresses
- This way this chain object contains everything we need, we don't need to worry about doing any transformation or calling any supplementary functions inside any of the encoders
- Needed to move our new Chain object to a higher level since this is used in the higher-level encoder traits. This required some weird default values in the constants in order to avoid using alloy's hex literal. I could have instead opted to make Bytes parse a string I think, though this would mean possibly returning an error at the constants level, which is not nice either.

Question:
- Do we want the user to be in charge of passing the native and wrapped token every single time? This may be a bit annoying for the user. For now, I have defaulted to those in constants.rs, this would take 5 mins to remove though if you don't like it, and it would get rid of this complicated bytes initialization.
2025-02-05 17:14:56 -05:00
TAMARA LIPOWSKI
f8b3baff55 chore: merge main 2025-02-05 13:48:00 -05:00
Diana Carvalho
3dcb8aee7b chore: Use tycho_core::dto objects instead of tycho_core::models
--- don't change below this line ---
ENG-4169 Took 11 minutes
2025-02-05 10:10:43 +00:00
TAMARA LIPOWSKI
8cd7d9f76e feat: Get native/wrapped addresses from chain
- These were being hardcoded to ETH and WETH, which may not always be the case for EVM-compatible chains.
2025-02-04 16:59:01 -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
Diana Carvalho
80454f012d feat: Add complex swap to quickstart example
--- don't change below this line ---
ENG-4087 Took 16 minutes
2025-02-03 10:55:37 +00:00
Diana Carvalho
84d162d418 feat: Add simple quickstart example
--- don't change below this line ---
ENG-4087 Took 14 seconds
2025-01-31 18:42:23 +00:00