return fee taken

This commit is contained in:
tim
2025-09-15 18:51:47 -04:00
parent 070717959e
commit fef6d007d8
3 changed files with 37 additions and 25 deletions

View File

@@ -453,12 +453,14 @@ contract PartyPoolTest is Test {
// Execute swap: token0 -> token1
vm.prank(alice);
(uint256 amountInUsed, uint256 amountOut) = pool.swap(alice, bob, 0, 1, maxIn, 0, 0);
(uint256 amountInUsed, uint256 amountOut, uint256 fee) = pool.swap(alice, bob, 0, 1, maxIn, 0, 0);
// Amounts should be positive and not exceed provided max
assertTrue(amountInUsed > 0, "expected some input used");
assertTrue(amountOut > 0, "expected some output returned");
assertTrue(amountInUsed <= maxIn, "used input must not exceed max");
// Fee should be <= amountInUsed
assertTrue(fee <= amountInUsed, "fee must not exceed total input");
// Alice's balance decreased by exactly amountInUsed
assertEq(token0.balanceOf(alice), balAliceBefore - amountInUsed);
@@ -492,10 +494,12 @@ contract PartyPoolTest is Test {
token0.approve(address(pool), type(uint256).max);
vm.prank(alice);
(uint256 amountInUsed, uint256 amountOut) = pool.swapToLimit(alice, bob, 0, 1, limitPrice, 0);
(uint256 amountInUsed, uint256 amountOut, uint256 fee) = pool.swapToLimit(alice, bob, 0, 1, limitPrice, 0);
assertTrue(amountInUsed > 0, "expected some input used for swapToLimit");
assertTrue(amountOut > 0, "expected some output for swapToLimit");
// Fee should be <= amountInUsed (gross includes fee)
assertTrue(fee <= amountInUsed, "fee must not exceed total input for swapToLimit");
// Verify bob got the output
assertEq(token1.balanceOf(bob) >= amountOut, true);