Skip to content

Commit b4683bb

Browse files
authored
fix(pool): update reentrancy lock in swap (#1006)
1 parent 11097d6 commit b4683bb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ func (i *poolV1) Swap(
159159
return "0", "0"
160160
}
161161

162+
// Apply reentrancy lock to the actual pool state
162163
slot0Start.SetUnlocked(false)
164+
pool.SetSlot0(slot0Start)
163165

164166
// Call swap start hook if set
165167
if i.store.HasSwapStartHook() {
@@ -172,7 +174,10 @@ func (i *poolV1) Swap(
172174
}
173175

174176
defer func() {
175-
slot0Start.SetUnlocked(true)
177+
// Release reentrancy lock on the actual pool state
178+
slot0End := pool.Slot0()
179+
slot0End.SetUnlocked(true)
180+
pool.SetSlot0(slot0End)
176181

177182
if i.store.HasSwapEndHook() {
178183
swapEndHook := i.store.GetSwapEndHook()

0 commit comments

Comments
 (0)