Six things a rescue does.
Each shown with the fork run's own figures, and where it was checked.
The account is a real 6-market account on dreamDEX's perps testnet, forked from block 33,472,615 and read at 33,472,616. The app runs the first three live and read-only for any address, and shows the last three from recorded runs.
Shock every market at once
Fixed absolute prices, bound to one block.
Set how far BTC and ETH move. The scenario fixes absolute prices for both and keeps every other held market at its reference mark, so no leg falls out of the arithmetic.
It is a canonical object with a SHA-256 id, bound to one block. After an execution the account is valued at the same prices again.
- Fixture scenario and rounding tests
- Fork every run binds its scenario id
Id 2d73979b848ff9b5…
Rebuild the account to the raw unit
From raw positions, marks and funding, with the bank's own rounding.
Health equity and every margin requirement are rebuilt from raw state, then compared with dreamDEX's MarginBank getter at the same block.
Any difference, a stale mark, a pool outside the bank's list or an unlisted stop blocks a recommendation instead of producing a confident wrong one.
- Live, read-only 4 real accounts exact
- Live, read-only 7,700 / 7,700 holders exact with floored PnL
| Figure | Rebuilt | Bank getter | Difference |
|---|---|---|---|
| Health equity | 1,019.202559 | 1,019.202559 | 0 |
| Maintenance | 492.100573 | 492.100573 | 0 |
| Initial | 984.201146 | 984.201146 | 0 |
| Close-out | 246.050286 | 246.050286 | 0 |
Price every reduction on the book
Filled now, valued at the scenario, smallest cut preferred.
Each candidate, 25 to 100% of each BTC or ETH position, is filled now against dreamDEX's order book with a protective limit 50 bps beyond the touch, paying fees per fill and settling funding the way the venue does. The rest of the account is then valued at the scenario prices.
Among the candidates that meet the target, the smallest cut is preferred. Reductions that make the scenario worse are flagged, and ones that cannot be filled say why.
- Fixture candidate tests
- Fork the preview matched the real fills exactly
Notional removed now, USDso, by the two cheapest fixes that meet the target
ETH −50% is preferred: 43% less exposure removed for the same goal
- Requested
- 0.8165 ETH
- Limit
- 2,305.06
- Expected fill
- 0.8165
- Cost now
- 0.07
- Buffer at scenario
- 6.48
- Meet the target
- 5 of 8
Reduce without flipping
An owner-bound guard that reverts a flip or a growth.
dreamDEX has no immediate reduce-only order. So the owner deploys a small guard, bound to their address, and grants it order placement on one pool through the OperatorPermissionsRegistry: the same grant dreamDEX's “Link a bot” writes.
The guard executes only if the live position still equals the confirmed one, and reverts the whole transaction, venue fills included, if the position would flip or grow. It holds no tokens and cannot withdraw.
- Fork 38 / 38 Solidity tests against the real venue, with traces
Allowed: same side, smaller, reduced by at most 0.8165
- Only the owner can call it, on the chain, bank and pools fixed at deployment
- Before the order: live position equals the confirmed one, opposite side, quantity no more than the position, on the lot, before the deadline
- After the fills: same side or flat, no larger, reduced by at most the quantity
- Each action id is used once; a reentrancy lock is held across the venue call
- A test harness that skips the preconditions makes the venue flip a position; the postcondition reverts all of it
Recompute from what filled
A receipt counts only once it is bound to the confirmation.
A receipt is credited only after it is bound to the saved confirmation: sender, guard, calldata, nonce, the guard's event and the taker's fills, decoded with the venue's own event definitions. Then the account is read at the receipt's block and every change has to be explained by the transaction itself.
The real remaining account is valued at the original scenario prices, beside the forecast and the account's actual health now.
- Fixture 19 tampered receipts refused
- Fork 6 alterations of a real receipt refused
- 0.4316 ETHat 2,316.64
- 0.3849 ETHat 2,316.50
Filled 0.8165 of 0.8165 ETH, inside the 2,305.06 limit
Buffer at the scenario prices, USDso
Stop safely when anything is unclear
Journalled before sending; unknown stays unknown.
Every transaction is journalled before it is sent. A changed account invalidates a confirmation before sending. A transaction whose outcome cannot be established stays unknown, and nothing else is sent until it is settled from chain data.
Cleanup closes positions only through the guard, revokes every grant, withdraws, and is verified at one block across all 21 pools.
- Fork 12 / 12 executor scenarios, including an RPC outage and a refused preflight
- Deploy the guard, verify its code33,472,621
- Approve and deposit 60 USDso33,472,622–23
- Open BTC long and ETH short33,472,624–25
- Grant the guard on BTC33,472,626
- Guarded reduction, goal met33,472,627
- Cleanup
- Close BTC and ETH through the guard33,472,628–30
- Revoke both grants, withdraw33,472,631–33
See it on your own account.
The app runs the first three live and read-only for any address, and shows the last three from recorded runs.
- dreamDEX componentsEvery contract, address and version it is built on.
- GuideThe app, the command line, and your own account.
- DashboardLive BTC and ETH markets and every proof.