Skip to content

Commit 08252c3

Browse files
committed
cleanup example router
1 parent 68197e0 commit 08252c3

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

test/utils/MinimalRouter.sol

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ contract MinimalRouter is SafeCallback {
5555
? key.currency0.settle(poolManager, sender, amountIn, false)
5656
: key.currency1.settle(poolManager, sender, amountIn, false);
5757

58+
// execute the swap
5859
poolManager.swap(
5960
key,
6061
IPoolManager.SwapParams({
@@ -69,18 +70,9 @@ contract MinimalRouter is SafeCallback {
6970
int256 delta0 = poolManager.currencyDelta(address(this), key.currency0);
7071
int256 delta1 = poolManager.currencyDelta(address(this), key.currency1);
7172

72-
// primarily take the output token, and excess amounts for exact output swaps
73-
if (delta0 < 0) {
74-
key.currency0.settle(poolManager, sender, uint256(-delta0), false);
75-
} else if (delta0 > 0) {
76-
key.currency0.take(poolManager, sender, uint256(delta0), false);
77-
}
78-
79-
if (delta1 < 0) {
80-
key.currency1.settle(poolManager, sender, uint256(-delta1), false);
81-
} else if (delta1 > 0) {
82-
key.currency1.take(poolManager, sender, uint256(delta1), false);
83-
}
73+
// take the output
74+
if (delta0 > 0) key.currency0.take(poolManager, sender, uint256(delta0), false);
75+
if (delta1 > 0) key.currency1.take(poolManager, sender, uint256(delta1), false);
8476

8577
// account for prepaid input against the observed deltas
8678
BalanceDelta returnDelta = toBalanceDelta(int128(delta0), int128(delta1))

0 commit comments

Comments
 (0)