Commit Graph

95 Commits

Author SHA1 Message Date
Diana Carvalho
dfa0f7d176 chore: Address compilers warnings and use EXECUTOR_SETTER instead of Bob in tests
--- don't change below this line ---
ENG-4041 Took 48 seconds


Took 18 seconds
2025-01-28 16:59:29 +00:00
Diana Carvalho
d8de65aedf fix: Remove checkMinAmount
If minAmountOut == 0, then skip the check

--- don't change below this line ---
ENG-4041 Took 35 minutes
2025-01-28 16:59:29 +00:00
Diana Carvalho
50429ad05c feat: Add swap method with tests
Changes:
- If the tokenIn is ETH, skip permit2 approval
- Make executors payable: When using delegatecall the executor inherits the execution context of whoever calls it. Our main swap function can accept ETH, it needs to be payable so by consequence the executors also need to be.
- Set uniswap v2 executor in test router
- Add tests for all possible cases of swap
- Add tests for all cases of splitSwap
- Add test functions to handle permit2 and encode swaps

--- don't change below this line ---
ENG-4041 Took 3 hours 50 minutes

Took 49 seconds


Took 14 seconds
2025-01-28 16:59:29 +00:00
Diana Carvalho
a8f6fc1eec feat: Add swap method (first attempt)
Will add tests and fullproof it in a future PR

--- don't change below this line ---
ENG-4041 Took 8 minutes

Took 42 seconds

Took 5 seconds
2025-01-28 16:59:29 +00:00
Diana Carvalho
3b2d9fcbdf feat: Wrap and unwrap ETH
--- don't change below this line ---
ENG-4041 Took 2 hours 28 minutes

Took 14 seconds

Took 11 seconds

Took 2 minutes

Took 1 minute


Took 7 minutes
2025-01-28 16:59:29 +00:00
royvardhan
a4e405fb75 feat: add tests for Balancer V2 executor 2025-01-28 19:32:45 +05:30
royvardhan
5dc5e23239 fix: build 2025-01-28 18:57:59 +05:30
royvardhan
44db2e52b3 fix: rm exactOut 2025-01-28 18:32:28 +05:30
royvardhan
a700189aaf feat: add balancer v2 executor 2025-01-27 22:54:56 +05:30
Tamara
cb38be7ad6 Merge branch 'main' into router/tnl/ENG-4046-static-call-verifier 2025-01-27 10:21:15 -05:00
royvardhan
4ee337d1ee fix: ci 2025-01-27 20:44:01 +05:30
Harsh Vardhan Roy
68f07b1852 Merge branch 'main' into router/hr/ENG-4171-Implement-Pause 2025-01-27 20:40:36 +05:30
TAMARA LIPOWSKI
8ef061fd75 refactor: Move code check to CallbackVerificationDispatcher
[copied from exact same reasoning with execution code-checking]

I was inspired to do this because, when disabling the slither check for the staticcall when calling the callback verifier, I realized it's not clear from the same contract that we have already checked for contract code existence when setting the verifier. This made me feel uneasy, as this contract can then not stand alone and must rely on the higher level contract to safely check for code existence, otherwise the staticcall is unsafe. Keeping this logic in a separate contract seems error-prone to me, as we may remove the check for code existence without immediately realizing the implications of doing so.

For this reason I have organized it as follows:
- Logic/tests relating to proper roles/access control in the main TychoRouter.
- Lower-level logic/tests that check contract validity before setting the callback verifier in the CallbackVerificationDispatcher
2025-01-24 17:17:10 -05:00
TAMARA LIPOWSKI
ad0748e9c3 feat: Perform staticcall to CallbackVerifier 2025-01-24 16:55:21 -05:00
Diana Carvalho
9c2b205c30 chore: Rename all SwapExecutor to Executor only for simplicity
--- don't change below this line ---
ENG-4033 Took 9 minutes
2025-01-24 17:03:00 +00:00
Diana Carvalho
1ad04bc9e9 chore: After rebase fixes
--- don't change below this line ---
ENG-4033 Took 5 minutes
2025-01-24 17:03:00 +00:00
Diana Carvalho
b3241804c6 chore: Rename Uniswapv2SwapExecutor to UniswapV2Executor
--- don't change below this line ---
ENG-4033 Took 4 minutes
2025-01-24 17:03:00 +00:00
Diana Carvalho
ed44f4e993 fix: Add input validation size in Uniswapv2SwapExecutor
--- don't change below this line ---
ENG-4033 Took 12 minutes
2025-01-24 17:03:00 +00:00
Diana Carvalho
b9f4451769 fix: Remove exactOut logic from Uniswapv2SwapExecutor
We don't support it now

--- don't change below this line ---
ENG-4033 Took 9 minutes
2025-01-24 17:03:00 +00:00
Diana Carvalho
5627a1902b feat: UniswapV2 SwapExecutor
--- don't change below this line ---
ENG-4033 Took 52 minutes

Took 3 minutes

Took 5 minutes

Took 36 seconds

Took 2 minutes


Took 30 seconds
2025-01-24 17:03:00 +00:00
TAMARA LIPOWSKI
1fabff19c4 feat: Emit event when removing executor
- This is not so relevant for security, but it would sabotage our performance if an executor was wrongly removed, so it's worth it to know every time this happens.
2025-01-24 11:45:24 -05:00
TAMARA LIPOWSKI
5214710530 chore: docstrings and other small improvements 2025-01-24 11:39:49 -05:00
royvardhan
c982ed99e8 feat: add pause/unpause methods 2025-01-24 18:12:56 +05:30
TAMARA LIPOWSKI
fb9f340cb7 refactor: Move contract code-checking logic to SwapExecutionDispatcher
I was inspired to do this because, when disabling the slither check for the delegatecall when calling the swap executor, I realized it's not clear from the same contract that we have already checked for contract code existence when setting the executor. This made me feel uneasy, as this contract can then not stand alone and must rely on the higher level contract to safely check for code existence, otherwise the delegatecall is unsafe. Keeping this logic in a separate contract seems error-prone to me, as we may remove the check for code existence without immediately realizing the implications of doing so.

For this reason I have organized it as follows:
- Logic/tests relating to proper roles/access control in the main TychoRouter.
- Lower-level logic/tests that checks contract validity before setting the executor in the SwapExecutionDispatcher
2025-01-23 15:40:24 -05:00
TAMARA LIPOWSKI
b616e11354 fix: Silence slither warnings
- low level calls are fine, since we are checking for success, and we have already checked for contract existence when setting swap executors
- dead-code is silenced
- fix solidity version
2025-01-23 15:22:31 -05:00
TAMARA LIPOWSKI
825af0f8d7 test: Thorough tests for main SwapExecutionDispatcher method 2025-01-23 15:22:31 -05:00
TAMARA LIPOWSKI
e91ee96129 feat: delegatecall to executor in SwapExecutionDispatcher 2025-01-23 15:22:31 -05:00
royvardhan
056582ca2f feat: add tests for withdraw, fee and make it DRY 2025-01-23 21:04:05 +05:30
Harsh Vardhan Roy
193910e650 Merge branch 'main' into router/hr/ENG-4050-fee-methods 2025-01-23 15:04:11 +05:30
royvardhan
15d3becf60 fix: use FEE_SETTER_ROLE for setFeeReceiver 2025-01-23 15:00:47 +05:30
TAMARA LIPOWSKI
34243e9016 docs: remove mention of delegatecall from verifier doc
- Because we will more likely use a regular call (safer and delegatecall is unnecessary)
2025-01-22 14:21:49 -05:00
royvardhan
0dc7edccfa feat: add fee methods 2025-01-22 23:52:06 +05:30
TAMARA LIPOWSKI
59950a7575 feat: Emit events when setting executors/verifiers 2025-01-22 12:50:43 -05:00
TAMARA LIPOWSKI
4cb3286c94 feat: Set swap executors and verifiers
- Moved the deployment method into a test template for organization
- Created skeletons of dispatcher contracts
- Added all possible test cases for thoroughness
2025-01-22 12:23:22 -05:00
royvardhan
f3363a24f4 fix: disable slither for native withdraw 2025-01-22 22:14:10 +05:30
royvardhan
136adafa6d fmt 2025-01-22 22:09:05 +05:30
royvardhan
2c3af0ff31 feat: add receiver in event 2025-01-22 22:05:28 +05:30
royvardhan
c6c0ddd498 fix: use send for native transfer 2025-01-22 22:01:30 +05:30
royvardhan
0c05874477 fix: ci 2025-01-22 20:54:36 +05:30
royvardhan
78fa890cd3 feat: add withdraw methods 2025-01-22 20:33:24 +05:30
TAMARA LIPOWSKI
ab28a4730d feat: initial TychoRouter skeleton
- remappings.txt is used for more elegant imports
- decided not to include all helper methods in skeleton - just main swap method. They are properly documented in the jira tasks.
- add filter-paths to slither to exclude submodules, otherwise we will get slither warnings about permit2 and open-zeppelin using different solidity versions:

```
	- Version constraint ^0.8.20 is used by:
		-^0.8.20 (lib/openzeppelin-contracts/contracts/access/AccessControl.sol#4)
		-^0.8.20 (lib/openzeppelin-contracts/contracts/access/IAccessControl.sol#4)
		-^0.8.20 (lib/openzeppelin-contracts/contracts/utils/Context.sol#4)
		-^0.8.20 (lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol#4)
		-^0.8.20 (lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol#4)
	- Version constraint ^0.8.0 is used by:
		-^0.8.0 (lib/permit2/src/interfaces/IAllowanceTransfer.sol#2)
		-^0.8.0 (lib/permit2/src/interfaces/IEIP712.sol#2)
	- Version constraint ^0.8.28 is used by:
```
2025-01-20 17:21:46 -05:00
TAMARA LIPOWSKI
68dddc0663 chore: Rename TychoRouter typo
- Accidentally copy pasta'd
2025-01-17 17:58:12 -05:00
TAMARA LIPOWSKI
f987125489 fix: Bump to latest Solidity version (0.8.28)
Earlier versions have known vulnerabilities.

Slither output:
```
INFO:Detectors:
Version constraint ^0.8.13 contains known severe issues (https://solidity.readthedocs.io/en/latest/bugs.html)
	- VerbatimInvalidDeduplication
	- FullInlinerNonExpressionSplitArgumentEvaluationOrder
	- MissingSideEffectsOnSelectorAccess
	- StorageWriteRemovalBeforeConditionalTermination
	- AbiReencodingHeadOverflowWithStaticArrayCleanup
	- DirtyBytesArrayToStorage
	- InlineAssemblyMemorySideEffects
	- DataLocationChangeInInternalOverride
	- NestedCalldataArrayAbiReencodingSizeValidation.
It is used by:
	- ^0.8.13 (src/Counter.sol#2)
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity
INFO:Slither:foundry/ analyzed (2 contracts with 93 detectors), 1 result(s) found
```
2025-01-17 16:57:08 -05:00
TAMARA LIPOWSKI
2998bb3fb1 feat: Add Slither to README.md and include contract file to test 2025-01-17 16:39:21 -05:00
Diana Carvalho
e16d7ccb8e feat: Add foundry environment and CI 2025-01-17 09:50:26 +00:00