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
- 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
This came from a reported bug where the single strategy was being chosen for a solution on a groupable protocol (univ4) but the solution was composed of 2 splits only. Like a trade from WETH to USDC through two different univ4 pools
Took 47 minutes
Took 15 seconds
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
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
- 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
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
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
Add transfer in Executor and pass receiver address in encoding
This is done by using the TAKE action instead of TAKE_ALL
--- don't change below this line ---
ENG-4315 Took 1 hour 36 minutes
Took 2 minutes
- For protocols like Balancer and Curve, which expect funds to be in the router at the time of swap, we must support also transferring funds from the user into the router. Doing this in the router would mean we are dealing with transfers in two different places: in the router main methods and in the executors. To avoid this, we are now performing transfers just in the executors, and two transfer types have been added to support transfers into the router.
TODO:
- Add this for Balancer and Curve (only added for USV4 atm).
- TODO consider renaming TRANSFER_FROM and TRANSFER_PERMIT2 to include "pool" in the name
- Also do some renamings and comment improvements:
transfer method -> type
- Remove integration tests since we no longer support direct calls to USV3 executor, even for testing.
- The tycho router address default is set at the EncoderBuilder level (not inside the strategies)
- Rename TychoCoreChain to TychoCommonChain
- Only take TychoCommonChain as an argument at the outermost level: EncoderBuilder. Everywhere else we use the execution Chain right away
--- don't change below this line ---
ENG-4332 Took 1 hour 10 minutes
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