Weekly Margin Log #3
Ultramarkets Weekly Margin Log #3 — Blackbox audit trail for full position lifecycle observability, liquidation vs. stop-loss race condition fix, PII security patch, market event grouping, position recovery contracts, and emergency refund pipeline. Product updates for March 14–20, 2026.
Ultramarkets Weekly Margin Log #3 - product updates for the week of March 14 to 20, 2026. Blackbox audit trail, liquidation priority engine, market event grouping, position recovery contracts, and more.
This week's shipping log from Ultramarkets.
This is log #3. If you missed the earlier ones: Log #1 | Log #2
This was an observability and safety week. We shipped the Blackbox - a structured audit trail that records every step of every position's lifecycle in one place. We also killed a race condition between liquidation and stop-loss, and shipped a handful of trader-facing improvements. Here's the full breakdown.
Blackbox Audit Trail
This is the most important piece of infrastructure we've shipped since the TWAP price guard.
Here's the problem it solves. When a trade fails - or worse, fails silently - debugging it means cross-referencing across separate systems for: latest position state, fund movements, wallet signing, and on-chain transactions. A single incident could take 30–60 minutes of detective work, jumping between dashboards, matching timestamps, tracing transaction hashes across contexts. That's fine when you have 20 traders. It does not scale to thousands. This had to be implemented with high urgency.
Now every position writes its own flight record. Each pipeline step - opening, lending, buying, closing, selling, repaying - automatically logs its start time, end time, success or failure, duration, and all key identifiers: transaction hashes, ledger IDs, order IDs, error messages. One chronological timeline per position. Automated anomaly detection layer is next.
If you've built margin infrastructure before, you know the pattern: the hardest bugs aren't the ones that crash. They're the ones where a step completes "successfully" but the downstream state is wrong, and you don't find out until a trader opens a support ticket three hours later. The Blackbox makes those bugs visible in minutes instead of hours.
Liquidation vs. Stop-Loss Priority Engine
This one was a real bug in production.
Liquidation and stop-loss were running as independent monitors with no coordination. When a position hit both thresholds simultaneously - which happens more often than you'd think in volatile prediction markets - the system could try to execute both at once. Two processes fighting to close the same position.
Justice, our CTO, flagged the behavior in our engineering channel. The fix spanned three PRs and established a clear hierarchy: liquidation always takes strict priority over stop-loss and take-profit. The position is now locked before queueing liquidation to prevent double-processing, and rollback logic for ambiguous cancel operations was hardened.
This matters because margin protocols live and die on liquidation reliability. If the vault's enforcement mechanism can race-condition itself into an undefined state, the entire risk model breaks down. The priority engine protects against internal execution conflicts. Both are vault safety infrastructure.
Market Event Grouping
Trader request. Polymarket events often have multiple outcome brackets - a Fed rate decision might have five or more possible ranges, all for the same meeting. Previously these showed up scattered across the feed with no visual relationship. Now we group brackets of the same event together. Backend matches on Polymarket's event ID, frontend renders the group as a single collapsible unit. Small change, big readability improvement when scanning markets.
Trade History Per Market
New endpoint exposing Polymarket trade history for each market. This is groundwork for showing position entry and exit history in the app - where you got in, where you got out, what the P&L looked like.
We also migrated the Polymarket integration from slugs to market IDs. Slugs were changing on the Polymarket side and silently breaking our API calls. Market IDs are stable. If you've worked with third-party APIs, you know: never build on a field that the upstream provider treats as mutable.
Position Recovery Contracts
On-chain methods to revert closed positions back to open and rehabilitate cancelled positions. Previously, a position stuck in a bad state required manual interventions - slow, error-prone, admin-only. Now an emergency operator role is able to trigger recovery directly through the contract.
This was built after real incidents where positions got wedged. It's the kind of tooling you never want to need and always want to have.
Emergency Refund Pipeline
Migration to transfer USDC from sender accounts to a designated refund recipient. Built after the ghost-fill incident showed the need for a clean fund-return path. When positions need unwinding outside normal flows - cancelled fill, failed settlement - we needed a way to return funds without ad-hoc manual transfers. Now there's a pipeline for it.
Smaller Fixes
MoonPay modal crash. The deposit modal was crashing the app on close. Root cause was in Privy's component - it destructures a field from a response object, but when a user hits the back arrow instead of X, that object comes back undefined. We’ve made a small fix to handle the crash gracefully and removed the success toast that kept showing for a deposit that never actually happened.
Email issues. Grammar errors across transactional templates got through copy review. Separately, we hit Resend's rate limit sending weekly wrap emails to the full user base - now batching sends.
Light theme UI bugs. Long/short button hover states, header decoration strip, and accent button hovers were broken in white theme and these have now been fixed. Shoutout to our designer who raised these PRs 🙌🏻
Time-left indicator. Countdown icon on markets now only appears when resolution is within 24 hours. Less visual noise on markets that aren't close to expiry.
That's week 3. The Blackbox is the foundation for a lot of what we're building next on the operational side. If you're in the private beta, you're already trading on top of it.
Comments ()