Commit Graph

23 Commits

Author SHA1 Message Date
pedrobergamini
504a4db702 chore: include partialFillOffset as part of user_data 2025-08-05 20:32:42 -03:00
pedrobergamini
4cb570edb1 chore: fix test filledTakerAmount extraction and decoding logic 2025-08-04 18:52:53 -03:00
Diana Carvalho
01ab5d22b1 fix: Move Bebop tests according to new setup
Encoding: integration tests are now separate and inside their own test folder
Execution: the final integration test should be inside of the protocol test file now and not in TychoRouterProtocolIntegration.t.sol. For this I had to move the BebopExecutionHarness.t.sol outside of the Bebop test file (because of imports)

Took 24 minutes

# Commit time for manual adjustment:
# Took 2 minutes
2025-06-24 10:42:09 +01:00
Diana Carvalho
df63b87569 fix: Add optimized_transfers_integration_tests.rs
I forgot these tests in the previous PR

Took 24 minutes
2025-06-23 15:34:11 +01:00
Diana Carvalho
1d263f8b4c fix: After rebase fixes
Took 6 minutes
2025-06-23 15:02:21 +01:00
Diana Carvalho
e09789f347 test: Refactor tests
- Move encoding integration tests to integration test folder (in the rust project)
- Move protocol integration tests be inside the protocol file. This way we can change the block without any problems and it is easier for integrators

Took 6 minutes

Took 6 minutes


Took 17 minutes
2025-06-23 15:02:20 +01:00
Diana Carvalho
c03df8aa1e feat: Add balancer v3 to transfer optimization constants
Also added a getForkBlock() on TychoRouterTestSetup.
 Moved the router balancer test inside the Balancer file and created a TychoRouterForBalancerV3Test to wrap it

Took 1 hour 10 minutes


Took 21 seconds
2025-06-06 10:41:35 +01:00
Diana Carvalho
269e328b5f feat: Add integration tests for balancer v3
Refactor BalancerV3Executor to have an inner _swapCallback method with the real swapping logic. Then we have two external methods:
- handleCallback: called by the router. Here we need to remove the first 68 bytes (4 selector + 32 dataOffset + 32 dataLength)
- swapCallback: called by the Vault directly if we are swapping against the executor directly (no router involved)

Took 1 minute
2025-06-05 17:22:17 +01:00
Diana Carvalho
4f85e3e88e chore: Move tests from strategy_encoders to tycho_encoders
Most of these tests were actually integration tests, so they should be in the outer level of the package.

Took 1 hour 5 minutes
2025-05-26 17:08:44 +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
75f2c3a1c5 feat: Create non alloy specific Permit and PermitDetails structs
- Add try_from methods to convert them to the corresponding Solidity representations
- Update tests

Took 56 seconds
2025-05-23 11:31:05 +01:00
Diana Carvalho
4e8c6ddc8c feat: Separate encoding swaps from encoding txs
This way the user is responsible for encoding the Tycho Router method inputs that are used as guardrails in execution.

Interface changes:
- Create EncodedSolution
- StrategyEncoder
  - don't need to know have permit2 or token_in_already_in_router as attributes anymore
  - encode_strategy returns EncodedSolution now (no method encoding done here now)
- TychoEncoder
  - add encode_solution() method. This is the recommended method for users
  - needs to have permit2, token_in_already_in_router and router_address as attributes
  - permit creation is made in the router now

Also:
- create encoding_utils.rs
- update all tests

Took 2 hours 42 minutes


Took 3 minutes

Took 13 minutes
2025-05-22 14:43:12 +01:00
Diana Carvalho
cc9e88cfed feat: Add transferFromNeeded to non permit2 methods
This will block an attempt to transfer from the user when we expect the funds to already be in the router.

chores:
- add docs
- in EncodingContext, rename transfer to transfer_type

Took 58 minutes
2025-05-19 12:02:57 +01:00
TAMARA LIPOWSKI
e0c195f63d fix: Fix remaining tests after latest encoding changes 2025-05-16 14:14:21 -04:00
Diana Carvalho
38748925b3 feat: Bring back TransferType and simplify encoding logic
Took 1 hour 53 minutes
2025-05-16 16:59:35 +01:00
Diana Carvalho
09ff7691f8 chore: Make naming consistent: transfer_needed, approval_needed, etc
Took 46 minutes
2025-05-15 14:52:43 +01:00
TAMARA LIPOWSKI
4a0533b8ea chore: Remove transfer flag from curve + balancer
we will never perform a manual transfer into these protocols, as they require the tokens to be in the router contract in order to perform a transferFrom.
2025-05-15 09:15:32 -04:00
Diana Carvalho
ee687038c5 fix: Make all tests pass!
Delete TokenTransfer.sol
Make slither happy

Bugfixes:
- Executors
  - Ekubo:
    - Fix the POOL_DATA_OFFSET value and remove sender from callback data
    - Use SafeERC20
  - Maverick and Univ2: Use safeTransfer and not safeTransferFrom
  - Univ3: update expected data length
  - Univ4: update the selectors (the signature changed)
- Router:
  - For split swap we don't need to pass the tokenInReceiver, it should always be the router address
  - For single and sequential: change order of the parameters (to be before the permit2 specific objects)
- Encoders:
  - Update selector signatures
  - For split swap pass the transfer_from (we might not need to if the token in is ETH)

Took 2 hours 51 minutes
2025-05-15 13:11:34 +01:00
Diana Carvalho
0f9af65846 feat: Support new transfer logic in encoding
The transfer from the user into the router is supposed to happen in the router (we only support this in the executors for callback constrained protocols). This is necessary because of some security concerns that were found in the audit. This way we reduce the space of attack.
- Refactored TransferOptimization not to handle TransferTypes anymore but just return bools.
- Split get_transfer_type into get_transfers and get_in_between_transfer. Updates tests
- Updated the strategies to use this
- Updated function signatures to pass transfer_from and funds_receiver
- Updated SwapEncoders to handle this
- SplitSwapStrategy just assumes all tokens are sent to and from the router at all times

Took 2 hours 46 minutes
2025-05-14 18:00:19 +01:00
Diana Carvalho
079759a75b feat: Choose single strategy if it's a grouped swap of the same protocol
Add and update tests

--- don't change below this line ---
ENG-4478 Took 45 minutes


Took 10 seconds

Took 14 seconds
2025-05-05 12:15:33 +01:00
TAMARA LIPOWSKI
d09497faca chore: Load maverick calldata from file
- Also remove irrelevant comment
2025-04-30 11:18:04 -04:00
TAMARA LIPOWSKI
bcef8f69f6 feat: Transfer Optimizations in MaverickV2
- Also added integration test to test the optimizations, where we can see the in and out transfers being optimized if we enable verbose foundry testing
- Fixed typo in swap encoder builder initialization
2025-04-29 15:46:19 -04:00
Diana Carvalho
0ff4aef0c7 chore: Write encoding rust calldata to file and read in solidity test
This way we can automatically replace the calldata when something changes. We don't need to manually replace the string ourselves.

--- don't change below this line ---
ENG-4453 Took 3 hours 26 minutes
2025-04-29 10:23:47 +01:00