An import can deliver the same business event again. A unique key gives PostgreSQL a conflict to detect. ON CONFLICT DO NOTHING ignores a duplicate, while DO UPDATE applies an explicit replacement rule. Neither option can decide whether an older event should overwrite a newer one unless you encode that rule.
The EXCLUDED row holds the values you tried to insert. Refer to it when you update a conflicting target. Distinguish a replacement amount from a delta: adding a replayed replacement twice is a common accounting defect.
An INSERT statement can't update the same target row twice through ON CONFLICT DO UPDATE. Deduplicate a batch before upserting it. DISTINCT ON can choose the newest source record when you order by the business key and a deterministic timestamp. RETURNING identifies what the write changed so a caller can reconcile its batch.
A replay-safe ignore leaves the existing balance unchanged.