@@ -55,6 +55,7 @@ contract MinimalRouter is SafeCallback {
55
55
? key.currency0.settle (poolManager, sender, amountIn, false )
56
56
: key.currency1.settle (poolManager, sender, amountIn, false );
57
57
58
+ // execute the swap
58
59
poolManager.swap (
59
60
key,
60
61
IPoolManager.SwapParams ({
@@ -69,18 +70,9 @@ contract MinimalRouter is SafeCallback {
69
70
int256 delta0 = poolManager.currencyDelta (address (this ), key.currency0);
70
71
int256 delta1 = poolManager.currencyDelta (address (this ), key.currency1);
71
72
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 );
84
76
85
77
// account for prepaid input against the observed deltas
86
78
BalanceDelta returnDelta = toBalanceDelta (int128 (delta0), int128 (delta1))
0 commit comments