Merge branch 'main' into router/hr/ENG-4280-gas-test

This commit is contained in:
Harsh Vardhan Roy
2025-03-05 21:32:40 +05:30
committed by GitHub
11 changed files with 84 additions and 40 deletions

View File

@@ -59,7 +59,9 @@ error TychoRouter__AddressZero();
error TychoRouter__AmountZero();
error TychoRouter__EmptySwaps();
error TychoRouter__NegativeSlippage(uint256 amount, uint256 minAmount);
error TychoRouter__AmountInNotFullySpent(uint256 leftoverAmount);
error TychoRouter__AmountInDiffersFromConsumed(
uint256 amountIn, uint256 amountConsumed
);
error TychoRouter__MessageValueMismatch(uint256 value, uint256 amount);
error TychoRouter__InvalidDataLength();
@@ -163,9 +165,10 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
uint256 amountConsumed = initialBalance - currentBalance;
if (amountConsumed < amountIn) {
uint256 leftoverAmount = amountIn - amountConsumed;
revert TychoRouter__AmountInNotFullySpent(leftoverAmount);
if (amountConsumed != amountIn) {
revert TychoRouter__AmountInDiffersFromConsumed(
amountIn, amountConsumed
);
}
if (fee > 0) {

View File

@@ -983,7 +983,9 @@ contract TychoRouterTest is TychoRouterTestSetup {
vm.expectRevert(
abi.encodeWithSelector(
TychoRouter__AmountInNotFullySpent.selector, 400000000000000000
TychoRouter__AmountInDiffersFromConsumed.selector,
1000000000000000000,
600000000000000000
)
);