Commit Graph

581 Commits

Author SHA1 Message Date
Diana Carvalho
d4244a7089 fix: Fix tests (not there yet)
Took 58 minutes
2025-05-16 17:57:29 +01:00
TAMARA LIPOWSKI
eeebd51114 feat: perform all transfers in executors
For organization (and thus safety) purposes.

Rename to RestrictTransferFrom.sol so that we can perform multiple transfer froms (upto an allowance) in the case of split swaps (where the split is the first swap).

TODO: Fix tests.
2025-05-16 11:59:54 -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
TAMARA LIPOWSKI
9b59b8b434 Revert "chore: Remove permit2 from executor constructor..."
This reverts commit b0b98c5e5d.
2025-05-16 11:23:43 -04:00
Diana Carvalho
fcd85c047f chore: Misc improvements:
- Don't use payable(receiver).transfer(amount) and use OpenZeppelin's Address.sendValue instead
- In Univ4Executor send funds to the poolManager and not msg.sender
- In OneTransferFromOnly:
  - rename method name
  - don't pass the sender but hardcode it to caller() (msg.sender)
  - Move marking the transfer as done up (before we actually transfer) to prevent reentrancy attacks

Took 18 minutes
2025-05-16 10:49:49 +01:00
Tamara
99d5df4f77 Merge branch 'main' into audit/dc/one-transfer-from-only 2025-05-15 13:47:42 -04:00
TAMARA LIPOWSKI
ec3d04d565 chore: remove author from docs 2025-05-15 13:44:51 -04:00
TAMARA LIPOWSKI
7c26e56a85 test: Ensure revert when attempting two transferFroms 2025-05-15 13:36:34 -04:00
Diana Carvalho
0b5233ead4 chore: Improve docstrings and decode bools always the same way
Took 26 minutes
2025-05-15 18:01:27 +01:00
TAMARA LIPOWSKI
7fd9f611e5 fix: Initial balance for cyclic swaps
This needs to be calculated before we perform a transferFrom in the router! This worked before since we were doing the transferFroms always from inside the executors.
2025-05-15 13:00:03 -04:00
TAMARA LIPOWSKI
d21ae45a49 chore: remove unnecessary sender encoding in USV3 2025-05-15 12:59:04 -04:00
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