Commit a067c24
Edward (Mike's bot)
fix(order-book): zero unsettled_* before token transfers in settle_funds (CEI)
settle_funds was setting market_user.unsettled_base = 0 and unsettled_quote = 0
*after* the transfer_checked CPIs. Solana CPIs are not reentrant in the
EVM sense, but checks-effects-interactions is still the right discipline:
if either transfer ever gained a path that called back into this program
(custom token hooks, transfer-fee extension with a side effect, a future
ext we don't anticipate), having the unsettled_* counters still readable
mid-transfer would let a re-entry double-withdraw the balance.
Snapshot the amounts into locals, zero the counters, then issue the
transfers. The instruction stays atomic via Solana's tx semantics \u2014 if a
transfer fails the whole tx unwinds, counters and all.
No semantic change in the success path. Tests still pass 24/24.1 parent 8f73fa3 commit a067c24
1 file changed
Lines changed: 9 additions & 2 deletions
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
13 | 20 | | |
14 | 21 | | |
| 22 | + | |
| 23 | + | |
15 | 24 | | |
16 | 25 | | |
17 | 26 | | |
| |||
39 | 48 | | |
40 | 49 | | |
41 | 50 | | |
42 | | - | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
| |||
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
60 | | - | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| |||
0 commit comments