Merge pull request #99 from propeller-heads/router/hr/ENG-4291-amount-consumed-check
This commit is contained in:
@@ -59,7 +59,9 @@ error TychoRouter__AddressZero();
|
|||||||
error TychoRouter__AmountZero();
|
error TychoRouter__AmountZero();
|
||||||
error TychoRouter__EmptySwaps();
|
error TychoRouter__EmptySwaps();
|
||||||
error TychoRouter__NegativeSlippage(uint256 amount, uint256 minAmount);
|
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__MessageValueMismatch(uint256 value, uint256 amount);
|
||||||
error TychoRouter__InvalidDataLength();
|
error TychoRouter__InvalidDataLength();
|
||||||
|
|
||||||
@@ -163,9 +165,10 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
|
|||||||
|
|
||||||
uint256 amountConsumed = initialBalance - currentBalance;
|
uint256 amountConsumed = initialBalance - currentBalance;
|
||||||
|
|
||||||
if (amountConsumed < amountIn) {
|
if (amountConsumed != amountIn) {
|
||||||
uint256 leftoverAmount = amountIn - amountConsumed;
|
revert TychoRouter__AmountInDiffersFromConsumed(
|
||||||
revert TychoRouter__AmountInNotFullySpent(leftoverAmount);
|
amountIn, amountConsumed
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fee > 0) {
|
if (fee > 0) {
|
||||||
|
|||||||
@@ -895,7 +895,9 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
|||||||
|
|
||||||
vm.expectRevert(
|
vm.expectRevert(
|
||||||
abi.encodeWithSelector(
|
abi.encodeWithSelector(
|
||||||
TychoRouter__AmountInNotFullySpent.selector, 400000000000000000
|
TychoRouter__AmountInDiffersFromConsumed.selector,
|
||||||
|
1000000000000000000,
|
||||||
|
600000000000000000
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user