Commit Graph

40 Commits

Author SHA1 Message Date
TAMARA LIPOWSKI
9accc84346 docs: Clarify validation criteria for cyclical swaps 2025-03-26 09:56:44 +01:00
Diana Carvalho
e96bcdfd0f fix: Add individual tests for each case
(split output and native action)

--- don't change below this line ---
ENG-4331 Took 6 minutes
2025-03-14 11:30:19 +00:00
Diana Carvalho
27c9c53889 feat: Add check to don't support cyclical swaps with native actions
Remove unnecessary tests and improve comments

--- don't change below this line ---
ENG-4331 Took 30 minutes
2025-03-13 17:34:50 +00:00
Diana Carvalho
0aba7edf83 fix: In test asset, use 0 for the last split, and not 0.5
--- don't change below this line ---
ENG-4331 Took 5 minutes
2025-03-13 16:50:39 +00:00
Diana Carvalho
f62a9d28c0 feat: Add validation for cyclical trades
We only support cyclical trades when the repeated token is the first and the last token in the swap. We don't support cycles in between

--- don't change below this line ---
ENG-4331 Took 2 hours 4 minutes

(cherry picked from commit 55ffa4eb45)

Took 5 minutes


Took 2 minutes
2025-03-13 16:30:54 +00:00
Diana Carvalho
3d7dcef1bd Revert "feat: Add validation for cyclical trades"
This reverts commit 55ffa4eb45.

Took 5 minutes

Took 2 minutes

# Commit time for manual adjustment:
# Took 2 minutes
2025-03-13 16:26:06 +00:00
Diana Carvalho
55ffa4eb45 feat: Add validation for cyclical trades
We only support cyclical trades when the repeated token is the first and the last token in the swap. We don't support cycles in between

--- don't change below this line ---
ENG-4331 Took 2 hours 4 minutes
2025-03-13 16:13:28 +00:00
Diana Carvalho
05a1843f9c fix: Add a value to the Transaction if token in is ETH
not only if the action is unwrap

--- don't change below this line ---
ENG-4260 Took 11 minutes
2025-02-27 12:39:16 +00:00
royvardhan
0e049b7c44 chore: rm selector from Transaction 2025-02-24 22:20:51 +05:30
royvardhan
18efe0305b fix: usv4 integration tests and remove selector from swap/strategy encoder 2025-02-24 19:48:25 +05:30
Diana Carvalho
8b2af4f577 feat: Implement Clone for EVMTychoEncoder
--- don't change below this line ---
ENG-4255 Took 6 minutes
2025-02-20 18:29:14 +00:00
royvardhan
29bc662ba9 refactor: use chain and protocol component from tycho_core::models 2025-02-20 22:36:50 +05:30
royvardhan
83f1955094 feat: add native and weth addresses for supported networks 2025-02-20 21:54:33 +05:30
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
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
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
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
9adbab498c chore: merge main 2025-02-06 11:49:17 -05: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
2b43ecdf29 docs: Document validation functions 2025-02-05 16:44:28 -05:00
Tamara
021a179076 Merge branch 'main' into encoding/tnl/ENG-4205-code-docs 2025-02-05 16:35:54 -05:00
TAMARA LIPOWSKI
07457b5f76 docs: More docs and improvements of existing docs
- Tried not to leave a single public function undocumented, though did not double-document public function with obvious names
- Remove all mentions of the strategy selector in favour of the strategy registry (to avoid confusion)
2025-02-05 16:35:43 -05:00
TAMARA LIPOWSKI
44e8e0bb96 docs: Address comments, make clippy happy 2025-02-05 15:44:27 -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
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
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
79f513c76b chore: After rebase with master fixes
Took 2 minutes
2025-02-04 17:32:14 +00: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
TAMARA LIPOWSKI
06603210bc fix: test_validate_fails_for_unwrap_wrong_last_swap
ETH was the given token not the checked token, which was wrong.
2025-02-04 10:28:16 -05:00
TAMARA LIPOWSKI
7482d228f2 chore: merge main 2025-02-04 10:04:42 -05:00
TAMARA LIPOWSKI
f873bb5187 refactor: check given/checked tokens before swap tokens
It's a more intuitive order, since these are higher-level attributes.

Also remove the validation from the trait - it doesn't have to be part of the trait.
2025-02-04 10:01:38 -05:00
TAMARA LIPOWSKI
4bc615913e feat: Tycho encoder validation
Validates:
- Proper sequence of input, output, and first/last swap tokens for wrap/unwrap cases
- All solutions contain at least one swap
- Only exact in solutions are inputted (since we don't yet support exact out)
2025-02-03 17:04:00 -05:00
Diana Carvalho
1a8e0f102c chore: Make objects public
Remove dead_code check and leftover file after a merge
Improve some docstrings

--- don't change below this line ---
ENG-4087 Took 1 hour 39 minutes
2025-01-31 18:40:59 +00:00
Diana Carvalho
b047d9762e test: Add test for tycho encoder
Rename RouterEncoder to TychoEncoder

--- don't change below this line ---
ENG-4081 Took 21 minutes
2025-01-31 12:41:37 +00:00