Commit Graph

470 Commits

Author SHA1 Message Date
dianacarvalho1
aec512c386 Merge branch 'main' into router/dc/ENG-4454-remove-executor-script 2025-05-15 16:18:33 +01:00
TAMARA LIPOWSKI
69c8325a1d chore: OneTransferFromOnly docs + proper slots
Also revert instead of returning if multiple `transferFrom`s are attempted - as this signals that encoding is incorrect or has been messed with.
2025-05-15 10:08:40 -04:00
Diana Carvalho
6cff470999 Merge branch 'refs/heads/main' into audit/dc/one-transfer-from-only
# Conflicts:
#	foundry/src/executors/TokenTransfer.sol

Took 38 seconds
2025-05-15 14:53:18 +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
TAMARA LIPOWSKI
b0b98c5e5d chore: Remove permit2 from executor constructor...
whenever not needed.
2025-05-15 08:23:55 -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
TAMARA LIPOWSKI
27dfde3118 feat: Support new transfer logic in all executors
TODO:
- Fix failing tests
- Remove permit2 from initialization of contracts
2025-05-14 20:42:19 -04: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
9401ce2620 feat: Sketch for OneTransferFromOnly.sol
Took 49 seconds
2025-05-14 11:22:54 +01:00
Diana Carvalho
b0c254add4 fix: Revert if the TransferType is not valid
Took 8 minutes
2025-05-14 09:03:18 +01:00
Diana Carvalho
65bd0d0749 feat: Explicitly handle the TransferType.NONE case
Took 8 minutes
2025-05-14 09:03:17 +01:00
Diana Carvalho
70230bf05f feat: Verify the amount out was received correctly for arbitrage swaps
Took 25 minutes


Took 3 minutes

Took 23 seconds
2025-05-14 09:03:17 +01:00
Diana Carvalho
444fc2d7b0 docs: Add comment on receive() in CurveExecutor
Took 9 minutes
2025-05-12 10:48:07 +01:00
Diana Carvalho
f14c8ee29b feat: Remove special handling of the Univ4 callback
The problem was that the pool manager was expecting an ABI encoded result to be returned and we were not returning that (we were returning just a result)
Special thanks to Max for figuring this out

Took 31 minutes
2025-05-09 10:48:54 +01:00
Diana Carvalho
30b8f9dd19 chore: Add script to remove executor addresses from Tycho Router
--- don't change below this line ---
ENG-4454 Took 1 hour 6 minutes
2025-05-08 15:11:07 +01:00
dianacarvalho1
d077929b6a Merge branch 'main' into router/dc/ENG-4492-remove-self-maverick 2025-05-06 13:53:12 +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
dianacarvalho1
b5cd53de11 Merge branch 'main' into router/tnl/deploy-pancake-v2 2025-05-05 10:11:28 +01:00
Diana Carvalho
0125118d22 chore: Remove unused self from MaverickV2Executor
--- don't change below this line ---
ENG-4492 Took 7 minutes
2025-05-05 10:06:10 +01:00
Diana Carvalho
04000059e5 feat: Change revert condition in _wrapETH
--- don't change below this line ---
ENG-4476 Took 1 minute
2025-05-02 12:48:03 +01:00
Diana Carvalho
8a7c39052d feat: Propagate the entire result of the callback
--- don't change below this line ---
ENG-4476 Took 41 minutes
2025-05-02 12:47:03 +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
Tamara
b6a3ce624d Merge branch 'main' into feat/maverick-v2-executor 2025-04-29 12:01:20 -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
TAMARA LIPOWSKI
872aa576e6 feat: Update PancakeV2 executor addresses 2025-04-28 17:41:31 -04:00
TAMARA LIPOWSKI
ba19b000dc fix: pass permit2 in deployment scripts
- Also deploy PancakeV2 (update in config) on ethereum
2025-04-28 17:23:54 -04:00
Tamara
b27e6c62ec Merge branch 'main' into router/tnl/reset-transient-storage 2025-04-28 09:32:35 -04:00
Tamara
87d6ead4c7 Merge branch 'main' into router/tnl/rename-dispatcher-methods 2025-04-28 08:56:08 -04:00
TAMARA LIPOWSKI
1b003dc483 feat: Clear transient storage after swap call
- This was originally remaining if no callback was performed, possible resulting in unexpected behaviour and an increased attack surface.
- Also specify nonzero slot for transient storage in order to reduce the risk of dangerous slot collision.
2025-04-25 21:39:09 -04:00
TAMARA LIPOWSKI
8b55d90608 chore: rename dispatcher methods for clarity 2025-04-25 21:07:48 -04:00
TAMARA LIPOWSKI
732450670f chore: remove outdated docstring 2025-04-25 18:33:14 -04:00
TAMARA LIPOWSKI
4de1d10406 feat: Add security check for callback selector
- Do not allow any callback to be chosen, for security and clarity purposes
2025-04-25 11:02:12 -04:00
TAMARA LIPOWSKI
3fb17c71da fix: Remove tload from executor
- Store the executor address when deploying instead.
- We would like to keep all instances of tload and tstore within the callback mechanism of our main TychoRouter contract for security reasons and to prevent any unexpected behaviour
- This way it's easy to reason that UniswapV4Executor will only ever execute a delegatecall to itself. Before it could in theory execute a delegatecall to any address. One had to look at all occurences of tstore(0, x) to ensure the address was constrained.
2025-04-24 16:57:08 -04:00
Diana Carvalho
fa872f5f0e chore: move single tests to TychoRouterProtocolIntegration.t.sol
They were in TychoRouterSplitSwap.t.sol
Add docs to _balancerOf

Took 2 hours 8 minutes


Took 18 seconds
2025-04-24 13:06:50 +01:00
Diana Carvalho
02cbb67b38 fix: After merge test fixes
Took 11 minutes
2025-04-23 12:31:53 +01:00
dianacarvalho1
fc249d5977 Merge branch 'main' into router/tnl/more-protocol-integration 2025-04-23 12:31:53 +01:00
TAMARA LIPOWSKI
132eed4bb9 test: 5-hop Multi-protocol integration test
- Needed to add ekubo and uniswap v4 to callback-limited protocols.
- I had to bump the fork block in all of our integration tests: The way it was before meant that certain integration tests were using certain executor addresses, and others were using different ones, because of the redeployment. This was a pain to account for on the rust side. Instead, all tests now use an Ekubo-compatible fork block. Values needed to be updated because of price changes between blocks.
2025-04-23 12:31:53 +01:00
TAMARA LIPOWSKI
d5d6e37041 fix: Changes after rebase 2025-04-23 12:31:53 +01:00
TAMARA LIPOWSKI
af68016223 fix: Tighten max feeBps in USV2 executor
Value was too lenient. We are assuming no forks will have higher fees than the original USV2.
2025-04-23 12:31:53 +01:00
TAMARA LIPOWSKI
4f9785fdac fix: Configurable fee on USV2 executor.
- This fee is not the same depending on the fork. For example, Pancake V2 uses a 0.25% fee, while the USV2 fee is 0.3%. We were wrongly hard-coding this fee to 0.3%.
2025-04-23 12:31:53 +01:00
Diana Carvalho
7614e36f18 Merge branch 'refs/heads/main' into feature/gas-optimization
# Conflicts:
#	foundry/src/Dispatcher.sol
#	foundry/test/executors/CurveExecutor.t.sol

Took 4 minutes

Took 12 seconds
2025-04-23 12:31:51 +01:00
dianacarvalho1
4a3a8ac6a6 Merge pull request #172 from propeller-heads/router/tnl/ENG-4443-usv3-executor-swap
feat: Make USV3 callback work with direct executor call
2025-04-23 12:31:42 +01:00
Diana Carvalho
d024fe240b fix: Post rebase fixes
--- don't change below this line ---
ENG-4437 Took 2 minutes
2025-04-23 12:31:42 +01:00
TAMARA LIPOWSKI
5562dd210e feat: Make USV3 callback work with direct executor call
- We have decided to now support calling our executors normally (without using delegatecalls) since they now support specifying token transfers.
- This was disabled for UniswapV3 in the past also because of data decoding issues. This seems to be the solution, though.
2025-04-23 12:31:42 +01:00
Diana Carvalho
eb2c17d0ba docs: Add comment to delegatecall in UniV4 executor
--- don't change below this line ---
ENG-4437 Took 8 minutes
2025-04-23 12:31:42 +01:00
Diana Carvalho
4a61de56b7 feat: Support using the TransferType in uniswap v4
Update tests

--- don't change below this line ---
ENG-4437 Took 1 hour 3 minutes

Took 2 minutes
2025-04-23 12:31:42 +01:00
Diana Carvalho
cebacc68fe test: Add integration test for it
--- don't change below this line ---
ENG-4446 Took 12 minutes
2025-04-23 12:31:42 +01:00
Diana Carvalho
cd608cb8e9 feat: Do not use V4Router for uniswap v4
Do our own implementation. In the end this is much cleaner than I expected and I was able to do a few improvements:
- we don't need to use actions. using function selectors and delegate call instead
- we don't need to convert into V4 Router types
- we don't need to check balances to get the amount out, we can just use the returned value

--- don't change below this line ---
ENG-4437 Took 3 hours 56 minutes


Took 3 minutes

Took 11 minutes
2025-04-23 12:31:42 +01:00