Our encoding uses PLE for subsequent swaps in a swap group. The EkuboExecutor assumes hard-coded hop length, which did not match the encoding side - leading to corrupted calldata in any swap after the first swap.
- Instead, add a new attribute to the builder, constants, and executor addresses json
- This was a miscommunication. Regular pools will still have the same name - only those with hooks will have hook appended to it
Make specific quotes that are expected to be used by the TychoRouter for the tests. Do not use the BebopHarness
Commented out Aggregate tests
Took 6 hours 40 minutes
- Needed to change the integration test setup to use two USV3 pools instead of one V3 and V2, since the V2 pool was taking too much fees for the order to be fulfilled.
- Also needed to change the fork block to make this test work, which meant also needing to update the data for the existing testExecute.
- Needed to update the filler address with the one from the test
- Removed unnecessary approval from non-integration test. The approval is now performed in the callback method.
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
- 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
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
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
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
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
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
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.
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
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