Commit Graph

133 Commits

Author SHA1 Message Date
TAMARA LIPOWSKI
ff3c7aa629 test: Split swap integration test 2025-01-31 11:34:50 -05:00
Diana Carvalho
c85c353e34 fix: Fix token index order in strategy encoding.
The contract relies on this order!!

Remove TODOs and comments

--- don't change below this line ---
ENG-4081 Took 1 hour 12 minutes


Took 12 seconds
2025-01-31 15:34:12 +00:00
TAMARA LIPOWSKI
4d697bfebf test: Router integration test with many TODOs 2025-01-31 15:34:12 +00:00
TAMARA LIPOWSKI
b01fa4cf04 test: Change some addresses to match contract test
- Use Alice's PK to match our router test, set her as the receiver too
- Component id should be a usv2 pool
- Use our router test's router address as the test's router address
- Use our test's contract (address(this)) as the sender
2025-01-31 15:34:12 +00:00
TAMARA LIPOWSKI
5d6f0c1673 fix: Fix selector - shouldn't contain spaces
I found this because I kept hitting the fallback function, meaning the selector wasn't recognized
2025-01-31 15:34:12 +00:00
TAMARA LIPOWSKI
5f3d4406bd fix: replace all unwraps with proper error handling
- Or more elegant assignments in place of the `.is_some()` and `.unwrap()` method.
2025-01-30 17:19:54 -05:00
Diana Carvalho
01d101acb5 chore: Move ple_encode to EVMStrategyEncoder
--- don't change below this line ---
ENG-4081 Took 3 minutes
2025-01-30 19:47:36 +00:00
Diana Carvalho
575c5bea5e fix: Use max instead of min to get the min_amount_out
between slippaged amount and checked amount
Save router's address as Bytes and not String

--- don't change below this line ---
ENG-4081 Took 7 minutes
2025-01-30 19:44:57 +00:00
Diana Carvalho
a28b54888e fix: Post merge's fixes
Because of the renaming, git couldn't identify the new files and handle the conflicts gracefully.
Copied implementation for ExecutorStrategyEncoder from main

Rollbacked on decision to encode the executor address and selector inside the SwapEncoders. This is only necessary for certain strategies. So it should be done at the strategy level

--- don't change below this line ---
ENG-4081 Took 35 minutes
2025-01-30 19:38:22 +00:00
Diana Carvalho
01df08deaa Merge remote-tracking branch 'origin/encoding/dc/ENG-4081-split-swap-strategy' into encoding/dc/ENG-4081-split-swap-strategy 2025-01-30 19:01:32 +00:00
TAMARA LIPOWSKI
5b86ae4ac5 docs: (split strategy test) better calldata comments
...for clarity and debugging purposes.
2025-01-30 12:45:36 -05:00
Diana Carvalho
8fd3deba70 Merge branch 'refs/heads/main' into encoding/dc/ENG-4081-split-swap-strategy
# Conflicts:
#	src/encoding/evm/router_encoder.rs
#	src/encoding/evm/strategy_encoder/encoder.rs
#	src/encoding/evm/strategy_encoder/selector.rs
#	src/encoding/strategy_encoder.rs

Took 2 minutes
2025-01-30 16:08:08 +00:00
royvardhan
9c35da0760 chore: rename straight_to_pool to direct_execution 2025-01-30 21:17:25 +05:30
royvardhan
8cb95f0950 feat: remove exact_out from USV2 2025-01-30 21:17:25 +05:30
royvardhan
95d45975ad chore: encoder test naming 2025-01-30 21:17:25 +05:30
royvardhan
4ef9b0b82f chore: use Bytes 2025-01-30 21:17:25 +05:30
royvardhan
1b8bf56c75 feat: resolve pr comments 2025-01-30 21:17:25 +05:30
royvardhan
0196767eff feat: add swap test with hex for univ2 executor 2025-01-30 21:17:25 +05:30
royvardhan
c482e21a5f feat: add univ2 executor test with hex 2025-01-30 21:17:25 +05:30
royvardhan
0007c4924c chore: update executor encoder tests 2025-01-30 21:17:25 +05:30
royvardhan
d2289c3765 chore: update test 2025-01-30 21:17:25 +05:30
royvardhan
ad70a0d5a8 feat: add executor encoder test 2025-01-30 21:17:25 +05:30
royvardhan
5c396512cf feat: update ExecutorEncoder interface and relevant types 2025-01-30 21:17:25 +05:30
Diana Carvalho
82e671df39 fix: Use abi_encode_packed in ple_encode()
--- don't change below this line ---
ENG-4081 Took 17 minutes
2025-01-30 15:39:07 +00:00
Diana Carvalho
6e8d2ede59 feat: Simplify router encoder
Don't make selector() a member of the StrategyEncoder trait. It is needed only for certain strategies. The strategy should manage it itself.

--- don't change below this line ---
ENG-4081 Took 17 minutes
2025-01-30 15:19:09 +00:00
Diana Carvalho
0e70e827a0 chore: Rename encoder to strategy/swap_encoder
This was confusing me when I had all of them open at the same time. Better to be extra explicit

--- don't change below this line ---
ENG-4081 Took 2 minutes
2025-01-30 13:19:09 +00:00
Diana Carvalho
7a8872cc41 fix: Don't leak evm specific code to interfaces(PrivateKeySigner, Chain)
Pass the signer's private key as a string around and only create a PrivateKeySigner inside Permit2 (where it's needed)
Use tycho-core Chain instead of Alloy ChainID. Create a temp method to convert between them
Create a EVMSwapEncoder that implements the executor_selector (that is evm specific)

--- don't change below this line ---
ENG-4081 Took 1 hour 7 minutes
2025-01-30 13:17:23 +00:00
Diana Carvalho
feb91cc639 feat: Implement SplitSwapStrategyEncoder
The strategy works as follows:
- Manage approvals needed
- Compute min amount (if check amount is any):
  - if slippage is defined, apply slippage on the expected amount and take the min value between that and the check amount
  - if not, it's just the check amount
- Iterate through the swaps
  - call the corresponding swap encoder to encode the swap
  - add swap header (tokens indexes and split)
  - ple encode the swaps
- Add extra inputs (amounts, token addresses, min amount, (un)wrap, number of tokens and receiver)

Misc:
- Move executor address and selector encoding inside the SwapEncoder
- Add default executor_selector to SwapEncoder
- Pass router address inside the SplitSwapStrategyEncoder
- Move Permit2 inside the SplitSwapStrategyEncoder. It is a responsibility and a specificity of the strategy to need permit2 approvals

--- don't change below this line ---
ENG-4081 Took 1 hour 21 minutes
2025-01-30 11:23:32 +00:00
TAMARA LIPOWSKI
cc979880e2 chore: Rename address_for_approvals -> router_address
When will this not be the router address that we use for approvals? It will always be the router address. address_for_approvals sounds to me very vague (which approvals?).
2025-01-21 16:35:19 -05:00
Diana Carvalho
af6d73a540 fix: Add RecoverableError
--- don't change below this line ---
ENG-4076 <#DTT#>
2025-01-17 17:02:44 +00:00
Diana Carvalho
bab5caa6f8 feat: Add EncodingError
Change method signatures to expect it and raise it where it makes sense

--- don't change below this line ---
ENG-4076 <#DTT#>
2025-01-17 17:00:52 +00:00
Diana Carvalho
38b8bb0e78 feat: Simplify StrategyEncoders and RouterEncoder
No more SingleSwapStrategyEncoder or SequentialStrategyEncoder
No more batch routing (so no need for batch permits as well). If multiple solutions are found, return multiple Transactions

--- don't change below this line ---
ENG-4076 <#DTT#>
2025-01-17 16:21:26 +00:00
Diana Carvalho
6c6ba21894 feat: Add evm feature gate
- Move all evm code inside evm directory
- StrategyEncoder:
  - Kept StrategyEncoder trait but created a new one: EVMStrategyEncoder to implement encode_protocol_header (that is evm specific).
  - All StrategyEncoders implement both traits now
  - Renamed DefaultStrategySelector -> EVMStrategySelector
- RouterEncoder:
  - Created a RouterEncoder trait and a EVMRouterEncoder that implements it
- Moved utils inside evm directory as well
- Renamed config.json -> executor_addresses.json and moved it to a higher config directory
- Make alloy optional and dependent on the evm feature gate

--- don't change below this line ---
ENG-4075 <#DTT#>
2025-01-17 12:52:39 +00:00