diff --git a/CHANGELOG.md b/CHANGELOG.md index 3136c37..2b78d8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.35.1](https://github.com/propeller-heads/tycho-execution/compare/0.35.0...0.35.1) (2025-02-11) + + +### Bug Fixes + +* (TychoRouter) Revert if empty swaps ([37efe52](https://github.com/propeller-heads/tycho-execution/commit/37efe52c10ea9028f735c3cfc15af0bc9c57a745)) + ## [0.35.0](https://github.com/propeller-heads/tycho-execution/compare/0.34.0...0.35.0) (2025-02-07) diff --git a/Cargo.lock b/Cargo.lock index 8c6938f..ed1c6f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4340,7 +4340,7 @@ dependencies = [ [[package]] name = "tycho-execution" -version = "0.35.0" +version = "0.35.1" dependencies = [ "alloy", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index e96b000..70ac1b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tycho-execution" -version = "0.35.0" +version = "0.35.1" edition = "2021" [[bin]] diff --git a/foundry/src/TychoRouter.sol b/foundry/src/TychoRouter.sol index b15bdfa..4b8aa1f 100644 --- a/foundry/src/TychoRouter.sol +++ b/foundry/src/TychoRouter.sol @@ -17,6 +17,7 @@ import {LibSwap} from "../lib/LibSwap.sol"; error TychoRouter__WithdrawalFailed(); error TychoRouter__AddressZero(); +error TychoRouter__EmptySwaps(); error TychoRouter__NegativeSlippage(uint256 amount, uint256 minAmount); error TychoRouter__AmountInNotFullySpent(uint256 leftoverAmount); error TychoRouter__MessageValueMismatch(uint256 value, uint256 amount); @@ -191,6 +192,10 @@ contract TychoRouter is internal returns (uint256) { + if (swaps_.length == 0) { + revert TychoRouter__EmptySwaps(); + } + uint256 currentAmountIn; uint256 currentAmountOut; uint8 tokenInIndex = 0; diff --git a/foundry/test/TychoRouter.t.sol b/foundry/test/TychoRouter.t.sol index 5b5ad79..489d366 100644 --- a/foundry/test/TychoRouter.t.sol +++ b/foundry/test/TychoRouter.t.sol @@ -672,6 +672,13 @@ contract TychoRouterTest is TychoRouterTestSetup { assertGe(finalBalance, expAmountOut); } + function testEmptySwapsRevert() public { + uint256 amountIn = 10 ** 18; + bytes memory swaps = ""; + vm.expectRevert(TychoRouter__EmptySwaps.selector); + tychoRouter.exposedSwap(amountIn, 2, swaps); + } + function testSingleSwapIntegration() public { // Test created with calldata from our router encoder, replacing the executor // address with the USV2 executor address.