Skip to content

Commit 4fc52da

Browse files
committed
use largest amount of tokens possible
1 parent 20f1bbf commit 4fc52da

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

test/AsyncCSMM.t.sol

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ contract AsyncCsmmTest is SetupHook {
6060
vm.stopPrank();
6161
}
6262

63-
function testFuzzAsyncSwap(uint256 amount, bool zeroForOne) public {
64-
vm.assume(amount >= 1);
65-
vm.assume(amount <= 1 ether);
66-
67-
AsyncOrder memory order =
68-
AsyncOrder({ key: key, owner: user, zeroForOne: zeroForOne, amountIn: amount, sqrtPrice: 2 ** 96 });
63+
function testFuzzAsyncSwap(AsyncOrder memory order) public {
64+
vm.assume(order.amountIn >= 1);
65+
vm.assume(order.amountIn < 2 ** 128 / 2);
66+
topUp(order.owner, order.amountIn);
67+
topUp(user2, order.amountIn);
68+
user = order.owner;
69+
order.key = key;
6970

7071
uint256 balance0Before = currency0.balanceOf(user);
7172
uint256 balance1Before = currency1.balanceOf(user);
@@ -76,14 +77,14 @@ contract AsyncCsmmTest is SetupHook {
7677
uint256 balance0After = currency0.balanceOf(user);
7778
uint256 balance1After = currency1.balanceOf(user);
7879

79-
if (zeroForOne) {
80-
assertEq(balance0Before - balance0After, amount);
80+
if (order.zeroForOne) {
81+
assertEq(balance0Before - balance0After, order.amountIn);
8182
assertEq(balance1Before, balance1After);
8283
} else {
83-
assertEq(balance1Before - balance1After, amount);
84+
assertEq(balance1Before - balance1After, order.amountIn);
8485
assertEq(balance0Before, balance0After);
8586
}
86-
assertEq(hook.asyncOrders(poolId, user, zeroForOne), amount);
87+
assertEq(hook.asyncOrders(poolId, user, order.zeroForOne), order.amountIn);
8788
assertEq(hook.setExecutor(user, asyncFiller), true);
8889

8990
balance0Before = currency0.balanceOf(user2);
@@ -95,19 +96,19 @@ contract AsyncCsmmTest is SetupHook {
9596
balance0After = currency0.balanceOf(user2);
9697
balance1After = currency1.balanceOf(user2);
9798

98-
if (zeroForOne) {
99+
if (order.zeroForOne) {
99100
assertEq(balance0Before, balance0After);
100-
assertEq(balance1Before - balance1After, amount);
101-
assertEq(hook.asyncOrders(poolId, user, zeroForOne), 0);
101+
assertEq(balance1Before - balance1After, order.amountIn);
102+
assertEq(hook.asyncOrders(poolId, user, order.zeroForOne), 0);
102103
} else {
103104
assertEq(balance1Before, balance1After);
104-
assertEq(balance0Before - balance0After, amount);
105-
assertEq(hook.asyncOrders(poolId, user, zeroForOne), 0);
105+
assertEq(balance0Before - balance0After, order.amountIn);
106+
assertEq(hook.asyncOrders(poolId, user, order.zeroForOne), 0);
106107
}
107-
if (zeroForOne) {
108-
assertEq(manager.balanceOf(user, currency0.toId()), uint256(amount));
108+
if (order.zeroForOne) {
109+
assertEq(manager.balanceOf(user, currency0.toId()), uint256(order.amountIn));
109110
} else {
110-
assertEq(manager.balanceOf(user, currency1.toId()), uint256(amount));
111+
assertEq(manager.balanceOf(user, currency1.toId()), uint256(order.amountIn));
111112
}
112113
}
113114

test/SetupHook.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ contract SetupHook is Test {
4848
}
4949

5050
function mint() public ownerAction {
51-
token0.mint(owner, 100 ether);
52-
token1.mint(owner, 100 ether);
51+
token0.mint(owner, 2 ** 128 - 1);
52+
token1.mint(owner, 2 ** 128 - 1);
5353
}
5454

5555
function deployPoolManager() public {

0 commit comments

Comments
 (0)