Skip to content

Commit 7d238e7

Browse files
authored
fix(pool): correct sequence of callback and token transfer in pool swap (#1008)
1 parent b4683bb commit 7d238e7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contract/r/gnoswap/pool/v1/swap.gno

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,17 @@ func (i *poolV1) Swap(
238238
// receive token0 from swap callback
239239
// send token1 to recipient (output)
240240
if result.Amount1.IsNeg() {
241-
i.safeSwapCallback(pool, token0Path, result.Amount0.Abs(), zeroForOne, swapCallback)
242-
243241
i.safeTransfer(pool, recipient, token1Path, result.Amount1.Abs(), false)
242+
243+
i.safeSwapCallback(pool, token0Path, result.Amount0.Abs(), zeroForOne, swapCallback)
244244
}
245245
} else {
246246
// receive token1 from swap callback
247247
// send token0 to recipient (output)
248248
if result.Amount0.IsNeg() {
249-
i.safeSwapCallback(pool, token1Path, result.Amount1.Abs(), zeroForOne, swapCallback)
250-
251249
i.safeTransfer(pool, recipient, token0Path, result.Amount0.Abs(), true)
250+
251+
i.safeSwapCallback(pool, token1Path, result.Amount1.Abs(), zeroForOne, swapCallback)
252252
}
253253
}
254254

0 commit comments

Comments
 (0)