mirror of
https://github.com/luxfi/dex.git
synced 2026-09-24 00:26:31 +00:00
CRITICAL: the prior taker-only settlement debited the maker's resting order but NEVER credited the maker the taker's payment — a value hole on every two-sided fill (old test only audited the taker leg). FIX: per-account ledger in pkg/dchain (balance:/locked:/asset:/orderasset:; checked-int lockFromAvailable/unlockToAvailable/spendLocked) — a fill is a pure intra-D-Chain balance move, wei-exact on BOTH legs. settle.go (orderLock/settleFills/quoteUnitsCeil: lock>=spend), block.go custody gate (lock-before-match, unfunded→reject) + settleOrderEffects. rebuildBookFromDB now restoreIntegerLane() — RowToOrder didn't round-trip SizeUnits/RemainingUnits → makers from disk had a broken integer lane → nil-units fills settle refused. zapwire ADDITIVE custody frames (clob_deposit/withdraw/open_market); 4 frozen CLOB frames byte-untouched. Conservation tests (real VM) + live 1337 e2e (deposit→cross→maker-credited→withdraw 1100==1100→restart) green.