-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdex-contracts-external-flows.html
More file actions
1455 lines (1303 loc) · 109 KB
/
Copy pathdex-contracts-external-flows.html
File metadata and controls
1455 lines (1303 loc) · 109 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="utf-8" />
<title>DEX.DO External Contract Flows</title>
<style>
:root {
--bg: #f4efe3;
--bg2: #fffaf0;
--card: #fffdfa;
--ink: #1f2937;
--muted: #526071;
--border: #d7c6a3;
--accent: #0f766e;
--accent-fill: #ecfeff;
--event: #b91c1c;
--event-fill: #fff1f2;
--line: #475569;
--note-fill: #f8fafc;
--note-stroke: #94a3b8;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 32px;
color: var(--ink);
background:
radial-gradient(circle at top left, #fff6dd 0, #fff6dd 18%, transparent 42%),
linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
font-family: Georgia, "Times New Roman", serif;
line-height: 1.55;
}
main {
max-width: 1240px;
margin: 0 auto;
}
h1,
h2,
h3 {
font-family: "Helvetica Neue", Arial, sans-serif;
letter-spacing: 0.01em;
margin: 0 0 12px;
}
h1 {
font-size: 34px;
}
h2 {
font-size: 24px;
}
h3 {
font-size: 18px;
}
p {
margin: 0 0 12px;
}
a {
color: #8b4513;
}
.card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 18px;
padding: 24px;
margin: 22px 0;
box-shadow: 0 10px 30px rgba(54, 36, 10, 0.08);
}
.hero {
padding: 28px;
}
.hero p:last-child {
margin-bottom: 0;
}
.links {
display: flex;
gap: 18px;
flex-wrap: wrap;
margin-top: 14px;
font-family: "Helvetica Neue", Arial, sans-serif;
font-size: 14px;
}
.pill {
display: inline-block;
padding: 4px 10px;
border-radius: 999px;
background: #f5efe1;
border: 1px solid #dbc7a1;
margin: 0 8px 8px 0;
font-family: "Helvetica Neue", Arial, sans-serif;
font-size: 13px;
}
.legend {
display: flex;
gap: 18px;
flex-wrap: wrap;
margin-top: 10px;
font-family: "Helvetica Neue", Arial, sans-serif;
font-size: 14px;
color: var(--muted);
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
}
.legend-box {
width: 30px;
height: 16px;
border-radius: 8px;
border: 3px solid var(--event);
background: var(--event-fill);
}
.legend-line {
width: 34px;
border-top: 2px solid var(--line);
}
table {
width: 100%;
border-collapse: collapse;
font-size: 14px;
}
th,
td {
padding: 10px 12px;
border-bottom: 1px solid #eadcc3;
vertical-align: top;
}
th {
text-align: left;
font-family: "Helvetica Neue", Arial, sans-serif;
}
.muted {
color: var(--muted);
}
.diagram {
margin-top: 14px;
}
.diagram svg {
width: 100%;
height: auto;
display: block;
background: #fff;
border: 1px solid #eadcc3;
border-radius: 14px;
}
.caption {
margin-top: 10px;
color: var(--muted);
font-size: 14px;
}
@media (max-width: 900px) {
body {
padding: 18px;
}
.card {
padding: 18px;
}
}
</style>
</head>
<body>
<main>
<section class="card hero">
<h1>DEX.DO External Contract Flows</h1>
<p>Full HTML documentation for the stateful externally reachable entrypoints in `contracts/`. The focus here is not the contract structure as such but which runtime flows the external calls trigger, which callbacks they spawn, and where external events appear.</p>
<p>The diagrams are inline SVG with no external JS, so rendering is predictable locally. Red badges on the sequence diagrams are external `emit ...{dest: ...}` events; the destination address is written directly inside each event block, with no separate tables or captions below the diagrams.</p>
<div class="links">
<a href="dex-contracts-system.html">System Overview</a>
<a href="dex-contracts-object-diagram.drawio">Object Diagram (.drawio)</a>
<a href="dex-events-routing.md">Event Routing Tables</a>
</div>
<div style="margin-top: 14px;">
<span class="pill">RootPN</span>
<span class="pill">PrivateNote</span>
<span class="pill">Nullifier</span>
<span class="pill">RootOracle</span>
<span class="pill">Oracle</span>
<span class="pill">OracleEventList</span>
<span class="pill">PMP</span>
<span class="pill">OrderBook</span>
</div>
<div class="legend">
<div class="legend-item"><span class="legend-line"></span><span>call / callback</span></div>
<div class="legend-item"><span class="legend-box"></span><span>external event object (`emit ...{dest: ...}`)</span></div>
</div>
</section>
<section class="card">
<h2>Contract Map</h2>
<table>
<thead>
<tr>
<th>Contract</th>
<th>Role</th>
<th>Key deterministic keys</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>RootPN</strong></td>
<td>Root deployer for `PrivateNote`, `Nullifier`, and the vault flow.</td>
<td>`_depositIdentifierHash`, `_nullifierHash`</td>
</tr>
<tr>
<td><strong>PrivateNote</strong></td>
<td>User-side DEX wallet: stake, split/merge, claim, orders, transfer.</td>
<td>`_depositIdentifierHash`, `stakeHash = hash(eventId, oracleListHash, tokenType)`</td>
</tr>
<tr>
<td><strong>Nullifier</strong></td>
<td>One-shot relay for shell-fee top-up into `PrivateNote`.</td>
<td>`_nullifierHash`</td>
</tr>
<tr>
<td><strong>RootOracle</strong></td>
<td>Root deployer for `Oracle`.</td>
<td>`_name` on the downstream `Oracle`</td>
</tr>
<tr>
<td><strong>Oracle</strong></td>
<td>Oracle-owner contract that creates `OracleEventList`.</td>
<td>`_name`, `(_oracle, _index)` on `OracleEventList`</td>
</tr>
<tr>
<td><strong>OracleEventList</strong></td>
<td>Event registry and the oracle-confirmation entry point for PMP.</td>
<td>`(_oracle, _index)` for the contract address; `eventId` for the inner `EventInfo` entries</td>
</tr>
<tr>
<td><strong>PMP</strong></td>
<td>Prediction market pool, approvals, timings, resolve, split/merge.</td>
<td>`(eventId, oracleListHash, tokenType)`</td>
</tr>
<tr>
<td><strong>OrderBook</strong></td>
<td>Order book for a frozen market — queues, match/fill/cancel.</td>
<td>`(eventId, oracleListHash, tokenType)`, `orderId`, `clientOrderId`</td>
</tr>
</tbody>
</table>
</section>
<section class="card">
<h2>Coverage Map</h2>
<p>Below is a coverage map by flow group. The document includes every stateful externally reachable entrypoint: user/admin calls, oracle/governance calls, inter-contract callbacks, recovery hooks, and shutdown paths. Only read-only methods such as `getDetails(...)`, `getVersion(...)`, `getOrder(...)`, `getQueueSize(...)`, and the like are excluded.</p>
<table>
<thead>
<tr>
<th>Flow Group</th>
<th>Covered entrypoints</th>
<th>Where documented</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Bootstrap / voucher / fee top-up</strong></td>
<td>`RootPN.generateVoucher`, `RootPN.deployPrivateNote`, `RootPN.sendEccShellToPrivateNote`, `RootPN.privateNoteDeployed`, `Nullifier.constructor`, `PrivateNote.receive`</td>
<td>Section 1</td>
</tr>
<tr>
<td><strong>Oracle deployment and registry</strong></td>
<td>`RootOracle.deployOracle`, `Oracle.deployEventList`, `Oracle.withdrawFees`, `Oracle.receive`, `OracleEventList.addEvent`, `OracleEventList.deleteEvent`</td>
<td>Section 2</td>
</tr>
<tr>
<td><strong>Market deployment / first approval / reject / freeze</strong></td>
<td>`PrivateNote.deployPMP`, `PMP.constructor`, `OracleEventList.confirmEvent`, `OracleEventList.cancelEvent`, `PMP.approveEvent`, `PMP.rejectEvent`, `PMP.onBounce`, `PrivateNote.onInitialStakesAccepted`, `PrivateNote.onInitialStakesFailed`, `PrivateNote.onPmpCleanRefund`, `OrderBook.constructor`</td>
<td>Section 3</td>
</tr>
<tr>
<td><strong>Oracle governance on approved market</strong></td>
<td>`PMP.submitSetTimings`, `PMP.submitResolve`, `PMP.submitCancelEvent`, `OrderBook.setResultStart`</td>
<td>Section 4</td>
</tr>
<tr>
<td><strong>Stake / cancel / split / merge / claim</strong></td>
<td>`PrivateNote.setStake`, `PrivateNote.cancelStake`, `PrivateNote.claim`, `PrivateNote.splitFullSet`, `PrivateNote.mergeFullSet`, `PMP.acceptStake`, `PMP.cancelStake`, `PMP.claim`, `PMP.splitFullSet`, `PMP.mergeFullSet`, `PrivateNote.onStakeAccepted`, `PrivateNote.onStakeCancelled`, `PrivateNote.onClaimAccepted`, `PrivateNote.onSplitAccepted`, `PrivateNote.onMergeAccepted`, `PrivateNote.acceptFee`</td>
<td>Sections 5 and 10</td>
</tr>
<tr>
<td><strong>Order placement and fill</strong></td>
<td>`PrivateNote.placeOrder`, `PrivateNote.placeBatch`, `OrderBook.executeBatch`, `OrderBook.processHead`, `PrivateNote.onOrderPlaced`, `PrivateNote.onOrderFilled`, `PrivateNote.onBatchComplete`</td>
<td>Section 6</td>
</tr>
<tr>
<td><strong>Order cancel / reject / queue control / bounce</strong></td>
<td>`PrivateNote.cancelOrder`, `PrivateNote.cancelOrderByClient`, `PrivateNote.cancelBatch`, `PrivateNote.cancelAllOrders`, `OrderBook.cancelAllOrders`, `OrderBook.cancelByClientId`, `OrderBook.cancelQueued`, `PrivateNote.onOrderCancelled`, `PrivateNote.onOrderRejected`, `OrderBook.onBounce`, `PrivateNote.onBounce`</td>
<td>Section 7</td>
</tr>
<tr>
<td><strong>Transfer / withdraw / coupon / local admin</strong></td>
<td>`PrivateNote.initTransfer`, `PrivateNote.offerTransfer`, `PrivateNote.onTransferAccepted`, `PrivateNote.clearTransferBusy`, `PrivateNote.withdrawTokens`, `RootPN.withdrawTokens`, `PrivateNote.revertWithdraw`, `PrivateNote.changeOwner`, `PrivateNote.generateCoupon`, `PrivateNote.discardCoupon`, `PrivateNote.deleteStake`, `RootPN.updateCode`, `RootOracle.updateCode`</td>
<td>Sections 8 and 9</td>
</tr>
<tr>
<td><strong>Terminal shutdown</strong></td>
<td>`PMP.claim` tail-path, `OrderBook.shutdown`</td>
<td>Section 10</td>
</tr>
</tbody>
</table>
</section>
<section class="card">
<h2>1. Bootstrap, Voucher, Fee Top-Up</h2>
<p>This chain covers three separate flows: `PrivateNote` creation, shell-fee top-up via `Nullifier`, and voucher-event generation in `RootPN`.</p>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 920 470" role="img" aria-label="Vault and PrivateNote lifecycle">
<defs>
<marker id="arrow-vault" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-vault-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="40" y="20" width="140" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="240" y="20" width="140" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="440" y="20" width="140" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="640" y="20" width="170" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="110" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">User</text>
<text x="310" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">RootPN</text>
<text x="510" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Nullifier</text>
<text x="725" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PrivateNote</text>
<line x1="110" y1="60" x2="110" y2="430" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="310" y1="60" x2="310" y2="430" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="510" y1="60" x2="510" y2="430" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="725" y1="60" x2="725" y2="430" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="110" y1="95" x2="310" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-vault)" />
<text x="145" y="86" font-family="Arial" font-size="13">deployPrivateNote(...)</text>
<line x1="310" y1="140" x2="725" y2="140" stroke="#475569" stroke-width="2" marker-end="url(#arrow-vault)" />
<text x="430" y="131" font-family="Arial" font-size="13">new PrivateNote(...)</text>
<line x1="725" y1="185" x2="310" y2="185" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-vault)" />
<text x="455" y="176" font-family="Arial" font-size="13">privateNoteDeployed(...)</text>
<line x1="310" y1="215" x2="565" y2="215" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-vault-red)" />
<rect x="570" y="190" width="260" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="700" y="210" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">PrivateNoteDeployed</text>
<text x="700" y="226" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(101)</text>
<line x1="110" y1="270" x2="310" y2="270" stroke="#475569" stroke-width="2" marker-end="url(#arrow-vault)" />
<text x="132" y="261" font-family="Arial" font-size="13">sendEccShellToPrivateNote(...)</text>
<line x1="310" y1="315" x2="510" y2="315" stroke="#475569" stroke-width="2" marker-end="url(#arrow-vault)" />
<text x="360" y="306" font-family="Arial" font-size="13">new Nullifier(noteAddress)</text>
<line x1="310" y1="345" x2="565" y2="345" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-vault-red)" />
<rect x="570" y="320" width="248" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="694" y="340" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">NullifierDeployed</text>
<text x="694" y="356" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(102)</text>
<line x1="510" y1="390" x2="725" y2="390" stroke="#475569" stroke-width="2" marker-end="url(#arrow-vault)" />
<text x="555" y="381" font-family="Arial" font-size="13">transfer shell fee</text>
<line x1="110" y1="430" x2="310" y2="430" stroke="#475569" stroke-width="2" marker-end="url(#arrow-vault)" />
<text x="170" y="421" font-family="Arial" font-size="13">generateVoucher(...)</text>
<line x1="310" y1="430" x2="565" y2="430" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-vault-red)" />
<rect x="570" y="405" width="252" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="696" y="425" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">VoucherGenerated</text>
<text x="696" y="441" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(135)</text>
<rect x="22" y="402" width="250" height="46" rx="10" fill="#f8fafc" stroke="#94a3b8" stroke-width="2" stroke-dasharray="5 4" />
<text x="147" y="421" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">`Nullifier` does not emit any event objects of its own.</text>
<text x="147" y="438" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">After deploy it only forwards the shell-fee into `PrivateNote`.</text>
</svg>
</div>
</section>
<section class="card">
<h2>2. Oracle Deployment And Registry</h2>
<p>The Oracle branch consists of `RootOracle`, `Oracle`, and `OracleEventList`. `OracleEventList` is what stores the `EventInfo` records and confirms the market for PMP.</p>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 980 520" role="img" aria-label="Oracle deployment and event registry">
<defs>
<marker id="arrow-oracle" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-oracle-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="30" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="220" y="20" width="170" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="430" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="640" y="20" width="190" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="105" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Operator</text>
<text x="305" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">RootOracle</text>
<text x="505" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Oracle</text>
<text x="735" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">OracleEventList</text>
<line x1="105" y1="60" x2="105" y2="440" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="305" y1="60" x2="305" y2="440" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="505" y1="60" x2="505" y2="440" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="735" y1="60" x2="735" y2="440" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="105" y1="95" x2="305" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle)" />
<text x="160" y="86" font-family="Arial" font-size="13">deployOracle(pubkey, name)</text>
<line x1="305" y1="135" x2="505" y2="135" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle)" />
<text x="372" y="126" font-family="Arial" font-size="13">new Oracle(...)</text>
<line x1="305" y1="170" x2="555" y2="170" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-oracle-red)" />
<rect x="560" y="145" width="280" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="700" y="165" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">OracleDeployed</text>
<text x="700" y="181" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(136)</text>
<line x1="505" y1="225" x2="735" y2="225" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle)" />
<text x="560" y="216" font-family="Arial" font-size="13">constructor - new OracleEventList(0)</text>
<line x1="505" y1="260" x2="555" y2="260" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-oracle-red)" />
<rect x="560" y="235" width="300" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="710" y="255" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">OracleEventListDeployed</text>
<text x="710" y="271" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(104)</text>
<line x1="105" y1="315" x2="505" y2="315" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle)" />
<text x="235" y="306" font-family="Arial" font-size="13">deployEventList(index)</text>
<line x1="505" y1="350" x2="735" y2="350" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle)" />
<text x="562" y="341" font-family="Arial" font-size="13">new OracleEventList(index)</text>
<line x1="505" y1="385" x2="555" y2="385" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-oracle-red)" />
<rect x="560" y="360" width="300" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="710" y="380" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">OracleEventListDeployed</text>
<text x="710" y="396" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(104)</text>
<line x1="105" y1="430" x2="735" y2="430" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle)" />
<text x="295" y="421" font-family="Arial" font-size="13">addEvent(name, fee, deadline, describe, outcomeNames, trustAddr)</text>
<line x1="735" y1="455" x2="545" y2="455" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-oracle-red)" />
<rect x="550" y="430" width="270" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="685" y="450" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">EventAdded</text>
<text x="685" y="466" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(133)</text>
<rect x="22" y="458" width="250" height="38" rx="10" fill="#f8fafc" stroke="#94a3b8" stroke-width="2" stroke-dasharray="5 4" />
<text x="147" y="482" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">`EventPublished` is declared, but there is no `emit` in the current code.</text>
</svg>
</div>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 940 230" role="img" aria-label="Oracle fee withdraw and top-up">
<defs>
<marker id="arrow-oracle-mini" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
</defs>
<rect x="30" y="20" width="160" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="260" y="20" width="160" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="490" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="710" y="20" width="170" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="110" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Funder</text>
<text x="340" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Oracle Owner</text>
<text x="565" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Oracle</text>
<text x="795" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Wallet</text>
<line x1="110" y1="60" x2="110" y2="180" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="340" y1="60" x2="340" y2="180" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="565" y1="60" x2="565" y2="180" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="795" y1="60" x2="795" y2="180" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="110" y1="95" x2="565" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle-mini)" />
<text x="245" y="86" font-family="Arial" font-size="13">receive() - replenish native balance</text>
<line x1="340" y1="145" x2="565" y2="145" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle-mini)" />
<text x="395" y="136" font-family="Arial" font-size="13">withdrawFees(to, amount)</text>
<line x1="565" y1="175" x2="795" y2="175" stroke="#475569" stroke-width="2" marker-end="url(#arrow-oracle-mini)" />
<text x="635" y="166" font-family="Arial" font-size="13">transfer shell fees</text>
<rect x="250" y="182" width="440" height="30" rx="10" fill="#f8fafc" stroke="#94a3b8" stroke-width="2" stroke-dasharray="5 4" />
<text x="470" y="202" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">Both single-step flows mutate state/balance but do not emit external event objects.</text>
</svg>
</div>
</section>
<section class="card">
<h2>3. Market Deployment, Oracle Approval, Freeze</h2>
<p>`PrivateNote` creates the `PMP`, the `PMP` collects approvals from every `OracleEventList`, records the deployer's initial stakes on the first approval, then transitions into approved state, receives timings, and only after freezing brings up `OrderBook`.</p>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1160 520" role="img" aria-label="PMP deployment and approval success">
<defs>
<marker id="arrow-market" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-market-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="30" y="20" width="120" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="190" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="380" y="20" width="120" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="540" y="20" width="170" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="760" y="20" width="170" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="90" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">User</text>
<text x="265" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PrivateNote</text>
<text x="440" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PMP</text>
<text x="625" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">OracleEventList A</text>
<text x="845" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">OracleEventList B</text>
<line x1="90" y1="60" x2="90" y2="450" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="265" y1="60" x2="265" y2="450" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="440" y1="60" x2="440" y2="450" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="625" y1="60" x2="625" y2="450" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="845" y1="60" x2="845" y2="450" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="90" y1="95" x2="265" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-market)" />
<text x="118" y="86" font-family="Arial" font-size="13">deployPMP(...)</text>
<line x1="265" y1="120" x2="515" y2="120" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-market-red)" />
<rect x="520" y="95" width="260" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="650" y="115" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">PMPDeployed</text>
<text x="650" y="131" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(111)</text>
<line x1="265" y1="165" x2="440" y2="165" stroke="#475569" stroke-width="2" marker-end="url(#arrow-market)" />
<text x="302" y="156" font-family="Arial" font-size="13">new PMP(...)</text>
<line x1="440" y1="215" x2="625" y2="215" stroke="#475569" stroke-width="2" marker-end="url(#arrow-market)" />
<text x="470" y="206" font-family="Arial" font-size="13">confirmEvent(eventId, oracleListHash, tokenType)</text>
<line x1="625" y1="245" x2="485" y2="245" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-market-red)" />
<rect x="490" y="220" width="270" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="625" y="240" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">EventConfirmed</text>
<text x="625" y="256" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(106)</text>
<line x1="625" y1="300" x2="440" y2="300" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-market)" />
<text x="492" y="291" font-family="Arial" font-size="13">approveEvent(...)</text>
<line x1="440" y1="335" x2="265" y2="335" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-market)" />
<text x="300" y="326" font-family="Arial" font-size="13">onInitialStakesAccepted(...)</text>
<rect x="20" y="348" width="220" height="38" rx="10" fill="#f8fafc" stroke="#94a3b8" stroke-width="2" stroke-dasharray="5 4" />
<text x="130" y="372" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">The first approve records `initialStakes` for the creator note.</text>
<line x1="440" y1="390" x2="845" y2="390" stroke="#475569" stroke-width="2" marker-end="url(#arrow-market)" />
<text x="560" y="381" font-family="Arial" font-size="13">confirmEvent(...) second oracle</text>
<line x1="845" y1="420" x2="505" y2="420" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-market-red)" />
<rect x="510" y="395" width="270" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="645" y="415" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">EventConfirmed</text>
<text x="645" y="431" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(106)</text>
<line x1="845" y1="455" x2="440" y2="455" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-market)" />
<text x="625" y="446" font-family="Arial" font-size="13">approveEvent(...)</text>
<line x1="440" y1="485" x2="715" y2="485" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-market-red)" />
<rect x="720" y="460" width="300" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="870" y="480" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">ApprovedByOracle</text>
<text x="870" y="496" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(119)</text>
</svg>
</div>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1080 320" role="img" aria-label="PMP reject and cleanup">
<defs>
<marker id="arrow-market-fail" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-market-fail-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="40" y="20" width="180" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="290" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="500" y="20" width="210" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="790" y="20" width="160" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="130" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">OracleEventList / bounce</text>
<text x="355" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PMP</text>
<text x="605" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Confirmed OracleEventLists</text>
<text x="870" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Creator PN</text>
<line x1="130" y1="60" x2="130" y2="250" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="355" y1="60" x2="355" y2="250" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="605" y1="60" x2="605" y2="250" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="870" y1="60" x2="870" y2="250" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="130" y1="95" x2="355" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-market-fail)" />
<text x="190" y="86" font-family="Arial" font-size="13">rejectEvent() or bounced confirm path</text>
<line x1="355" y1="125" x2="615" y2="125" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-market-fail-red)" />
<rect x="620" y="100" width="290" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="765" y="120" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">PMPRejected</text>
<text x="765" y="136" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(132)</text>
<line x1="355" y1="175" x2="605" y2="175" stroke="#475569" stroke-width="2" marker-end="url(#arrow-market-fail)" />
<text x="430" y="166" font-family="Arial" font-size="13">cancelEvent(...) for already confirmed lists</text>
<line x1="355" y1="215" x2="870" y2="215" stroke="#475569" stroke-width="2" marker-end="url(#arrow-market-fail)" />
<text x="520" y="206" font-family="Arial" font-size="13">onInitialStakesFailed(refundTotal) if first approve never completed</text>
<rect x="24" y="245" width="540" height="38" rx="10" fill="#f8fafc" stroke="#94a3b8" stroke-width="2" stroke-dasharray="5 4" />
<text x="294" y="269" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">`OracleEventList.cancelEvent(...)` only decrements its local counter and does not produce an external event object.</text>
</svg>
</div>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 980 300" role="img" aria-label="PMP freeze and order book deployment">
<defs>
<marker id="arrow-freeze" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-freeze-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="30" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="250" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="450" y="20" width="170" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="700" y="20" width="160" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="105" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">User / Oracle quorum</text>
<text x="315" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PMP</text>
<text x="535" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Creator PN</text>
<text x="780" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">OrderBook</text>
<line x1="105" y1="60" x2="105" y2="230" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="315" y1="60" x2="315" y2="230" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="535" y1="60" x2="535" y2="230" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="780" y1="60" x2="780" y2="230" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="105" y1="95" x2="315" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-freeze)" />
<text x="140" y="86" font-family="Arial" font-size="13">first split / merge / resolve after stakeEnd</text>
<path d="M 315 125 C 380 125 380 160 315 160" fill="none" stroke="#475569" stroke-width="2" marker-end="url(#arrow-freeze)" />
<text x="328" y="117" font-family="Arial" font-size="13">_ensureFrozen()</text>
<line x1="315" y1="185" x2="535" y2="185" stroke="#475569" stroke-width="2" marker-end="url(#arrow-freeze)" />
<text x="355" y="176" font-family="Arial" font-size="13">onPmpCleanRefund(...)</text>
<line x1="315" y1="220" x2="780" y2="220" stroke="#475569" stroke-width="2" marker-end="url(#arrow-freeze)" />
<text x="470" y="211" font-family="Arial" font-size="13">new OrderBook(...)</text>
<line x1="315" y1="255" x2="610" y2="255" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-freeze-red)" />
<rect x="615" y="230" width="290" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="760" y="250" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">PoolsFrozen</text>
<text x="760" y="266" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(140)</text>
<rect x="30" y="248" width="250" height="30" rx="10" fill="#f8fafc" stroke="#94a3b8" stroke-width="2" stroke-dasharray="5 4" />
<text x="155" y="268" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">The same `_ensureFrozen()` can also fire from inside `setTimings()`.</text>
</svg>
</div>
</section>
<section class="card">
<h2>4. Oracle Governance Entry Flows</h2>
<p>After approval the market is governed by quorum mechanics inside `PMP`. The entry points here are not `private`: external messages into `submitSetTimings`, `submitResolve`, and `submitCancelEvent` collect votes from oracle signers or trusted addresses and only then flip the market's main state.</p>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1030 560" role="img" aria-label="Oracle timings and resolve quorum">
<defs>
<marker id="arrow-gov" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-gov-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="30" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="230" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="430" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="610" y="20" width="140" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="800" y="20" width="140" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="105" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Oracle A</text>
<text x="305" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Oracle B</text>
<text x="495" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PMP</text>
<text x="680" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">OrderBook</text>
<text x="870" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Deployer PN</text>
<line x1="105" y1="60" x2="105" y2="470" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="305" y1="60" x2="305" y2="470" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="495" y1="60" x2="495" y2="470" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="680" y1="60" x2="680" y2="470" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="870" y1="60" x2="870" y2="470" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="105" y1="95" x2="495" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov)" />
<text x="225" y="86" font-family="Arial" font-size="13">submitSetTimings(resultStart)</text>
<line x1="305" y1="130" x2="495" y2="130" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov)" />
<text x="344" y="121" font-family="Arial" font-size="13">submitSetTimings(resultStart)</text>
<path d="M 495 165 C 560 165 560 205 495 205" fill="none" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov)" />
<text x="508" y="157" font-family="Arial" font-size="13">quorum -> setTimings()</text>
<line x1="495" y1="225" x2="700" y2="225" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-gov)" />
<text x="556" y="216" font-family="Arial" font-size="13">setResultStart(resultStart) if frozen</text>
<line x1="495" y1="255" x2="700" y2="255" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-gov-red)" />
<rect x="705" y="230" width="280" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="845" y="250" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">TimingsSet</text>
<text x="845" y="266" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(124)</text>
<line x1="105" y1="315" x2="495" y2="315" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov)" />
<text x="240" y="306" font-family="Arial" font-size="13">submitResolve(outcomeId)</text>
<line x1="305" y1="350" x2="495" y2="350" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov)" />
<text x="357" y="341" font-family="Arial" font-size="13">submitResolve(outcomeId)</text>
<path d="M 495 385 C 560 385 560 425 495 425" fill="none" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov)" />
<text x="505" y="377" font-family="Arial" font-size="13">quorum -> resolve()</text>
<line x1="495" y1="445" x2="870" y2="445" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-gov)" />
<text x="616" y="436" font-family="Arial" font-size="13">acceptFee(creatorFee)</text>
<line x1="495" y1="475" x2="710" y2="475" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-gov-red)" />
<rect x="715" y="450" width="280" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="855" y="470" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">CreatorFeeCollected</text>
<text x="855" y="486" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(137)</text>
<line x1="495" y1="515" x2="710" y2="515" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-gov-red)" />
<rect x="715" y="490" width="280" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="855" y="510" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">Resolved</text>
<text x="855" y="526" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(120)</text>
</svg>
</div>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 920 260" role="img" aria-label="Oracle cancel quorum">
<defs>
<marker id="arrow-gov-cancel" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-gov-cancel-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="40" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="250" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="460" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="115" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Oracle A</text>
<text x="325" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">Oracle B</text>
<text x="525" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PMP</text>
<line x1="115" y1="60" x2="115" y2="180" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="325" y1="60" x2="325" y2="180" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="525" y1="60" x2="525" y2="180" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="115" y1="95" x2="525" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov-cancel)" />
<text x="245" y="86" font-family="Arial" font-size="13">submitCancelEvent()</text>
<line x1="325" y1="130" x2="525" y2="130" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov-cancel)" />
<text x="377" y="121" font-family="Arial" font-size="13">submitCancelEvent()</text>
<path d="M 525 165 C 590 165 590 195 525 195" fill="none" stroke="#475569" stroke-width="2" marker-end="url(#arrow-gov-cancel)" />
<text x="537" y="157" font-family="Arial" font-size="13">quorum -> cancelEvent()</text>
<line x1="525" y1="225" x2="750" y2="225" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-gov-cancel-red)" />
<rect x="755" y="200" width="140" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="825" y="220" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">EventCancelled</text>
<text x="825" y="236" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(126)</text>
<rect x="30" y="205" width="320" height="34" rx="10" fill="#f8fafc" stroke="#94a3b8" stroke-width="2" stroke-dasharray="5 4" />
<text x="190" y="227" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">The vote is one-shot here: a repeated `submitCancelEvent()` from the same oracle is ignored.</text>
</svg>
</div>
</section>
<section class="card">
<h2>5. Stake, Split, Merge, Resolve, Claim</h2>
<p>This is the main market execution path after approval: regular stake, full-set split/merge, then resolve and claim. The mirrored PMP/PrivateNote event pairs are most visible here.</p>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 840 520" role="img" aria-label="Stake and cancel stake flows">
<defs>
<marker id="arrow-stake" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-stake-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="50" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="280" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="520" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="115" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">User</text>
<text x="355" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PrivateNote</text>
<text x="585" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PMP</text>
<line x1="115" y1="60" x2="115" y2="430" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="355" y1="60" x2="355" y2="430" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="585" y1="60" x2="585" y2="430" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="115" y1="95" x2="355" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-stake)" />
<text x="185" y="86" font-family="Arial" font-size="13">setStake(...)</text>
<line x1="355" y1="135" x2="585" y2="135" stroke="#475569" stroke-width="2" marker-end="url(#arrow-stake)" />
<text x="420" y="126" font-family="Arial" font-size="13">acceptStake(...)</text>
<line x1="585" y1="165" x2="455" y2="165" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-stake-red)" />
<rect x="460" y="140" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="602" y="160" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">StakeAccepted</text>
<text x="602" y="176" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(118)</text>
<line x1="585" y1="205" x2="355" y2="205" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-stake)" />
<text x="430" y="196" font-family="Arial" font-size="13">onStakeAccepted(...)</text>
<line x1="355" y1="235" x2="505" y2="235" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-stake-red)" />
<rect x="510" y="210" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="652" y="230" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">StakeConfirmed</text>
<text x="652" y="246" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(113)</text>
<line x1="115" y1="315" x2="355" y2="315" stroke="#475569" stroke-width="2" marker-end="url(#arrow-stake)" />
<text x="176" y="306" font-family="Arial" font-size="13">cancelStake(...)</text>
<line x1="355" y1="355" x2="585" y2="355" stroke="#475569" stroke-width="2" marker-end="url(#arrow-stake)" />
<text x="422" y="346" font-family="Arial" font-size="13">cancelStake(...)</text>
<line x1="585" y1="390" x2="355" y2="390" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-stake)" />
<text x="430" y="381" font-family="Arial" font-size="13">onStakeCancelled(...)</text>
<line x1="355" y1="425" x2="520" y2="425" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-stake-red)" />
<rect x="525" y="400" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="667" y="420" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">StakeCancelled</text>
<text x="667" y="436" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(115)</text>
</svg>
</div>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 840 560" role="img" aria-label="Split and merge full set flows">
<defs>
<marker id="arrow-sm" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-sm-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="50" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="280" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="520" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="115" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">User</text>
<text x="355" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PrivateNote</text>
<text x="585" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PMP</text>
<line x1="115" y1="60" x2="115" y2="470" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="355" y1="60" x2="355" y2="470" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="585" y1="60" x2="585" y2="470" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="115" y1="95" x2="355" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-sm)" />
<text x="178" y="86" font-family="Arial" font-size="13">splitFullSet(...)</text>
<line x1="355" y1="135" x2="585" y2="135" stroke="#475569" stroke-width="2" marker-end="url(#arrow-sm)" />
<text x="424" y="126" font-family="Arial" font-size="13">splitFullSet(...)</text>
<line x1="585" y1="170" x2="455" y2="170" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-sm-red)" />
<rect x="460" y="145" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="602" y="165" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">SplitProcessed</text>
<text x="602" y="181" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(141)</text>
<line x1="585" y1="210" x2="355" y2="210" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-sm)" />
<text x="428" y="201" font-family="Arial" font-size="13">onSplitAccepted(...)</text>
<line x1="355" y1="245" x2="520" y2="245" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-sm-red)" />
<rect x="525" y="220" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="667" y="240" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">FullSetStakeConfirmed</text>
<text x="667" y="256" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(116)</text>
<line x1="115" y1="330" x2="355" y2="330" stroke="#475569" stroke-width="2" marker-end="url(#arrow-sm)" />
<text x="172" y="321" font-family="Arial" font-size="13">mergeFullSet(...)</text>
<line x1="355" y1="370" x2="585" y2="370" stroke="#475569" stroke-width="2" marker-end="url(#arrow-sm)" />
<text x="424" y="361" font-family="Arial" font-size="13">mergeFullSet(...)</text>
<line x1="585" y1="405" x2="455" y2="405" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-sm-red)" />
<rect x="460" y="380" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="602" y="400" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">MergeProcessed</text>
<text x="602" y="416" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(142)</text>
<line x1="585" y1="445" x2="355" y2="445" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-sm)" />
<text x="425" y="436" font-family="Arial" font-size="13">onMergeAccepted(...)</text>
<line x1="355" y1="480" x2="520" y2="480" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-sm-red)" />
<rect x="525" y="455" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="667" y="475" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">FullSetStakeCancelled</text>
<text x="667" y="491" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(117)</text>
</svg>
</div>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 940 430" role="img" aria-label="Claim flows">
<defs>
<marker id="arrow-claim" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-claim-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="40" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="300" y="20" width="150" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="570" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="105" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">User</text>
<text x="375" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PrivateNote</text>
<text x="635" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PMP</text>
<line x1="105" y1="60" x2="105" y2="340" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="375" y1="60" x2="375" y2="340" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="635" y1="60" x2="635" y2="340" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="105" y1="95" x2="375" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-claim)" />
<text x="200" y="86" font-family="Arial" font-size="13">claim(...) before resolve</text>
<line x1="375" y1="130" x2="635" y2="130" stroke="#475569" stroke-width="2" marker-end="url(#arrow-claim)" />
<text x="460" y="121" font-family="Arial" font-size="13">claim(...)</text>
<line x1="635" y1="165" x2="375" y2="165" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-claim)" />
<text x="450" y="156" font-family="Arial" font-size="13">onClaimAccepted(outcome = none)</text>
<rect x="100" y="182" width="410" height="34" rx="10" fill="#f8fafc" stroke="#94a3b8" stroke-width="2" stroke-dasharray="5 4" />
<text x="305" y="204" text-anchor="middle" font-family="Arial" font-size="12" fill="#526071">An unresolved claim clears `_busy` but does not produce external event objects.</text>
<line x1="105" y1="255" x2="375" y2="255" stroke="#475569" stroke-width="2" marker-end="url(#arrow-claim)" />
<text x="205" y="246" font-family="Arial" font-size="13">claim(...) after resolve</text>
<line x1="375" y1="290" x2="635" y2="290" stroke="#475569" stroke-width="2" marker-end="url(#arrow-claim)" />
<text x="460" y="281" font-family="Arial" font-size="13">claim(...)</text>
<line x1="635" y1="325" x2="470" y2="325" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-claim-red)" />
<rect x="475" y="300" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="617" y="320" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">ClaimProcessed</text>
<text x="617" y="336" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(121)</text>
<line x1="635" y1="375" x2="375" y2="375" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-claim)" />
<text x="450" y="366" font-family="Arial" font-size="13">onClaimAccepted(...)</text>
<line x1="375" y1="410" x2="540" y2="410" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-claim-red)" />
<rect x="545" y="385" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="687" y="405" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">ClaimAccepted</text>
<text x="687" y="421" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(114)</text>
</svg>
</div>
</section>
<section class="card">
<h2>6. OrderBook: Placement And Fill</h2>
<p>The order flow is split into a queue and callbacks. In the single-order path, `PrivateNote` first emits `OrderSubmitted` and only then receives `OrderBook`'s callbacks via `OrderPlacedConfirmed` / `OrderFilledConfirmed`. Batch placement reuses the same queue/match machinery without an `OrderSubmitted` per item, terminated by `onBatchComplete(...)`.</p>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 920 650" role="img" aria-label="Single order placement and fill sequence">
<defs>
<marker id="arrow-order" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-order-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>
<rect x="50" y="20" width="130" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="285" y="20" width="160" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<rect x="560" y="20" width="160" height="40" rx="10" fill="#ecfeff" stroke="#0f766e" stroke-width="2" />
<text x="115" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">User</text>
<text x="365" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">PrivateNote</text>
<text x="640" y="45" text-anchor="middle" font-family="Arial" font-size="16" font-weight="700">OrderBook</text>
<line x1="115" y1="60" x2="115" y2="560" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="365" y1="60" x2="365" y2="560" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="640" y1="60" x2="640" y2="560" stroke="#94a3b8" stroke-dasharray="6 6" />
<line x1="115" y1="95" x2="365" y2="95" stroke="#475569" stroke-width="2" marker-end="url(#arrow-order)" />
<text x="205" y="86" font-family="Arial" font-size="13">placeOrder(...)</text>
<line x1="365" y1="125" x2="520" y2="125" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-order-red)" />
<rect x="525" y="100" width="290" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="670" y="120" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">OrderSubmitted</text>
<text x="670" y="136" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(151)</text>
<line x1="365" y1="170" x2="640" y2="170" stroke="#475569" stroke-width="2" marker-end="url(#arrow-order)" />
<text x="440" y="161" font-family="Arial" font-size="13">executeBatch(orders, [])</text>
<line x1="640" y1="200" x2="505" y2="200" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-order-red)" />
<rect x="510" y="175" width="260" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="640" y="195" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">Queued</text>
<text x="640" y="211" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(0)</text>
<path d="M 640 245 C 705 245 705 285 640 285" fill="none" stroke="#475569" stroke-width="2" marker-end="url(#arrow-order)" />
<text x="652" y="237" font-family="Arial" font-size="13">processHead()</text>
<line x1="640" y1="300" x2="505" y2="300" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-order-red)" />
<rect x="510" y="275" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="652" y="295" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">OrderPlaced</text>
<text x="652" y="311" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(143)</text>
<line x1="640" y1="345" x2="365" y2="345" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-order)" />
<text x="450" y="336" font-family="Arial" font-size="13">onOrderPlaced(...)</text>
<line x1="365" y1="375" x2="520" y2="375" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-order-red)" />
<rect x="525" y="350" width="300" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="675" y="370" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">OrderPlacedConfirmed</text>
<text x="675" y="386" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(147)</text>
<path d="M 640 415 C 720 415 720 455 640 455" fill="none" stroke="#475569" stroke-width="2" marker-end="url(#arrow-order)" />
<text x="652" y="407" font-family="Arial" font-size="13">match / fill loop</text>
<line x1="640" y1="470" x2="500" y2="470" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-order-red)" />
<rect x="505" y="445" width="285" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="647" y="465" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">OrderFilled</text>
<text x="647" y="481" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(146)</text>
<line x1="640" y1="520" x2="475" y2="520" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-order-red)" />
<rect x="480" y="495" width="315" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="637" y="515" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">PartialFill / FullyFilled</text>
<text x="637" y="531" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(0)</text>
<line x1="640" y1="575" x2="365" y2="575" stroke="#475569" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#arrow-order)" />
<text x="450" y="566" font-family="Arial" font-size="13">onOrderFilled(...)</text>
<line x1="365" y1="610" x2="535" y2="610" stroke="#b91c1c" stroke-width="2" marker-end="url(#arrow-order-red)" />
<rect x="540" y="585" width="300" height="48" rx="10" fill="#fff1f2" stroke="#b91c1c" stroke-width="3" />
<text x="690" y="605" text-anchor="middle" font-family="Arial" font-size="13" font-weight="800" fill="#b91c1c">OrderFilledConfirmed</text>
<text x="690" y="621" text-anchor="middle" font-family="Arial" font-size="10.5" font-weight="700" fill="#b91c1c">dest: address.makeAddrExtern(148)</text>
</svg>
</div>
<div class="diagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1080 350" role="img" aria-label="Batch order placement and queue poke">
<defs>
<marker id="arrow-order-batch" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#475569" />
</marker>
<marker id="arrow-order-batch-red" markerWidth="12" markerHeight="8" refX="10" refY="4" orient="auto">
<polygon points="0,0 12,4 0,8" fill="#b91c1c" />
</marker>
</defs>