Commit Graph

270 Commits

Author SHA1 Message Date
TAMARA LIPOWSKI
ec3d04d565 chore: remove author from docs 2025-05-15 13:44:51 -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
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
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
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
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
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
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
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
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
Diana Carvalho
eb1aa6cdcd chore: Correct typo in all balancerAfter/Before (again)
--- don't change below this line ---
ENG-4314 Took 1 hour 14 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
d447551e20 fix: Bring back receiver address zero check
Add small docs and rename variables

--- don't change below this line ---
ENG-4314 Took 1 hour 39 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
8145f416b7 fix: After rebase fixes
- In Tycho Router
  - Fix integration tests
  - If the trade is cyclical, we can't do the balance check for the correctness of the amountOut transfers
- In encoding,
  - if it is a wrap trade, the transfer should be just a normal Transfer (not TransferFrom nor a Permit2Transfer)
  - add test names to println! statements

--- don't change below this line ---
ENG-4315 Took 1 hour 0 minutes

Took 30 seconds

Took 21 seconds

Took 16 seconds


Took 17 seconds
2025-04-23 12:31:41 +01:00
Diana Carvalho
ec87969aa6 feat: Add transfer out for Uniswap V4
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
2025-04-23 12:31:41 +01:00
Diana Carvalho
328a281a44 feat: Add transfer out for Curve
Add transfer in Executor and pass receiver address in encoding
Remove integration test with StETH pool because we don't support it at simulation level and there is something weird with the amounts (that it is not worth it to investigate now)

--- don't change below this line ---
ENG-4315 Took 34 minutes

Took 2 minutes
2025-04-23 12:31:41 +01:00
Diana Carvalho
9bcb58e5aa feat: Support out transfer straight to the receiver
- The out transfer is now a responsibility of the Executors -> remove this from router methods
- Also adding a check that the receiver got the full amount out
- In encoding, if it is the last swap, pass the receiver as the trade receiver and not the router address (fix encoding tests)
- Fixed some solidity tests (after rebasing with a PR that is still open, I will fix them all)

TODO: Adapt curve and uniswap v4 to support this

--- don't change below this line ---
ENG-4315 Took 3 hours 7 minutes

Took 20 minutes

Took 59 seconds


Took 7 minutes
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
860bba4b7a fix: Add slither ignore for loop call
- This started being an issue only with slither upgrade in the CI. We accept the risk here, and have for some time.
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
be65c890bb fix: Calldata size for Ekubo pay callback
- And doc clarification
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
d9066d0a09 feat: Use TokenTransfer optimization helper in Ekubo 2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
30dc3f7682 chore: renamings for clarity
- Also added a check for length in the Curve executor.
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
3a73fef933 feat: Add TokenTransfer class to BalancerV2
- This needed to be in BalancerV2 so that the executor can also take care of transfers from the user into the tycho router, to avoid having transfer actions mixed between the router and executors
2025-04-23 12:31:41 +01:00
TAMARA LIPOWSKI
462be5463b feat: Add TokenTransfer class to Curve
- This needed to be in Curve so that the executor can also take care of transfers from the user into the tycho router, to avoid having transfer actions mixed between the router and executors
2025-04-23 12:31:41 +01:00