oxinsider 0.4.0

Official Rust client for the 0xinsider Developer API: Polymarket sports and esports analytics, wallet grades, large trades and sharp-money flow.
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
// Code generated by cargo codegen from the 0xinsider OpenAPI document. DO NOT EDIT.

//! Typed models for every schema the OpenAPI document names, and for the request
//! and response bodies it defines inline.
//!
//! A field the document marks optional or nullable is an `Option`: `None` means the
//! API did not report that value, which is not a zero. Unknown JSON keys are ignored
//! and an unknown enum value lands in `Other`, so an additive API change never fails
//! a response. Money and price fields are `f64`, the precision the API sends.

// Descriptions are the document's own, quoted verbatim; a field it leaves
// undescribed has no doc comment rather than an invented one.
#![allow(missing_docs)]
#![allow(rustdoc::bare_urls, rustdoc::broken_intra_doc_links, rustdoc::invalid_html_tags)]
#![allow(clippy::doc_lazy_continuation, clippy::large_enum_variant)]

use serde::{Deserialize, Deserializer, Serialize, Serializer, de};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AccountIdentity {
    pub object: String,
    pub data: AccountIdentityData,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AccountIdentityData {
    pub user_id: i64,
    pub credential_id: i64,
    pub credential_kind: CredentialKind,
    /// The credential is currently valid; revoked, expired or unknown credentials are rejected.
    pub credential_status: String,
    pub entitlement: AccountIdentityDataEntitlement,
    /// Approved OAuth scopes; null for full developer-key access.
    #[serde(default)]
    pub scopes: Option<Vec<String>>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AccountIdentityDataEntitlement {
    pub paid_data_access: PaidDataAccess,
    /// When paid data access is lapsed, the caller should renew the subscription; otherwise null.
    #[serde(default)]
    pub recovery_action: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Action {
    /// `buy`
    #[serde(rename = "buy")]
    Buy,
    /// `sell`
    #[serde(rename = "sell")]
    Sell,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Action {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Buy => "buy",
            Self::Sell => "sell",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Action {
    fn from(value: &str) -> Self {
        match value {
            "buy" => Self::Buy,
            "sell" => Self::Sell,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Action {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Action {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ActivateWebhookSecretResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum AdmittedBy {
    /// `most_held`
    #[serde(rename = "most_held")]
    MostHeld,
    /// `soonest_kickoff`
    #[serde(rename = "soonest_kickoff")]
    SoonestKickoff,
    /// `most_held_48h`
    #[serde(rename = "most_held_48h")]
    MostHeld48h,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl AdmittedBy {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::MostHeld => "most_held",
            Self::SoonestKickoff => "soonest_kickoff",
            Self::MostHeld48h => "most_held_48h",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for AdmittedBy {
    fn from(value: &str) -> Self {
        match value {
            "most_held" => Self::MostHeld,
            "soonest_kickoff" => Self::SoonestKickoff,
            "most_held_48h" => Self::MostHeld48h,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for AdmittedBy {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for AdmittedBy {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A sandbox key and the path to live access (#13959). Nothing is stored: the key cannot be listed or revoked and does not expire. Register again for a new one.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AgentRegistration {
    /// The sandbox key. Send it as Authorization: Bearer <api_key> to the sandbox. The last 8 hex characters are a checksum (the first 4 bytes of SHA-256 over the rest of the key), so the sandbox can tell a mistyped key from a real one. It is not a secret and unlocks no production data.
    pub api_key: String,
    /// Always false: this key never reaches live data.
    pub livemode: bool,
    pub environment: String,
    pub created_at: String,
    pub sandbox: AgentRegistrationSandbox,
    /// What live data needs, and where each credential comes from. Both need a person: an account with an active Pro subscription.
    pub live_access: AgentRegistrationLiveAccess,
}

/// What live data needs, and where each credential comes from. Both need a person: an account with an active Pro subscription.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AgentRegistrationLiveAccess {
    /// The production V1 base URL.
    pub api_base_url: String,
    /// What a live credential needs, in one sentence.
    pub requirement: String,
    /// Where a signed-in Pro user creates a live key (oxi_sk_live_).
    pub api_keys_url: String,
    /// RFC 8414 authorization server metadata, for an OAuth 2.1 grant the user approves.
    pub oauth_authorization_server_metadata_url: String,
    /// RFC 7591 dynamic client registration for public OAuth clients.
    pub oauth_registration_endpoint: String,
    /// The Pro plan.
    pub pricing_url: String,
    /// The authentication walkthrough for agents.
    pub auth_guide_url: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AgentRegistrationSandbox {
    /// The sandbox V1 base URL. Every documented operation answers here with example data, except GET /api/v1/stream: a Server-Sent Events stream is a live connection rather than a body, so the sandbox answers it with 400.
    pub api_base_url: String,
    /// A read to send with the key.
    pub first_request_url: String,
    /// The OpenAPI document, served by the sandbox.
    pub openapi_url: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ApiDiscovery {
    /// Canonical API origin for public V1 requests.
    pub api_base_url: String,
    /// Full agent-readable API reference.
    pub docs_url: String,
    /// Canonical web-origin OpenAPI JSON document.
    pub openapi_url: String,
    /// Unauthenticated API health endpoint.
    pub health_url: String,
    pub authentication: String,
    /// RFC 9728 protected-resource metadata for the API origin: the document every V1 401 names in its WWW-Authenticate challenge (resource, bearer_methods_supported, resource_documentation). The remote MCP server has its own document at /.well-known/oauth-protected-resource/api/v1/mcp.
    pub protected_resource_metadata_url: String,
    /// The complete authenticated route index: one entry per authenticated route this spec documents, in "<METHOD> <path>" form, not a representative subset. GET /api/v1 is the unauthenticated entrypoint an agent hits first, so it hands back the whole authenticated surface rather than a sample the caller would have to guess around. The example on GET /api/v1 is abridged for readability -- the live response returns all of them. Kept in lockstep with this spec by review: it is a hand-maintained const in backend/src/api_v1/discovery.rs and no automated check compares the two, so treat this spec as authoritative if they ever disagree.
    pub authenticated_routes: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ApiError {
    pub object: String,
    pub error: ApiErrorError,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ApiErrorBody {
    /// FROZEN: an existing value never changes meaning. request_timeout (408, #16146) was added the way insufficient_scope was: the handler did not answer inside the server's 30-second timeout. Retry-After and retry_at ride on it only for a safe method (GET, HEAD); a timed-out mutation may have completed, so check its state and reuse its Idempotency-Key.
    pub code: ErrorCode,
    pub message: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub doc_url: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub param: Option<String>,
    /// The recommended next retry instant (RFC3339). Present on every retryable error (reason=pick_not_released, code=rate_limited including reason=monthly_quota_exceeded, code=rate_limit_unavailable, reason=read_model_warming) and omitted otherwise. Always in the future. For pick_not_released, the recommendation is advisory and can change before a pick becomes available. Schedule the next request from the returned value instead of inferring a release schedule or polling. Prefer Retry-After for the duration because it is immune to client clock skew.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub retry_at: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub freshness: Option<FreshnessFailure>,
    /// ADDITIVE (#7209). The specific, actionable cause behind `code`, when there is one more specific than the code itself. `code` keeps its published values, so existing clients are unaffected; new clients branch on `reason`. Omitted when the code already says everything we know. pick_not_released: no Pick of the Day is published for the current product day; schedule one request against retry_at instead of polling. unknown_endpoint: the PATH is not a route on this API -- read GET /api/v1, do not retry. trader_not_tracked: the wallet is real and the URL is right, but the trader is not on the warm sync tier (the wallets we sync most often) -- stop asking for this wallet. market_out_of_scope (404 not_found, #27303): the market or event is real and the URL is right, but 0xinsider serves sports and esports markets only -- stop asking for this market; neither a retry nor another URL for it can succeed. cursor_expired: pagination went stale mid-walk -- re-request the first page and continue. read_model_warming: the requested endpoint cannot serve its read model yet; exact causes are endpoint-specific and can include a cold or contended refresh or a dependency that prevented refresh. database_unavailable: the API's database or its connection pool is temporarily unreachable (a connection-class failure, not a query fault); code stays rate_limit_unavailable, nothing is rate-limited, retry after Retry-After / retry_at. idempotency_in_progress: retain the exact Idempotency-Key and request body, then retry shortly. webhook_delivery_in_progress: retry the URL or signing-secret configuration change after the destination's active request completes. request_accounting_unavailable: accounting capacity is unavailable before the handler executes; retry after Retry-After / retry_at. sandbox_api_key: the credential is a sandbox key (oxi_sk_test_) from POST /api/v1/agents/register, which only the sandbox server accepts -- call the sandbox base URL with it, or get a live key or OAuth access token; do not retry it here. api_key_in_query: the key was sent as a ?token= query parameter, which no route reads because URLs land in logs and history; the key itself was not checked -- resend it as Authorization: Bearer. subscription_inactive: the key is valid but the account's Pro subscription has lapsed (402 subscription_required); permanent until a person reactivates at https://0xinsider.com/billing, which the message names -- stop retrying on a schedule and surface the link. The key owner is emailed once per lapse. monthly_quota_exceeded: the account has used the requests its plan includes for the UTC calendar month (429 rate_limited); retry_at and Retry-After name the first of next month, the only retry that can succeed, and the message names https://0xinsider.com/developers, where pay as you go for requests over the quota is turned on. The X-Monthly-Quota-Limit, X-Monthly-Quota-Remaining and X-Monthly-Quota-Reset headers on every authenticated response say how close the account is. invalid_query, invalid_path, invalid_body (400 bad_request, #16146): a query parameter, a path segment or the JSON body did not parse or does not fit the route's schema, so no handler ran; param names the field when the parser named one (a query key, a path segment, a JSON path such as traders[0], or body); fix the request, never retry it as sent. unsupported_media_type (415 bad_request, param content-type): send the body with Content-Type: application/json. payload_too_large (413 bad_request, param body): the body is over 1048576 bytes. method_not_allowed (405 bad_request): the path is a route but not with this method; the Allow header names the methods it serves. ip_rate_limited (429 rate_limited, #16380): the per-address budget every caller behind one IP shares, counted before authentication, is spent; not the key's own window, and the RateLimit-* headers describe that bucket. ip_throttled (429 rate_limited): the address is in a cooldown after sustained over-limit traffic; Retry-After is minutes to days, and a request before it does not shorten the cooldown. max_plan_required (403 forbidden, #23085): the key is valid and its account is on Pro, but the route is part of Max (GET /api/v1/edge-hunter); every Pro route keeps working with the same key, so do not disable it. The message names https://0xinsider.com/pricing, where the account upgrades; a retry never clears it. endpoint_retired (410): this legacy sports endpoint no longer serves data. Migrate to GET /api/v1/edge-hunter; retrying the retired path cannot succeed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reason: Option<ErrorReason>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ApiErrorError {
    /// FROZEN: an existing value never changes meaning. request_timeout (408, #16146) was added the way insufficient_scope was: the handler did not answer inside the server's 30-second timeout. Retry-After and retry_at ride on it only for a safe method (GET, HEAD); a timed-out mutation may have completed, so check its state and reuse its Idempotency-Key.
    pub code: ErrorCode,
    pub message: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub doc_url: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub param: Option<String>,
    /// The recommended next request instant (RFC3339), always in the future. Present on every retryable error: `pick_not_released`, `rate_limited`, `rate_limit_unavailable`, and `read_model_warming`. Omitted otherwise. The absolute twin of `Retry-After`; prefer the header for the sleep duration. For `pick_not_released`, the earliest of the next scheduled release, the next automatic selector attempt, the operating-window start, or about 60 seconds. See that response.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub retry_at: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub freshness: Option<FreshnessFailure>,
    /// ADDITIVE (#7209). The specific, actionable cause behind `code`, when there is one more specific than the code itself. `code` keeps its published values, so existing clients are unaffected; new clients branch on `reason`. Omitted when the code already says everything we know. pick_not_released: no Pick of the Day is published for the current product day; schedule one request against retry_at instead of polling. unknown_endpoint: the PATH is not a route on this API -- read GET /api/v1, do not retry. trader_not_tracked: the wallet is real and the URL is right, but the trader is not on the warm sync tier (the wallets we sync most often) -- stop asking for this wallet. market_out_of_scope (404 not_found, #27303): the market or event is real and the URL is right, but 0xinsider serves sports and esports markets only -- stop asking for this market; neither a retry nor another URL for it can succeed. cursor_expired: pagination went stale mid-walk -- re-request the first page and continue. read_model_warming: the requested endpoint cannot serve its read model yet; exact causes are endpoint-specific and can include a cold or contended refresh or a dependency that prevented refresh. database_unavailable: the API's database or its connection pool is temporarily unreachable (a connection-class failure, not a query fault); code stays rate_limit_unavailable, nothing is rate-limited, retry after Retry-After / retry_at. idempotency_in_progress: retain the exact Idempotency-Key and request body, then retry shortly. webhook_delivery_in_progress: retry the URL or signing-secret configuration change after the destination's active request completes. request_accounting_unavailable: accounting capacity is unavailable before the handler executes; retry after Retry-After / retry_at. sandbox_api_key: the credential is a sandbox key (oxi_sk_test_) from POST /api/v1/agents/register, which only the sandbox server accepts -- call the sandbox base URL with it, or get a live key or OAuth access token; do not retry it here. api_key_in_query: the key was sent as a ?token= query parameter, which no route reads because URLs land in logs and history; the key itself was not checked -- resend it as Authorization: Bearer. subscription_inactive: the key is valid but the account's Pro subscription has lapsed (402 subscription_required); permanent until a person reactivates at https://0xinsider.com/billing, which the message names -- stop retrying on a schedule and surface the link. The key owner is emailed once per lapse. monthly_quota_exceeded: the account has used the requests its plan includes for the UTC calendar month (429 rate_limited); retry_at and Retry-After name the first of next month, the only retry that can succeed, and the message names https://0xinsider.com/developers, where pay as you go for requests over the quota is turned on. The X-Monthly-Quota-Limit, X-Monthly-Quota-Remaining and X-Monthly-Quota-Reset headers on every authenticated response say how close the account is. invalid_query, invalid_path, invalid_body (400 bad_request, #16146): a query parameter, a path segment or the JSON body did not parse or does not fit the route's schema, so no handler ran; param names the field when the parser named one (a query key, a path segment, a JSON path such as traders[0], or body); fix the request, never retry it as sent. unsupported_media_type (415 bad_request, param content-type): send the body with Content-Type: application/json. payload_too_large (413 bad_request, param body): the body is over 1048576 bytes. method_not_allowed (405 bad_request): the path is a route but not with this method; the Allow header names the methods it serves. ip_rate_limited (429 rate_limited, #16380): the per-address budget every caller behind one IP shares, counted before authentication, is spent; not the key's own window, and the RateLimit-* headers describe that bucket. ip_throttled (429 rate_limited): the address is in a cooldown after sustained over-limit traffic; Retry-After is minutes to days, and a request before it does not shorten the cooldown. max_plan_required (403 forbidden, #23085): the key is valid and its account is on Pro, but the route is part of Max (GET /api/v1/edge-hunter); every Pro route keeps working with the same key, so do not disable it. The message names https://0xinsider.com/pricing, where the account upgrades; a retry never clears it. endpoint_retired (410): this legacy sports endpoint no longer serves data. Migrate to GET /api/v1/edge-hunter; retrying the retired path cannot succeed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reason: Option<ErrorReason>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Basis {
    /// `midpoint`
    #[serde(rename = "midpoint")]
    Midpoint,
    /// `last_trade`
    #[serde(rename = "last_trade")]
    LastTrade,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Basis {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Midpoint => "midpoint",
            Self::LastTrade => "last_trade",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Basis {
    fn from(value: &str) -> Self {
        match value {
            "midpoint" => Self::Midpoint,
            "last_trade" => Self::LastTrade,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Basis {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Basis {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BatchGetMarketFlowBody {
    /// Market condition IDs to resolve in input order.
    pub condition_ids: Vec<String>,
    /// Lookback window used for flow and trade-count context.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timeframe: Option<Timeframe>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BatchGetMarketFlowResponse {
    pub object: String,
    pub data: Vec<BatchMarketFlowItem>,
    pub meta: BatchResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BatchGetMarketIntelBody {
    /// Market condition IDs to resolve in input order.
    pub condition_ids: Vec<String>,
    /// Lookback window used for flow and trade-count context.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timeframe: Option<Timeframe>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BatchGetMarketIntelResponse {
    pub object: String,
    pub data: Vec<BatchMarketFlowItem>,
    pub meta: BatchResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BatchGetTradersBody {
    /// Trader identities to resolve in input order.
    pub traders: Vec<String>,
    /// Shared expand flags applied to every trader item.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub expand: Option<Vec<Expand>>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BatchGetTradersResponse {
    pub object: String,
    pub data: Vec<BatchTraderItem>,
    pub meta: BatchResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BatchMarketFlowItem {
    /// Zero-based request index. Duplicate inputs keep separate result rows.
    pub index: i64,
    pub input: String,
    pub status: BatchTraderItemStatus,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub data: Option<MarketFlow>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub error: Option<ApiErrorBody>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BatchRateLimitMeta {
    pub basis: String,
    /// The batch item budget per minute for the caller's plan: 2500 item units on Pro, 5000 on Max. The same number X-Batch-RateLimit-Limit reports.
    pub limit: i64,
    pub remaining: i64,
    /// Unix timestamp when the batch item window resets.
    pub reset: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BatchResponseMeta {
    /// Unique request ID (req_ prefix). The same value as the X-Request-Id response header, the request's usage accounting row and its log lines.
    pub request_id: String,
    pub cached: bool,
    pub total_items: i64,
    pub successful_items: i64,
    pub failed_items: i64,
    /// Number of batch item units reserved before execution.
    pub request_cost: i64,
    pub rate_limit: BatchRateLimitMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BatchTraderItem {
    /// Zero-based request index. Duplicate inputs keep separate result rows.
    pub index: i64,
    pub input: String,
    pub status: BatchTraderItemStatus,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub data: Option<Trader>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub error: Option<ApiErrorBody>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum BatchTraderItemStatus {
    /// `ok`
    #[serde(rename = "ok")]
    Ok,
    /// `error`
    #[serde(rename = "error")]
    Error,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl BatchTraderItemStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Ok => "ok",
            Self::Error => "error",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for BatchTraderItemStatus {
    fn from(value: &str) -> Self {
        match value {
            "ok" => Self::Ok,
            "error" => Self::Error,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for BatchTraderItemStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for BatchTraderItemStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum BoardUpcomingStatus {
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// `not_configured`
    #[serde(rename = "not_configured")]
    NotConfigured,
    /// `available`
    #[serde(rename = "available")]
    Available,
    /// `capacity_limited`
    #[serde(rename = "capacity_limited")]
    CapacityLimited,
    /// `source_unavailable`
    #[serde(rename = "source_unavailable")]
    SourceUnavailable,
    /// `cold_unavailable`
    #[serde(rename = "cold_unavailable")]
    ColdUnavailable,
    /// `deadline_unavailable`
    #[serde(rename = "deadline_unavailable")]
    DeadlineUnavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl BoardUpcomingStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Unknown => "unknown",
            Self::NotConfigured => "not_configured",
            Self::Available => "available",
            Self::CapacityLimited => "capacity_limited",
            Self::SourceUnavailable => "source_unavailable",
            Self::ColdUnavailable => "cold_unavailable",
            Self::DeadlineUnavailable => "deadline_unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for BoardUpcomingStatus {
    fn from(value: &str) -> Self {
        match value {
            "unknown" => Self::Unknown,
            "not_configured" => Self::NotConfigured,
            "available" => Self::Available,
            "capacity_limited" => Self::CapacityLimited,
            "source_unavailable" => Self::SourceUnavailable,
            "cold_unavailable" => Self::ColdUnavailable,
            "deadline_unavailable" => Self::DeadlineUnavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for BoardUpcomingStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for BoardUpcomingStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum BoardUpcomingUnavailableScopes {
    /// `category`
    #[serde(rename = "category")]
    Category,
    /// `nfl`
    #[serde(rename = "nfl")]
    Nfl,
    /// `cfb`
    #[serde(rename = "cfb")]
    Cfb,
    /// `nba`
    #[serde(rename = "nba")]
    Nba,
    /// `wnba`
    #[serde(rename = "wnba")]
    Wnba,
    /// `euroleague-basketball`
    #[serde(rename = "euroleague-basketball")]
    EuroleagueBasketball,
    /// `nhl`
    #[serde(rename = "nhl")]
    Nhl,
    /// `mls`
    #[serde(rename = "mls")]
    Mls,
    /// `valorant`
    #[serde(rename = "valorant")]
    Valorant,
    /// `league-of-legends`
    #[serde(rename = "league-of-legends")]
    LeagueOfLegends,
    /// `counter-strike-2`
    #[serde(rename = "counter-strike-2")]
    CounterStrike2,
    /// `dota-2`
    #[serde(rename = "dota-2")]
    Dota2,
    /// `registry`
    #[serde(rename = "registry")]
    Registry,
    /// `union`
    #[serde(rename = "union")]
    Union,
    /// `wave`
    #[serde(rename = "wave")]
    Wave,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl BoardUpcomingUnavailableScopes {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Category => "category",
            Self::Nfl => "nfl",
            Self::Cfb => "cfb",
            Self::Nba => "nba",
            Self::Wnba => "wnba",
            Self::EuroleagueBasketball => "euroleague-basketball",
            Self::Nhl => "nhl",
            Self::Mls => "mls",
            Self::Valorant => "valorant",
            Self::LeagueOfLegends => "league-of-legends",
            Self::CounterStrike2 => "counter-strike-2",
            Self::Dota2 => "dota-2",
            Self::Registry => "registry",
            Self::Union => "union",
            Self::Wave => "wave",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for BoardUpcomingUnavailableScopes {
    fn from(value: &str) -> Self {
        match value {
            "category" => Self::Category,
            "nfl" => Self::Nfl,
            "cfb" => Self::Cfb,
            "nba" => Self::Nba,
            "wnba" => Self::Wnba,
            "euroleague-basketball" => Self::EuroleagueBasketball,
            "nhl" => Self::Nhl,
            "mls" => Self::Mls,
            "valorant" => Self::Valorant,
            "league-of-legends" => Self::LeagueOfLegends,
            "counter-strike-2" => Self::CounterStrike2,
            "dota-2" => Self::Dota2,
            "registry" => Self::Registry,
            "union" => Self::Union,
            "wave" => Self::Wave,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for BoardUpcomingUnavailableScopes {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for BoardUpcomingUnavailableScopes {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// One bucketed OHLC price candle. Prices are in provider [0, 1] units, truncated to 4 decimals at the rendering edge.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Candle {
    /// Bucket-start unix epoch (seconds): UTC midnight for 1d, the ISO-week Monday's UTC midnight for 1w.
    pub t: i64,
    /// Open price in provider [0, 1] units (first observed point in the bucket).
    pub o: f64,
    /// High price in provider [0, 1] units (max observed in the bucket).
    pub h: f64,
    /// Low price in provider [0, 1] units (min observed in the bucket).
    pub l: f64,
    /// Close price in provider [0, 1] units (last observed point in the bucket).
    pub c: f64,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Category {
    /// `Basketball`
    #[serde(rename = "Basketball")]
    Basketball,
    /// `Football`
    #[serde(rename = "Football")]
    Football,
    /// `Baseball`
    #[serde(rename = "Baseball")]
    Baseball,
    /// `Hockey`
    #[serde(rename = "Hockey")]
    Hockey,
    /// `MMA`
    #[serde(rename = "MMA")]
    Mma,
    /// `Boxing`
    #[serde(rename = "Boxing")]
    Boxing,
    /// `Soccer`
    #[serde(rename = "Soccer")]
    Soccer,
    /// `Cricket`
    #[serde(rename = "Cricket")]
    Cricket,
    /// `Golf`
    #[serde(rename = "Golf")]
    Golf,
    /// `Tennis`
    #[serde(rename = "Tennis")]
    Tennis,
    /// `Esports`
    #[serde(rename = "Esports")]
    Esports,
    /// `Racing`
    #[serde(rename = "Racing")]
    Racing,
    /// `Table Tennis`
    #[serde(rename = "Table Tennis")]
    TableTennis,
    /// `Pickleball`
    #[serde(rename = "Pickleball")]
    Pickleball,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Category {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Basketball => "Basketball",
            Self::Football => "Football",
            Self::Baseball => "Baseball",
            Self::Hockey => "Hockey",
            Self::Mma => "MMA",
            Self::Boxing => "Boxing",
            Self::Soccer => "Soccer",
            Self::Cricket => "Cricket",
            Self::Golf => "Golf",
            Self::Tennis => "Tennis",
            Self::Esports => "Esports",
            Self::Racing => "Racing",
            Self::TableTennis => "Table Tennis",
            Self::Pickleball => "Pickleball",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Category {
    fn from(value: &str) -> Self {
        match value {
            "Basketball" => Self::Basketball,
            "Football" => Self::Football,
            "Baseball" => Self::Baseball,
            "Hockey" => Self::Hockey,
            "MMA" => Self::Mma,
            "Boxing" => Self::Boxing,
            "Soccer" => Self::Soccer,
            "Cricket" => Self::Cricket,
            "Golf" => Self::Golf,
            "Tennis" => Self::Tennis,
            "Esports" => Self::Esports,
            "Racing" => Self::Racing,
            "Table Tennis" => Self::TableTennis,
            "Pickleball" => Self::Pickleball,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Category {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Category {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Model-wide readiness, read in the same database snapshot as category_records. Individual category rows retain their own status.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CategorySkillModelReadiness {
    pub status: Status,
    pub model_version: String,
    pub taxonomy_version: String,
    pub observation_started_at: String,
    pub as_of: String,
    #[serde(default)]
    pub source_last_success_at: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum CategorySkillSource {
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `partial`
    #[serde(rename = "partial")]
    Partial,
    /// `degraded`
    #[serde(rename = "degraded")]
    Degraded,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl CategorySkillSource {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Live => "live",
            Self::Partial => "partial",
            Self::Degraded => "degraded",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for CategorySkillSource {
    fn from(value: &str) -> Self {
        match value {
            "live" => Self::Live,
            "partial" => Self::Partial,
            "degraded" => Self::Degraded,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for CategorySkillSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for CategorySkillSource {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Forward-only category evidence from observed Polymarket taker fills. Status is category eligibility, not a global letter grade or a guarantee of positive edge. Scores are probability differences. Unknown and degraded rows withhold scores. Coverage is partial; observation counts are not lifetime market counts.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CategorySkillV2 {
    pub status: Status,
    pub model_version: String,
    #[serde(default)]
    pub taxonomy_version: Option<String>,
    pub platform: String,
    pub scope: String,
    pub source_coverage: SourceCoverage,
    pub canonical_category: String,
    pub as_of: String,
    #[serde(default)]
    pub source_last_success_at: Option<String>,
    pub observation_started_at: String,
    #[serde(default)]
    pub latest_observation_at: Option<String>,
    pub independent_event_count: i64,
    pub resolved_condition_count: i64,
    pub unresolved_observation_count: i64,
    #[serde(default)]
    pub edge_mean: Option<f64>,
    #[serde(default)]
    pub edge_sd: Option<f64>,
    #[serde(default)]
    pub edge_se: Option<f64>,
    #[serde(default)]
    pub edge_lower_95: Option<f64>,
    #[serde(default)]
    pub brier_event_avg: Option<f64>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum CategoryWinRateStatus {
    /// `measured`
    #[serde(rename = "measured")]
    Measured,
    /// `not_enough_data`
    #[serde(rename = "not_enough_data")]
    NotEnoughData,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl CategoryWinRateStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Measured => "measured",
            Self::NotEnoughData => "not_enough_data",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for CategoryWinRateStatus {
    fn from(value: &str) -> Self {
        match value {
            "measured" => Self::Measured,
            "not_enough_data" => Self::NotEnoughData,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for CategoryWinRateStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for CategoryWinRateStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Changed {
    /// `scores`
    #[serde(rename = "scores")]
    Scores,
    /// `status`
    #[serde(rename = "status")]
    Status,
    /// `period`
    #[serde(rename = "period")]
    Period,
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `ended`
    #[serde(rename = "ended")]
    Ended,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Changed {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Scores => "scores",
            Self::Status => "status",
            Self::Period => "period",
            Self::Live => "live",
            Self::Ended => "ended",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Changed {
    fn from(value: &str) -> Self {
        match value {
            "scores" => Self::Scores,
            "status" => Self::Status,
            "period" => Self::Period,
            "live" => Self::Live,
            "ended" => Self::Ended,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Changed {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Changed {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ClvApplicability {
    /// `applicable`
    #[serde(rename = "applicable")]
    Applicable,
    /// `not_applicable`
    #[serde(rename = "not_applicable")]
    NotApplicable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ClvApplicability {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Applicable => "applicable",
            Self::NotApplicable => "not_applicable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ClvApplicability {
    fn from(value: &str) -> Self {
        match value {
            "applicable" => Self::Applicable,
            "not_applicable" => Self::NotApplicable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ClvApplicability {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ClvApplicability {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ClvState {
    /// `measured`
    #[serde(rename = "measured")]
    Measured,
    /// `pending`
    #[serde(rename = "pending")]
    Pending,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// `not_applicable`
    #[serde(rename = "not_applicable")]
    NotApplicable,
    /// `none`
    #[serde(rename = "none")]
    None,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ClvState {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Measured => "measured",
            Self::Pending => "pending",
            Self::Unavailable => "unavailable",
            Self::NotApplicable => "not_applicable",
            Self::None => "none",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ClvState {
    fn from(value: &str) -> Self {
        match value {
            "measured" => Self::Measured,
            "pending" => Self::Pending,
            "unavailable" => Self::Unavailable,
            "not_applicable" => Self::NotApplicable,
            "none" => Self::None,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ClvState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ClvState {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Cohort {
    /// `wider_holder`
    #[serde(rename = "wider_holder")]
    WiderHolder,
    /// `in_play`
    #[serde(rename = "in_play")]
    InPlay,
    /// `emerging_pile`
    #[serde(rename = "emerging_pile")]
    EmergingPile,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Cohort {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::WiderHolder => "wider_holder",
            Self::InPlay => "in_play",
            Self::EmergingPile => "emerging_pile",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Cohort {
    fn from(value: &str) -> Self {
        match value {
            "wider_holder" => Self::WiderHolder,
            "in_play" => Self::InPlay,
            "emerging_pile" => Self::EmergingPile,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Cohort {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Cohort {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Combo {
    /// Combo identifier: 0x followed by 62 lowercase hex characters. This differs from a binary market condition ID.
    pub condition_id: String,
    #[serde(default)]
    pub leg_count: Option<i64>,
    #[serde(default)]
    pub prepared_at: Option<String>,
    /// Whether the preparation event has been indexed.
    pub legs_known: bool,
    pub legs: Vec<ComboLeg>,
    #[serde(default)]
    pub window: Option<ComboWindowStats>,
    #[serde(default)]
    pub totals: Option<ComboTotals>,
    /// Result of the YES conjunction, independent of the wallet side or its P&L.
    pub status: ComboStatus,
    /// Reason the conjunction result cannot be verified, when unknown.
    #[serde(default)]
    pub status_reason: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboCoverage {
    pub state: ComboCoverageState,
    pub ingest_enabled: bool,
    pub cursors: Vec<ComboCoverageCursor>,
    #[serde(default)]
    pub max_lag_blocks: Option<i64>,
    #[serde(default)]
    pub oldest_cursor_update: Option<String>,
    #[serde(default)]
    pub lifecycle_lag_blocks: Option<i64>,
    pub lifecycle_backfilling: bool,
    /// Time the coverage state was evaluated; not a market-price timestamp.
    pub computed_at: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboCoverageCursor {
    /// Indexed contract.
    pub contract: String,
    pub last_block: i64,
    pub seed_block: i64,
    pub seed_origin: String,
    #[serde(default)]
    pub chain_finalized_block: Option<i64>,
    #[serde(default)]
    pub lag_blocks: Option<i64>,
    pub updated_at: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ComboCoverageState {
    /// `paused`
    #[serde(rename = "paused")]
    Paused,
    /// `uninitialized`
    #[serde(rename = "uninitialized")]
    Uninitialized,
    /// `stale`
    #[serde(rename = "stale")]
    Stale,
    /// `backfilling`
    #[serde(rename = "backfilling")]
    Backfilling,
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ComboCoverageState {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Paused => "paused",
            Self::Uninitialized => "uninitialized",
            Self::Stale => "stale",
            Self::Backfilling => "backfilling",
            Self::Live => "live",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ComboCoverageState {
    fn from(value: &str) -> Self {
        match value {
            "paused" => Self::Paused,
            "uninitialized" => Self::Uninitialized,
            "stale" => Self::Stale,
            "backfilling" => Self::Backfilling,
            "live" => Self::Live,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ComboCoverageState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ComboCoverageState {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// One combo with its newest 100 fills and all-time lifecycle totals. Paid API callers receive full access.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboDetail {
    pub access: String,
    pub combo: Combo,
    pub fills: Vec<ComboFill>,
    #[serde(default)]
    pub lifecycle: Option<ComboLifecycleStats>,
    pub coverage: ComboCoverage,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboFill {
    /// Stable fill identity.
    pub id: String,
    pub block_number: i64,
    pub log_index: i64,
    pub block_timestamp: String,
    pub tx_hash: String,
    /// Taker wallet address.
    #[serde(default)]
    pub trader: Option<String>,
    #[serde(default)]
    pub trader_name: Option<String>,
    #[serde(default)]
    pub trader_grade: Option<Grade>,
    /// Recorded wallet-wide trade time.
    #[serde(default)]
    pub last_traded_at: Option<String>,
    pub action: Action,
    /// Combo identifier: 0x followed by 62 lowercase hex characters. This differs from a binary market condition ID.
    pub condition_id: String,
    /// 0 is YES, 1 is NO.
    pub outcome_index: i64,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub shares: String,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub collateral_usdc: String,
    /// Execution price for the traded outcome; null for a zero-share event.
    #[serde(default)]
    pub price: Option<String>,
    /// Execution price normalized to YES.
    #[serde(default)]
    pub price_yes: Option<String>,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub fee_usdc: String,
    #[serde(default)]
    pub leg_count: Option<i64>,
    /// Result of the YES conjunction, independent of the wallet side or its P&L.
    pub status: ComboStatus,
    #[serde(default)]
    pub status_reason: Option<String>,
    pub won_legs: i64,
    /// Shares per dollar at execution; not a forecast or guaranteed return.
    #[serde(default)]
    pub payout_multiplier: Option<String>,
    pub legs: Vec<ComboLeg>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboFillsResponse {
    pub object: String,
    pub data: Vec<ComboFill>,
    pub sort: ComboFillsResponseSort,
    pub window: Window,
    pub limit: i64,
    pub coverage: ComboCoverage,
    /// A continuation is available based on page fullness. Its next page may be empty.
    pub has_more: bool,
    /// Exclusive block_number:log_index continuation for recent ordering.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Continuation offset for largest or payout ordering.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_offset: Option<i64>,
    pub meta: ResponseMeta,
    /// Not computed for combo fill pages; omitted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ComboFillsResponseSort {
    /// `recent`
    #[serde(rename = "recent")]
    Recent,
    /// `largest`
    #[serde(rename = "largest")]
    Largest,
    /// `payout`
    #[serde(rename = "payout")]
    Payout,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ComboFillsResponseSort {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Recent => "recent",
            Self::Largest => "largest",
            Self::Payout => "payout",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ComboFillsResponseSort {
    fn from(value: &str) -> Self {
        match value {
            "recent" => Self::Recent,
            "largest" => Self::Largest,
            "payout" => Self::Payout,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ComboFillsResponseSort {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ComboFillsResponseSort {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboLeg {
    pub leg_index: i64,
    pub outcome_index: i64,
    pub module_id: i64,
    pub state: ComboLegState,
    #[serde(default)]
    pub market: Option<ComboLegMarket>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboLegMarket {
    /// Source of the leg facts.
    pub source: ComboLegMarketSource,
    /// Full binary CTF condition ID for this leg.
    pub condition_id: String,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub slug: Option<String>,
    #[serde(default)]
    pub event_slug: Option<String>,
    /// Provider-resolved URL including the referral tag.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub polymarket_url: Option<String>,
    #[serde(default)]
    pub outcome_label: Option<String>,
    #[serde(default)]
    pub image: Option<String>,
    #[serde(default)]
    pub category: Option<String>,
    /// Provider outcome index; negative sentinels describe void or unresolved states.
    #[serde(default)]
    pub winning_outcome: Option<i64>,
    #[serde(default)]
    pub resolved_at: Option<String>,
    /// A closed market may still have no terminal outcome.
    #[serde(default)]
    pub market_closed: Option<bool>,
    /// Stored daily price for this leg outcome token; not a live quote.
    #[serde(default)]
    pub pick_price_daily: Option<f64>,
    /// Observation time of the stored daily price.
    #[serde(default)]
    pub pick_price_as_of: Option<String>,
    /// Whole days since the stored daily bucket.
    #[serde(default)]
    pub pick_price_age_days: Option<i64>,
    /// Unmodified provider leg status when available.
    #[serde(default)]
    pub provider_leg_status: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ComboLegMarketSource {
    /// `markets`
    #[serde(rename = "markets")]
    Markets,
    /// `provider`
    #[serde(rename = "provider")]
    Provider,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ComboLegMarketSource {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Markets => "markets",
            Self::Provider => "provider",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ComboLegMarketSource {
    fn from(value: &str) -> Self {
        match value {
            "markets" => Self::Markets,
            "provider" => Self::Provider,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ComboLegMarketSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ComboLegMarketSource {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ComboLegState {
    /// `pending`
    #[serde(rename = "pending")]
    Pending,
    /// `won`
    #[serde(rename = "won")]
    Won,
    /// `lost`
    #[serde(rename = "lost")]
    Lost,
    /// `void`
    #[serde(rename = "void")]
    Void,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ComboLegState {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Pending => "pending",
            Self::Won => "won",
            Self::Lost => "lost",
            Self::Void => "void",
            Self::Unknown => "unknown",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ComboLegState {
    fn from(value: &str) -> Self {
        match value {
            "pending" => Self::Pending,
            "won" => Self::Won,
            "lost" => Self::Lost,
            "void" => Self::Void,
            "unknown" => Self::Unknown,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ComboLegState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ComboLegState {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboLifecycleStats {
    pub splits: i64,
    pub merges: i64,
    pub redeems: i64,
    pub compresses: i64,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub split_usdc: String,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub merge_usdc: String,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub redeemed_shares: String,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub redeemed_usdc: String,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub compressed_usdc: String,
    pub last_event_at: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboLiveCount {
    /// Traded combos whose YES conjunction remains pending.
    pub count: i64,
    /// Time the count was computed; check its age before using it.
    pub computed_at: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboResponse {
    pub object: String,
    pub data: ComboDetail,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ComboStatus {
    /// `pending`
    #[serde(rename = "pending")]
    Pending,
    /// `won`
    #[serde(rename = "won")]
    Won,
    /// `lost`
    #[serde(rename = "lost")]
    Lost,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ComboStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Pending => "pending",
            Self::Won => "won",
            Self::Lost => "lost",
            Self::Unknown => "unknown",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ComboStatus {
    fn from(value: &str) -> Self {
        match value {
            "pending" => Self::Pending,
            "won" => Self::Won,
            "lost" => Self::Lost,
            "unknown" => Self::Unknown,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ComboStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ComboStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboTotals {
    pub fills: i64,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub volume_usdc: String,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub largest_fill_usdc: String,
    pub first_fill_at: String,
    pub last_fill_at: String,
    /// Last taker execution normalized to YES; not a current quote.
    #[serde(default)]
    pub last_fill_price_yes: Option<String>,
    pub last_fill_outcome_index: i64,
    pub last_fill_action: Action,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ComboWindowStats {
    pub fills: i64,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub volume_usdc: String,
    pub distinct_traders: i64,
    /// Exact decimal string from the stored chain or SQL value; preserve precision until display.
    pub largest_fill_usdc: String,
}

/// Stored live combo count. Null means the first count is unavailable, never zero.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CombosSummary {
    #[serde(default)]
    pub live: Option<ComboLiveCount>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CombosSummaryResponse {
    pub object: String,
    pub data: CombosSummary,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Competitors {
    /// `provider_ids`
    #[serde(rename = "provider_ids")]
    ProviderIds,
    /// `labels`
    #[serde(rename = "labels")]
    Labels,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Competitors {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::ProviderIds => "provider_ids",
            Self::Labels => "labels",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Competitors {
    fn from(value: &str) -> Self {
        match value {
            "provider_ids" => Self::ProviderIds,
            "labels" => Self::Labels,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Competitors {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Competitors {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Consistency {
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `snapshot`
    #[serde(rename = "snapshot")]
    Snapshot,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Consistency {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Live => "live",
            Self::Snapshot => "snapshot",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Consistency {
    fn from(value: &str) -> Self {
        match value {
            "live" => Self::Live,
            "snapshot" => Self::Snapshot,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Consistency {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Consistency {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ContentKind {
    /// `learn`
    #[serde(rename = "learn")]
    Learn,
    /// `glossary`
    #[serde(rename = "glossary")]
    Glossary,
    /// `comparison`
    #[serde(rename = "comparison")]
    Comparison,
    /// `research`
    #[serde(rename = "research")]
    Research,
    /// `strategy`
    #[serde(rename = "strategy")]
    Strategy,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ContentKind {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Learn => "learn",
            Self::Glossary => "glossary",
            Self::Comparison => "comparison",
            Self::Research => "research",
            Self::Strategy => "strategy",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ContentKind {
    fn from(value: &str) -> Self {
        match value {
            "learn" => Self::Learn,
            "glossary" => Self::Glossary,
            "comparison" => Self::Comparison,
            "research" => Self::Research,
            "strategy" => Self::Strategy,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ContentKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ContentKind {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ContentSearchResult {
    /// Backend-owned stable editorial content identifier.
    pub content_id: String,
    /// Editorial content kind.
    pub kind: ContentKind,
    /// Backend-owned content slug.
    pub slug: String,
    /// Editorial title.
    pub title: String,
    /// Search-result excerpt.
    pub excerpt: String,
    /// Canonical first-party content URL.
    pub url: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ContentType {
    /// `application/json`
    #[serde(rename = "application/json")]
    ApplicationJson,
    /// `application/x-ndjson`
    #[serde(rename = "application/x-ndjson")]
    ApplicationXNdjson,
    /// `text/csv`
    #[serde(rename = "text/csv")]
    TextCsv,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ContentType {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::ApplicationJson => "application/json",
            Self::ApplicationXNdjson => "application/x-ndjson",
            Self::TextCsv => "text/csv",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ContentType {
    fn from(value: &str) -> Self {
        match value {
            "application/json" => Self::ApplicationJson,
            "application/x-ndjson" => Self::ApplicationXNdjson,
            "text/csv" => Self::TextCsv,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ContentType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ContentType {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CounterpartyAnalysis {
    pub status: CounterpartyAnalysisStatus,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unavailable_reason: Option<String>,
    /// Deterministic immutable membership snapshot for this detail response.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub snapshot_id: Option<String>,
    /// Stable digest binding page cursors to one snapshot and execution set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub analysis_id: Option<String>,
    pub execution_count: i64,
    pub available_execution_count: i64,
    pub unavailable_execution_count: i64,
    pub executions: Vec<CounterpartyExecution>,
    /// Stable cursor after the last execution included in the bounded inline page.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub executions_next_cursor: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum CounterpartyAnalysisStatus {
    /// `available`
    #[serde(rename = "available")]
    Available,
    /// `partial`
    #[serde(rename = "partial")]
    Partial,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl CounterpartyAnalysisStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Available => "available",
            Self::Partial => "partial",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for CounterpartyAnalysisStatus {
    fn from(value: &str) -> Self {
        match value {
            "available" => Self::Available,
            "partial" => Self::Partial,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for CounterpartyAnalysisStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for CounterpartyAnalysisStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CounterpartyExecution {
    pub execution_id: String,
    pub exchange_family: ExchangeFamily,
    pub transaction_hash: String,
    pub orders_matched_log_index: i64,
    pub taker: CounterpartyParticipant,
    pub makers: Vec<CounterpartyParticipant>,
    /// Stable cursor after the last maker included in the bounded inline page.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub makers_next_cursor: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CounterpartyMakerPage {
    pub analysis_id: String,
    pub snapshot_id: String,
    pub execution_id: String,
    pub items: Vec<CounterpartyParticipant>,
    /// Cursor bound to the analysis, execution, last full-denominator share total, and wallet.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CounterpartyMatchBreakdown {
    pub match_type: MatchType,
    pub maker_fill_count: i64,
    /// Exact decimal shares.
    pub filled_shares: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CounterpartyParticipant {
    pub counterparty_key: String,
    /// Lowercase Polygon wallet from the exact OrderFilled log.
    pub execution_wallet: String,
    pub identity_status: IdentityStatus,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resolved_user_id: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub wallet_family: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resolution_block: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resolution_source: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub display_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grade: Option<String>,
    /// Latest nonfuture recorded wallet-wide trade time for the tracked trader supplying this participant's grade. Omitted when unavailable; not the receipt time or the owner EOA's activity. Trader context is read with the response and is not frozen by execution membership snapshots.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_traded_at: Option<String>,
    /// 0xinsider profile path segment for this participant, present only when the execution wallet has a tracked trader: `@<username>` when that username resolves to the trader alone, otherwise the trader's lowercase wallet. Percent-encode the part after `@` and append to `https://0xinsider.com/profile/`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub profile_segment: Option<String>,
    pub maker_fill_count: i64,
    /// Exact decimal shares.
    pub filled_shares: String,
    /// Exact decimal USDC amount.
    pub filled_usdc: String,
    /// Participant share of the exact execution, from 0 through 100.
    pub share_pct: String,
    pub match_breakdown: Vec<CounterpartyMatchBreakdown>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Coverage {
    /// `full_envelope_and_trades`
    #[serde(rename = "full_envelope_and_trades")]
    FullEnvelopeAndTrades,
    /// `trades_only`
    #[serde(rename = "trades_only")]
    TradesOnly,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Coverage {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::FullEnvelopeAndTrades => "full_envelope_and_trades",
            Self::TradesOnly => "trades_only",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Coverage {
    fn from(value: &str) -> Self {
        match value {
            "full_envelope_and_trades" => Self::FullEnvelopeAndTrades,
            "trades_only" => Self::TradesOnly,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Coverage {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Coverage {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateMcpJsonRpcResponseBody {
    /// JSON-RPC protocol version; this server accepts 2.0.
    pub jsonrpc: String,
    /// Request identifier echoed exactly in one JSON-RPC response; supported notifications omit it and receive an empty HTTP 202.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub id: Option<serde_json::Value>,
    /// MCP method to invoke.
    pub method: McpMethod,
    /// Method-specific MCP parameters.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub params: Option<serde_json::Map<String, serde_json::Value>>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CreateMcpJsonRpcResponseResponse {
    pub jsonrpc: String,
    #[serde(default)]
    pub id: Option<serde_json::Value>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub result: Option<serde_json::Map<String, serde_json::Value>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub error: Option<CreateMcpJsonRpcResponseResponseError>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CreateMcpJsonRpcResponseResponseError {
    pub code: i64,
    pub message: String,
    /// Optional JSON-serializable error data.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub data: Option<serde_json::Value>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateWebhookRequest {
    pub name: String,
    /// Public HTTPS callback URL on the default port 443. Local, private, and internal targets are rejected, as is any explicit port other than 443 and any URL carrying credentials. Each user's URLs are unique after normalizing HTTPS scheme/host case, trailing DNS dots and port 443; path/query case is preserved. Pending verification and PATCH-disabled endpoints still reserve their stored URL. The destination must answer the signed webhook.verification challenge with a 2xx before POST /api/v1/webhooks/{id}/verify can activate the endpoint.
    pub url: String,
    pub event_types: Vec<WebhookEventType>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub trade_filters: Option<LargeTradeSubscriptionFilters>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CreateWebhookResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateWebhookVerificationAttemptRequest {
    /// The original one-time token returned by webhook creation or a URL change. Sent only in the request body and signed receiver challenge.
    pub verification_token: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CreateWebhookVerificationAttemptResponse {
    pub object: String,
    pub data: WebhookVerificationAttempt,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum CredentialKind {
    /// `api_key`
    #[serde(rename = "api_key")]
    ApiKey,
    /// `oauth_grant`
    #[serde(rename = "oauth_grant")]
    OauthGrant,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl CredentialKind {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::ApiKey => "api_key",
            Self::OauthGrant => "oauth_grant",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for CredentialKind {
    fn from(value: &str) -> Self {
        match value {
            "api_key" => Self::ApiKey,
            "oauth_grant" => Self::OauthGrant,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for CredentialKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for CredentialKind {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Compact data age and coverage for a response body, always present on the operations that publish it. Read status and as_of to decide whether to use the body at all, and field_groups to see which part is weak. Everything here comes from stored observation clocks, so a cached body reports the same ages a freshly computed one does: meta.cached and meta.cache_age_s stay the only transport-time facts and neither makes this block newer. The per-field audit object is still available through expand=trust; this is the default summary of the same question.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DataQuality {
    /// fresh when every group is fresh, unavailable when every group is unavailable, and partial in every other case.
    pub status: DataQualityGroupStatus,
    /// The oldest as_of among the groups that carry one: the age of the weakest clock this body rests on. Omitted when no group carries a clock.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub as_of: Option<String>,
    /// One entry per field group. Entries may be added in later releases, so match on group rather than on position or length.
    pub field_groups: Vec<DataQualityGroup>,
}

/// One group of response fields that share a writer and therefore share a clock.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DataQualityGroup {
    /// Stable snake_case group name. Names are additive across releases, so match on the ones you know and ignore the rest.
    pub group: String,
    /// The table and column that write this group, named so the verdict can be audited (for example trader_rankings.computed_at).
    pub owner: String,
    /// fresh: served, and as_of carries this group's real observation or computation clock. partial: some of the group's fields are served and some are missing. unknown: served, and this read has no clock for it, so no age may be inferred. untracked: 0xinsider does not track this group for this subject, by design. unavailable: the group could not be served. New values may be added; treat one you do not recognize as unknown. fresh means the group is tracked and clocked, not that it is inside any particular tolerance: compare as_of against your own.
    pub status: DataQualityGroupStatus,
    /// When this group's values were observed or computed. Omitted whenever the read cannot measure it, and never filled with the serialization time, the cache time, or another group's clock.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub as_of: Option<String>,
    /// Why the status is not fresh. Omitted when it is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum DataQualityGroupStatus {
    /// `fresh`
    #[serde(rename = "fresh")]
    Fresh,
    /// `partial`
    #[serde(rename = "partial")]
    Partial,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// `untracked`
    #[serde(rename = "untracked")]
    Untracked,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl DataQualityGroupStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Fresh => "fresh",
            Self::Partial => "partial",
            Self::Unknown => "unknown",
            Self::Untracked => "untracked",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for DataQualityGroupStatus {
    fn from(value: &str) -> Self {
        match value {
            "fresh" => Self::Fresh,
            "partial" => Self::Partial,
            "unknown" => Self::Unknown,
            "untracked" => Self::Untracked,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for DataQualityGroupStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for DataQualityGroupStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DeleteWebhookResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Direction {
    /// `YES`
    #[serde(rename = "YES")]
    Yes,
    /// `NO`
    #[serde(rename = "NO")]
    No,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Direction {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Yes => "YES",
            Self::No => "NO",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Direction {
    fn from(value: &str) -> Self {
        match value {
            "YES" => Self::Yes,
            "NO" => Self::No,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Direction {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Direction {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum DirectionalSource {
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `degraded`
    #[serde(rename = "degraded")]
    Degraded,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl DirectionalSource {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Live => "live",
            Self::Degraded => "degraded",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for DirectionalSource {
    fn from(value: &str) -> Self {
        match value {
            "live" => Self::Live,
            "degraded" => Self::Degraded,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for DirectionalSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for DirectionalSource {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum DirectionalStatus {
    /// `available`
    #[serde(rename = "available")]
    Available,
    /// `unknown_ungrouped`
    #[serde(rename = "unknown_ungrouped")]
    UnknownUngrouped,
    /// `unknown_stale`
    #[serde(rename = "unknown_stale")]
    UnknownStale,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl DirectionalStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Available => "available",
            Self::UnknownUngrouped => "unknown_ungrouped",
            Self::UnknownStale => "unknown_stale",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for DirectionalStatus {
    fn from(value: &str) -> Self {
        match value {
            "available" => Self::Available,
            "unknown_ungrouped" => Self::UnknownUngrouped,
            "unknown_stale" => Self::UnknownStale,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for DirectionalStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for DirectionalStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// The full Max-only Edge Hunter board. Defaults cover all sports and esports with B grade floor, 48-hour horizon and at most 30 rows; common selections, legacy category, min_grade and limit narrow that projection. No pagination or ETag. Rows add frozen market_context discovery metadata.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterBoard {
    /// When the ranked snapshot was computed. Date current quotes with their own ts values.
    pub as_of: String,
    pub horizon_hours: i64,
    /// Requested holder-presence grade floor, S/A/B. A holder at that grade or better admits the row; other holders remain visible.
    pub min_grade: MarketHolderGrade,
    /// live uses the current graded holder pile; db_only is a weaker stored-data fallback.
    pub ranking_source: RankingSource,
    /// degraded means directional enrichment was unavailable.
    pub directional_source: DirectionalSource,
    #[serde(default)]
    pub cached_age_seconds: Option<i64>,
    pub viewer: String,
    /// Always null: Edge Hunter has no free signal slot.
    #[serde(default)]
    pub free_rank: Option<i64>,
    /// Ranked rows after normalized selections and grade filtering, before the view-specific limit cap.
    pub total: i64,
    pub rows: Vec<EdgeHunterRow>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterBoardResponse {
    pub object: String,
    pub data: EdgeHunterBoard,
    pub meta: ResponseMeta,
    /// Normalized axes requested with a selector or category; omitted on an unselected default read.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub selection: Option<EdgeHunterSelection>,
}

/// Category evidence over the full uncapped piled-side S/A/B holder allocation. It never changes signal membership, ordering, routing, or sizing.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterCategorySkill {
    pub status: Status,
    pub model_version: String,
    #[serde(default)]
    pub taxonomy_version: Option<String>,
    pub platform: String,
    pub scope: String,
    pub source_coverage: SourceCoverage,
    pub observation_started_at: String,
    pub as_of: String,
    #[serde(default)]
    pub canonical_category: Option<String>,
    pub eligible_holders: i64,
    pub covered_holders: i64,
    #[serde(default)]
    pub backed_sharp_usd: Option<f64>,
    #[serde(default)]
    pub covered_backed_usd: Option<f64>,
    #[serde(default)]
    pub coverage_pct: Option<f64>,
    #[serde(default)]
    pub weighted_edge_mean: Option<f64>,
    #[serde(default)]
    pub weighted_holder_lower_mean: Option<f64>,
    #[serde(default)]
    pub specialist_backed_usd: Option<f64>,
    #[serde(default)]
    pub specialist_backed_usd_pct: Option<f64>,
    #[serde(default)]
    pub largest_holder_backed_usd_pct: Option<f64>,
    #[serde(default)]
    pub minimum_holder_event_count: Option<i64>,
}

/// Per-sport accountable funnel for the full observation snapshot, returned on every page.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterFunnelReport {
    pub sports: Vec<EdgeHunterSportFunnelReport>,
}

/// Metadata frozen with the read generation. Values are nullable when the provider/canonical source has no value; no title-based inference or current-clock fallback.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterMarketContext {
    /// Normalized machine/provider league identity. Known wire/tag aliases normalize; other provider identities match exact lowercase keys.
    #[serde(default)]
    pub league: Option<String>,
    /// Exact provider series slug, usable in series_slugs selection.
    #[serde(default)]
    pub series_slug: Option<String>,
    /// Exact provider sports_market_type, usable in market_types selection.
    #[serde(default)]
    pub market_type: Option<String>,
    /// Exact local canonical metadata writer market_canonical.updated_at. This is not a provider observation clock; null means unavailable.
    #[serde(default)]
    pub metadata_updated_at: Option<String>,
}

/// One explicitly observation-only holder-pile measurement. It is evidence for cohort evaluation, not an execution instruction, and is isolated from the funded Edge Hunter signals view.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterObservation {
    /// The side profitable wallets hold, as a provider-backed display label. Canonical spelling of piled_side (#16310), same value: when provider group context is unavailable it may remain a bare Yes/No/Over/Under, so do not use it alone as participant identity.
    #[serde(default)]
    pub side: Option<String>,
    /// Recorded side backing score; higher values indicate stronger backing.
    pub backing_score: f64,
    /// Signed share of graded money on the side, in [-1, 1]. Canonical spelling of smart_score (#16309, #16310), same value.
    pub side_share: f64,
    /// Raw Polymarket condition id.
    pub condition_id: String,
    /// Provider-backed Polymarket CLOB token id for the piled outcome. Rows without a verified token terminate before emission.
    pub token_id: String,
    /// Canonical sport bucket.
    pub category: Category,
    /// Raw provider category as stored.
    #[serde(default)]
    pub raw_category: Option<String>,
    /// Provider-backed market title.
    pub title: String,
    #[serde(default)]
    pub event_slug: Option<String>,
    /// Provider event id when available.
    #[serde(default)]
    pub event_id: Option<String>,
    /// Provider parent-event id used as the first event-cap identity when available.
    #[serde(default)]
    pub parent_event_id: Option<String>,
    /// Provider-backed kickoff time in UTC.
    pub game_start_time: String,
    /// UTC instant when this row finished provider/holder evaluation.
    pub observed_at: String,
    /// Source cohort or additive projection view. emerging_pile is projected from wider_holder after source computation, overlaps its funnel denominator, and uses the source row's directional evidence.
    pub cohort: Cohort,
    /// Which evaluation place in its sport the row took this refresh. most_held: a wider_holder place for up to 8 markets per sport kicking off within 24 hours, most graded holders first, kept until kickoff while the holder page still shows a card or could not be read; also every in_play row, whose places go most graded holders first. soonest_kickoff: a wider_holder place among the sport's 8 soonest kickoffs, which is not kept. emerging_pile rows carry their source wider_holder row's value. Filter on most_held to keep the most-held selection. most_held_48h: every row of an admission=most_held_48h response, which is that opt-in selection (up to 8 markets per sport within 48 hours, most graded holders first, recomputed every refresh), including a market a default place also evaluates; it never appears on a default response.
    pub admitted_by: AdmittedBy,
    /// Always true. This row must not be routed to an order executor.
    pub observation_only: bool,
    /// Nullable provider-backed piled-outcome display label. When provider group context is unavailable, it may remain a bare Yes/No/Over/Under; do not use it alone as participant identity. Deprecated (#16310): `side` is the canonical spelling and carries the same value; this key stays on the wire.
    #[serde(default)]
    pub piled_side: Option<String>,
    /// Provider binary-column selector: 0 selects outcome_yes/token_id_yes; 1 selects outcome_no/token_id_no. It does not identify home/away or a participant. Use piled_side together with title/event context for display.
    pub piled_outcome_index: i64,
    /// Aggregate piled-side market midpoint recorded at observed_at. This is an observation price mark, not a wallet entry cost.
    pub backed_price: f64,
    /// Piled-side graded-holder dollar concentration.
    pub sharp_pct: f64,
    /// Raw graded-holder USD on the piled outcome.
    pub backed_sharp_usd: f64,
    pub s_count: i64,
    pub a_count: i64,
    pub b_count: i64,
    /// Piled-side S/A/B holder count.
    pub graded_holders: i64,
    pub top_grade: MarketHolderGrade,
    /// Canonical signed holder-pile score. Deprecated (#16310): `side_share` is the canonical spelling and carries the same value; this key stays on the wire.
    pub smart_score: f64,
    /// Cumulative provider taker volume in shares, not cash or dollars.
    pub volume: f64,
    /// Recorded conviction score; higher values indicate stronger conviction.
    pub conviction_score: f64,
    /// Whether the provider holder page came from the shared cache or a live provider read.
    pub provider_read_source: ProviderReadSource,
    /// True only when the provider page read for each outcome token listed every holder of that token. Observation collection reads one 100-row page per token; a token with more holders stays incomplete. False means holder counts and dollar totals measure the observed positive-holder subset. sharp_pct describes that observed subset and is not a lower bound on the full-population percentage. Incomplete scans cannot satisfy a future capital-promotion gate.
    pub holder_scan_complete: bool,
    /// Proven provider holder observation time. A warm cache hit uses only the original provider completion time from its companion metadata, never cache-read time. A wider_holder or emerging_pile row whose holder read did not finish in the current pass may reuse that market's last pregame holder page for up to 15 minutes; an in_play row may reuse its last in-play page, read after the provider reported the game live and never before that market's own kickoff, for up to 10 minutes. Both ages are counted when the snapshot is computed. Either reuse carries that page's original time here and provider_read_source cached. A pregame market more than an hour before kickoff reuses its last page the same way until that page is 10 minutes old, and only then is read again. Once that market's own kickoff has passed, an in_play row with provider_read_source cached, a warm hit or a reuse, never carries a page read before it. Null, malformed, future, or stale holder time fails in-play closed.
    #[serde(default)]
    pub holder_snapshot_at: Option<String>,
    /// Truthful state of the directional read, which classifies each graded holder by its fresh synced legs across the game's markets and, when holder_scan_complete is true, by Polymarket's currentValue on both outcomes of this market. A wider_holder row can remain emitted with unavailable and terminal wider_holder_emitted; in_play fails closed instead and terminates as in_play_directional_unavailable.
    pub directional_status: DirectionalStatus,
    #[serde(default)]
    pub one_way_holder_count: Option<i64>,
    #[serde(default)]
    pub hedged_holder_count: Option<i64>,
    #[serde(default)]
    pub one_way_graded_usd: Option<f64>,
    #[serde(default)]
    pub directional_confidence: Option<f64>,
    /// Recorded side ordering score; higher values sort first.
    pub directional_rank_score: f64,
    /// 1-based rank within this observation cohort and snapshot.
    pub rank: i64,
    /// Required nullable frozen metadata context. Null only during the legacy-generation transition; selected reads require sidecar readiness and fail closed with 503 instead.
    #[serde(default)]
    pub market_context: Option<EdgeHunterMarketContext>,
}

/// Measured coverage of the frozen canonical observation generation and this requested page. For sports and esports reads, the first four counts remain global through category, cohort and all selectors; with admission=most_held_48h they count that selection's generation, where every wider_holder candidate it did not take is capacity_limited. They are neither a census of all provider markets nor a count of successfully evaluated holders. Selected and returned counts describe the requested projection. An unmappable legacy category synthesizes a zero-work empty generation with all six counts zero and no degradation reasons; it does not read the all-sports cache.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterObservationCoverage {
    /// Sum of canonical source-generation funnel input across all sports, before category, cohort or selector projection.
    pub input_markets: i64,
    /// Canonical source-generation input assigned capacity_limited. These markets were intentionally outside the bounded holder-work admission and are not missing emitted rows.
    pub capacity_limited_markets: i64,
    /// All wider_holder and in_play observations emitted in the canonical source generation, before cohort, category or selector projection. Emerging pile is an overlapping projection and does not add source emissions.
    pub emitted_observations: i64,
    /// Canonical source-generation markets whose attempted holder scan did not establish complete coverage, including incomplete scans that did not emit an observation. Collection reads one 100-row page per token, so a market with more holders on a token counts here by design; this count does not by itself degrade the generation.
    pub incomplete_holder_markets: i64,
    /// Observations matching the requested cohort, category, selectors and applicable pinned projection cutoff before pagination.
    pub selected_observations: i64,
    /// Observation rows on this page; equals data.length.
    pub returned_observations: i64,
}

/// One observed cause of operational degradation in the canonical all-sports observation generation. Reasons are independent of the one-terminal-per-input funnel and remain unchanged through category, cohort and selector projection. Intentional capacity limits and an unconfigured upcoming source are not degradation reasons.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterObservationDegradationReason {
    /// Recorded producer cause. holder_scan_incomplete is retired and no longer emitted: the one-page holder read is an intentional bound, disclosed by each row's holder_scan_complete and by coverage.incomplete_holder_markets, and it does not degrade a generation. directional_unavailable can accompany an emitted wider_holder row; live_source_stale means provider live evidence exceeded its freshness bound. Other values identify reconciliation, applicable board-source or terminal failure evidence.
    pub reason: EdgeHunterObservationDegradationReasonReason,
    /// Canonical sport for the recorded cause; null only for generation-wide evidence without a sport attribution.
    #[serde(default)]
    pub sport: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum EdgeHunterObservationDegradationReasonReason {
    /// `holder_scan_incomplete`
    #[serde(rename = "holder_scan_incomplete")]
    HolderScanIncomplete,
    /// `live_source_stale`
    #[serde(rename = "live_source_stale")]
    LiveSourceStale,
    /// `directional_unavailable`
    #[serde(rename = "directional_unavailable")]
    DirectionalUnavailable,
    /// `funnel_unreconciled`
    #[serde(rename = "funnel_unreconciled")]
    FunnelUnreconciled,
    /// `board_live_unavailable`
    #[serde(rename = "board_live_unavailable")]
    BoardLiveUnavailable,
    /// `board_upcoming_unavailable`
    #[serde(rename = "board_upcoming_unavailable")]
    BoardUpcomingUnavailable,
    /// `provider_unavailable`
    #[serde(rename = "provider_unavailable")]
    ProviderUnavailable,
    /// `holder_deadline_unavailable`
    #[serde(rename = "holder_deadline_unavailable")]
    HolderDeadlineUnavailable,
    /// `holder_computation_unavailable`
    #[serde(rename = "holder_computation_unavailable")]
    HolderComputationUnavailable,
    /// `missing_stored_market`
    #[serde(rename = "missing_stored_market")]
    MissingStoredMarket,
    /// `price_unavailable`
    #[serde(rename = "price_unavailable")]
    PriceUnavailable,
    /// `in_play_stale_observed`
    #[serde(rename = "in_play_stale_observed")]
    InPlayStaleObserved,
    /// `in_play_directional_unavailable`
    #[serde(rename = "in_play_directional_unavailable")]
    InPlayDirectionalUnavailable,
    /// `internal_unclassified`
    #[serde(rename = "internal_unclassified")]
    InternalUnclassified,
    /// `board_source_unavailable`
    #[serde(rename = "board_source_unavailable")]
    BoardSourceUnavailable,
    /// `board_deadline_unavailable`
    #[serde(rename = "board_deadline_unavailable")]
    BoardDeadlineUnavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl EdgeHunterObservationDegradationReasonReason {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::HolderScanIncomplete => "holder_scan_incomplete",
            Self::LiveSourceStale => "live_source_stale",
            Self::DirectionalUnavailable => "directional_unavailable",
            Self::FunnelUnreconciled => "funnel_unreconciled",
            Self::BoardLiveUnavailable => "board_live_unavailable",
            Self::BoardUpcomingUnavailable => "board_upcoming_unavailable",
            Self::ProviderUnavailable => "provider_unavailable",
            Self::HolderDeadlineUnavailable => "holder_deadline_unavailable",
            Self::HolderComputationUnavailable => "holder_computation_unavailable",
            Self::MissingStoredMarket => "missing_stored_market",
            Self::PriceUnavailable => "price_unavailable",
            Self::InPlayStaleObserved => "in_play_stale_observed",
            Self::InPlayDirectionalUnavailable => "in_play_directional_unavailable",
            Self::InternalUnclassified => "internal_unclassified",
            Self::BoardSourceUnavailable => "board_source_unavailable",
            Self::BoardDeadlineUnavailable => "board_deadline_unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for EdgeHunterObservationDegradationReasonReason {
    fn from(value: &str) -> Self {
        match value {
            "holder_scan_incomplete" => Self::HolderScanIncomplete,
            "live_source_stale" => Self::LiveSourceStale,
            "directional_unavailable" => Self::DirectionalUnavailable,
            "funnel_unreconciled" => Self::FunnelUnreconciled,
            "board_live_unavailable" => Self::BoardLiveUnavailable,
            "board_upcoming_unavailable" => Self::BoardUpcomingUnavailable,
            "provider_unavailable" => Self::ProviderUnavailable,
            "holder_deadline_unavailable" => Self::HolderDeadlineUnavailable,
            "holder_computation_unavailable" => Self::HolderComputationUnavailable,
            "missing_stored_market" => Self::MissingStoredMarket,
            "price_unavailable" => Self::PriceUnavailable,
            "in_play_stale_observed" => Self::InPlayStaleObserved,
            "in_play_directional_unavailable" => Self::InPlayDirectionalUnavailable,
            "internal_unclassified" => Self::InternalUnclassified,
            "board_source_unavailable" => Self::BoardSourceUnavailable,
            "board_deadline_unavailable" => Self::BoardDeadlineUnavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for EdgeHunterObservationDegradationReasonReason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for EdgeHunterObservationDegradationReasonReason {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A market whose wider_holder card left this selection before kickoff, with why it left.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterObservationDeparture {
    /// Raw Polymarket condition id.
    pub condition_id: String,
    #[serde(default)]
    pub event_slug: Option<String>,
    /// Canonical sport bucket the departed card carried.
    pub category: Category,
    /// The departed card's admitted_by: most_held_48h on an admission=most_held_48h response.
    pub admitted_by: AdmittedBy,
    /// Kickoff the departed card carried, in UTC. The entry leaves the list once it passes.
    pub game_start_time: String,
    /// The departed card's observed_at: when its last evaluation finished.
    pub last_observed_at: String,
    /// snapshot_as_of of the first snapshot of this selection without the card.
    pub departed_at: String,
    /// Why the market has no card: its terminal in this selection's funnel in the snapshot it left, and while that terminal reports a read that did not finish (holder_deadline_unavailable, provider_unavailable, holder_computation_unavailable, internal_unclassified), the terminal of each later snapshot until one answers; an answered reason never changes. primary_slate_candidate: the market joined the funded slate, which view=signals covers. capacity_limited: it lost its evaluation place without another outcome. missing_stored_market: the market was no longer in the stored market universe. Any other value means what it means in the funnel, for example split_holder_pile, no_current_graded_holder or resolved.
    pub reason: EdgeHunterObservationTerminalReason,
}

/// Closed 25-value terminal-reason vocabulary for the accountable Edge Hunter observation funnel. capacity_limited is intentional bounded provider-work admission and does not itself set the snapshot degraded. board_source_unavailable is a completed board-source failure; board_deadline_unavailable means live-board work missed either an internal configured-scope deadline or the outer fair-wave deadline; both classify only already-started rows, so for the upcoming source read funnel.sports[].board_upcoming_status instead; provider_unavailable is reserved for an attempted holder-provider failure; holder_deadline_unavailable is holder cache/provider absolute-deadline exhaustion.
///
/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum EdgeHunterObservationTerminalReason {
    /// `outside_horizon`
    #[serde(rename = "outside_horizon")]
    OutsideHorizon,
    /// `resolved`
    #[serde(rename = "resolved")]
    Resolved,
    /// `provider_closed`
    #[serde(rename = "provider_closed")]
    ProviderClosed,
    /// `provider_excluded`
    #[serde(rename = "provider_excluded")]
    ProviderExcluded,
    /// `invalid_market`
    #[serde(rename = "invalid_market")]
    InvalidMarket,
    /// `missing_token`
    #[serde(rename = "missing_token")]
    MissingToken,
    /// `missing_stored_market`
    #[serde(rename = "missing_stored_market")]
    MissingStoredMarket,
    /// `not_provider_live`
    #[serde(rename = "not_provider_live")]
    NotProviderLive,
    /// `board_source_unavailable`
    #[serde(rename = "board_source_unavailable")]
    BoardSourceUnavailable,
    /// `board_deadline_unavailable`
    #[serde(rename = "board_deadline_unavailable")]
    BoardDeadlineUnavailable,
    /// `primary_slate_candidate`
    #[serde(rename = "primary_slate_candidate")]
    PrimarySlateCandidate,
    /// `zero_indexed_holder_research`
    #[serde(rename = "zero_indexed_holder_research")]
    ZeroIndexedHolderResearch,
    /// `capacity_limited`
    #[serde(rename = "capacity_limited")]
    CapacityLimited,
    /// `provider_unavailable`
    #[serde(rename = "provider_unavailable")]
    ProviderUnavailable,
    /// `holder_deadline_unavailable`
    #[serde(rename = "holder_deadline_unavailable")]
    HolderDeadlineUnavailable,
    /// `holder_computation_unavailable`
    #[serde(rename = "holder_computation_unavailable")]
    HolderComputationUnavailable,
    /// `holder_scan_incomplete`
    #[serde(rename = "holder_scan_incomplete")]
    HolderScanIncomplete,
    /// `no_current_graded_holder`
    #[serde(rename = "no_current_graded_holder")]
    NoCurrentGradedHolder,
    /// `split_holder_pile`
    #[serde(rename = "split_holder_pile")]
    SplitHolderPile,
    /// `price_unavailable`
    #[serde(rename = "price_unavailable")]
    PriceUnavailable,
    /// `wider_holder_emitted`
    #[serde(rename = "wider_holder_emitted")]
    WiderHolderEmitted,
    /// `in_play_emitted`
    #[serde(rename = "in_play_emitted")]
    InPlayEmitted,
    /// `in_play_stale_observed`
    #[serde(rename = "in_play_stale_observed")]
    InPlayStaleObserved,
    /// `in_play_directional_unavailable`
    #[serde(rename = "in_play_directional_unavailable")]
    InPlayDirectionalUnavailable,
    /// `internal_unclassified`
    #[serde(rename = "internal_unclassified")]
    InternalUnclassified,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl EdgeHunterObservationTerminalReason {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::OutsideHorizon => "outside_horizon",
            Self::Resolved => "resolved",
            Self::ProviderClosed => "provider_closed",
            Self::ProviderExcluded => "provider_excluded",
            Self::InvalidMarket => "invalid_market",
            Self::MissingToken => "missing_token",
            Self::MissingStoredMarket => "missing_stored_market",
            Self::NotProviderLive => "not_provider_live",
            Self::BoardSourceUnavailable => "board_source_unavailable",
            Self::BoardDeadlineUnavailable => "board_deadline_unavailable",
            Self::PrimarySlateCandidate => "primary_slate_candidate",
            Self::ZeroIndexedHolderResearch => "zero_indexed_holder_research",
            Self::CapacityLimited => "capacity_limited",
            Self::ProviderUnavailable => "provider_unavailable",
            Self::HolderDeadlineUnavailable => "holder_deadline_unavailable",
            Self::HolderComputationUnavailable => "holder_computation_unavailable",
            Self::HolderScanIncomplete => "holder_scan_incomplete",
            Self::NoCurrentGradedHolder => "no_current_graded_holder",
            Self::SplitHolderPile => "split_holder_pile",
            Self::PriceUnavailable => "price_unavailable",
            Self::WiderHolderEmitted => "wider_holder_emitted",
            Self::InPlayEmitted => "in_play_emitted",
            Self::InPlayStaleObserved => "in_play_stale_observed",
            Self::InPlayDirectionalUnavailable => "in_play_directional_unavailable",
            Self::InternalUnclassified => "internal_unclassified",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for EdgeHunterObservationTerminalReason {
    fn from(value: &str) -> Self {
        match value {
            "outside_horizon" => Self::OutsideHorizon,
            "resolved" => Self::Resolved,
            "provider_closed" => Self::ProviderClosed,
            "provider_excluded" => Self::ProviderExcluded,
            "invalid_market" => Self::InvalidMarket,
            "missing_token" => Self::MissingToken,
            "missing_stored_market" => Self::MissingStoredMarket,
            "not_provider_live" => Self::NotProviderLive,
            "board_source_unavailable" => Self::BoardSourceUnavailable,
            "board_deadline_unavailable" => Self::BoardDeadlineUnavailable,
            "primary_slate_candidate" => Self::PrimarySlateCandidate,
            "zero_indexed_holder_research" => Self::ZeroIndexedHolderResearch,
            "capacity_limited" => Self::CapacityLimited,
            "provider_unavailable" => Self::ProviderUnavailable,
            "holder_deadline_unavailable" => Self::HolderDeadlineUnavailable,
            "holder_computation_unavailable" => Self::HolderComputationUnavailable,
            "holder_scan_incomplete" => Self::HolderScanIncomplete,
            "no_current_graded_holder" => Self::NoCurrentGradedHolder,
            "split_holder_pile" => Self::SplitHolderPile,
            "price_unavailable" => Self::PriceUnavailable,
            "wider_holder_emitted" => Self::WiderHolderEmitted,
            "in_play_emitted" => Self::InPlayEmitted,
            "in_play_stale_observed" => Self::InPlayStaleObserved,
            "in_play_directional_unavailable" => Self::InPlayDirectionalUnavailable,
            "internal_unclassified" => Self::InternalUnclassified,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for EdgeHunterObservationTerminalReason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for EdgeHunterObservationTerminalReason {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Full Edge Hunter observations list envelope. Required degradation_reasons explains the source-generation verdict; required coverage distinguishes source input, intentional capacity exclusions, source emissions, incomplete holder scans, selection and the returned page. The view literal distinguishes advanced collections, including empty pages.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterObservationsResponse {
    pub object: String,
    pub view: String,
    pub data: Vec<EdgeHunterObservation>,
    pub has_more: bool,
    /// Pass as cursor for the next page. Always sent; null on the last page.
    #[serde(default)]
    pub next_cursor: Option<String>,
    /// Completion time of the shared observation snapshot pinned by the cursor.
    pub snapshot_as_of: String,
    /// True when an operational failure or unknown provider-board, holder, directional, reconciliation, or internal completeness state made this snapshot partial. This is snapshot-wide and can retain degradation that the funnel's one-terminal-per-input accounting cannot represent. Inspect degradation_reasons for every recorded source-generation cause and its nullable canonical sport attribution. Intentional bounds do not by themselves set this field: capacity_limited rows remain fully accounted in the funnel, and a holder scan the one-page read leaves incomplete counts in coverage.incomplete_holder_markets; board_upcoming_status=not_configured is not a failure.
    pub degraded: bool,
    /// Sorted, deduplicated causes from the canonical all-sports generation, unchanged by category, cohort or selectors; with admission=most_held_48h, from that selection's generation. Empty exactly when degraded is false. Capacity-limited input, the one-page holder bound (holder_scan_complete=false) and board_upcoming_status=not_configured do not by themselves add a reason.
    pub degradation_reasons: Vec<EdgeHunterObservationDegradationReason>,
    pub coverage: EdgeHunterObservationCoverage,
    pub funnel: EdgeHunterFunnelReport,
    pub meta: ResponseMeta,
    /// Normalized axes requested with a selector or category; omitted on an unselected default read.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub selection: Option<EdgeHunterSelection>,
    /// Echoes the opt-in admission rule a request named; omitted on a default read. When present, data, funnel, coverage, degraded and degradation_reasons describe that selection, not the default one.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub admission: Option<String>,
    /// cohort=wider_holder only, for the default selection and for admission=most_held_48h: markets that had a wider_holder card in an earlier snapshot of the same selection, have none in this one, and have not kicked off. Newest departed_at first. An entry stays until the game_start_time it carries passes, and leaves as soon as the market has a card again; while it stays only a reason that reports an unfinished read changes (see reason), and a later departure of the same market is a new entry. Filtered by the same category and selectors as data, and identical on every page of one snapshot. At most 336 entries; when more are open, the oldest departures leave first. An empty array means no card of this selection is departed. Omitted on in_play and emerging_pile, and on a snapshot that could not establish its departures, never reported as an empty array. Tracking that restarts after its record is lost starts empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub departures: Option<Vec<EdgeHunterObservationDeparture>>,
}

/// One provider outcome in fixed YES/NO order, including its frozen token identity and independently observed quote. Null current_price means no verified current quote is available.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterOutcome {
    pub index: i64,
    #[serde(default)]
    pub label: Option<String>,
    #[serde(default)]
    pub provider_id: Option<i64>,
    /// Frozen provider CLOB token ID for this exact outcome in YES/NO order. Null when unavailable; not a participant identity.
    #[serde(default)]
    pub token_id: Option<String>,
    #[serde(default)]
    pub current_price: Option<EdgeHunterPrice>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterParticipant {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub provider_id: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub logo: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub logo_mark_dark: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub color: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headshot: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headshot_revision: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tour: Option<String>,
    pub name: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterPrice {
    /// Provider probability as a decimal string. Keep its precision until display.
    pub price: String,
    pub basis: Basis,
    /// Source observation clock in epoch milliseconds, represented as a string.
    pub ts: String,
    /// Backend validation clock in epoch milliseconds. Omitted when no current-source validation is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub validated_at: Option<String>,
}

/// One ranked pre-game sports market where graded sharp money is piled on one side, with required-status category evidence from partial forward-observed Polymarket fills.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterRankedSignal {
    /// The side profitable wallets hold, as a provider-backed display label. Canonical spelling of piled_side (#16310), same value: when provider group context is unavailable it may remain a bare Yes/No/Over/Under, so do not use it alone as participant identity.
    #[serde(default)]
    pub side: Option<String>,
    /// UTC time at which the snapshot that ranked this row was computed. Canonical spelling of signal_created_at (#16310), same value.
    pub ranked_at: String,
    /// Recorded side backing score; higher values indicate stronger backing.
    pub backing_score: f64,
    /// Signed share of graded money on the side, (yes_usd - no_usd)/(yes_usd + no_usd) in [-1, 1] (side-yes positive, side-no negative). Canonical spelling of smart_score (#16309, #16310), same value.
    #[serde(default)]
    pub side_share: Option<f64>,
    /// Polymarket condition id.
    pub condition_id: String,
    /// UTC time at which the immutable signal snapshot was computed. Every row from one snapshot shares this value; it is not provider market creation time and is not rewritten at request time. Deprecated (#16310): `ranked_at` is the canonical spelling and carries the same value; this key stays on the wire.
    pub signal_created_at: String,
    /// Polymarket CLOB token id (ERC1155 asset id, decimal string) for the PILED outcome; null when unavailable.
    #[serde(default)]
    pub token_id: Option<String>,
    /// Canonical sport bucket (e.g. Basketball, Tennis); null when the raw category has no canonical mapping.
    #[serde(default)]
    pub category: Option<Category>,
    /// Raw provider category as stored (e.g. NBA, EPL).
    #[serde(default)]
    pub raw_category: Option<String>,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub event_slug: Option<String>,
    /// Kickoff (UTC). In the future at SNAPSHOT time and within the requested horizon; because the response is served from a shared snapshot cached up to the ~180s TTL, a served kickoff can be up to ~180s in the past relative to the response time. Not a live guarantee that the game has not yet started.
    #[serde(default)]
    pub game_start_time: Option<String>,
    /// Nullable provider-backed piled-outcome display label. When provider group context is unavailable, it may remain a bare Yes/No/Over/Under; do not use it alone as participant identity. Deprecated (#16310): `side` is the canonical spelling and carries the same value; this key stays on the wire.
    #[serde(default)]
    pub piled_side: Option<String>,
    /// Provider binary-column selector: 0 selects outcome_yes/token_id_yes; 1 selects outcome_no/token_id_no. It does not identify home/away or a participant. Use piled_side together with title/event context for display.
    pub piled_outcome_index: i64,
    /// Piled-side dollar concentration backed_usd / (yes_usd + no_usd), in (0.5, 1] for a real pile; null when there is no sharp USD.
    #[serde(default)]
    pub sharp_pct: Option<f64>,
    /// Raw piled-side sharp-money USD.
    pub backed_sharp_usd: f64,
    /// S-grade graded holders on the piled side.
    pub s_count: i64,
    /// A-grade graded holders on the piled side.
    pub a_count: i64,
    /// B-grade graded holders on the piled side.
    pub b_count: i64,
    /// Piled-side graded holder count (s_count + a_count + b_count).
    pub graded_holders: i64,
    /// Best grade present on the piled side; null when none.
    #[serde(default)]
    pub top_grade: Option<MarketHolderGrade>,
    /// Canonical sharp-money score (yes_usd - no_usd)/(yes_usd + no_usd) in [-1, 1] (piled-yes positive, piled-no negative). Deprecated (#16310): `side_share` is the canonical spelling and carries the same value; this key stays on the wire.
    #[serde(default)]
    pub smart_score: Option<f64>,
    /// Cumulative provider taker volume in shares, not cash or dollars.
    #[serde(default)]
    pub volume: Option<f64>,
    /// Aggregate recent flow direction on the market; null when unavailable.
    #[serde(default)]
    pub net_side: Option<LargeTradeInsertedV2DataSide>,
    /// Recorded conviction score; higher values indicate stronger conviction.
    pub conviction_score: f64,
    /// Piled-side graded holders read one-way: their fresh open legs across the signal game's markets (cross-market within the one game; moneyline+spread family only) all back the same team, or, when the market's holder scan was complete, Polymarket's currentValue shows no opposite leg on this market worth 10% of the backed leg and no fresh leg opposes it. Null when the directional read was not computed (no groupable game, no holder-level data on this ranking path, or the enrichment read failed) or classified nobody.
    #[serde(default)]
    pub one_way_holder_count: Option<i64>,
    /// Piled-side graded holders classified HEDGED across the game by fresh legs (they back two or more distinct teams). A wallet long both outcomes of this market is not one-way and not counted here. Null when the directional read was not computed or classified nobody.
    #[serde(default)]
    pub hedged_holder_count: Option<i64>,
    /// Piled-side graded USD held by one-way wallets (share-weighted allocation of backed_sharp_usd). Null when the directional read was not computed or classified nobody.
    #[serde(default)]
    pub one_way_graded_usd: Option<f64>,
    /// One-way fraction of the piled graded dollars, in [0, 1] -- the metric orthogonal to sharp_pct. Stale, unknown, hedged, and two-sided dollars dilute it toward zero (conservative). Null when the directional read was not computed or classified nobody.
    #[serde(default)]
    pub directional_confidence: Option<f64>,
    /// Recorded side ordering score; higher values sort first.
    pub directional_rank_score: f64,
    pub category_skill: EdgeHunterCategorySkill,
    /// 1-based rank within the (min_grade-filtered) ranked result.
    pub rank: i64,
    /// Required nullable frozen metadata context. Null only during the legacy-generation transition; selected reads require sidecar readiness and fail closed with 503 instead.
    #[serde(default)]
    pub market_context: Option<EdgeHunterMarketContext>,
}

/// One full Max row from Edge Hunter. signal is populated on every row this endpoint returns. Identity and quotes preserve provider values; unknown values stay null.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterRow {
    pub rank: i64,
    pub state: String,
    pub free: bool,
    pub condition_id: String,
    #[serde(default)]
    pub event_slug: Option<String>,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub category: Option<Category>,
    #[serde(default)]
    pub raw_category: Option<String>,
    #[serde(default)]
    pub game_start_time: Option<String>,
    /// Cumulative provider taker volume in shares, not cash in USD. Null when unavailable.
    #[serde(default)]
    pub volume: Option<f64>,
    pub participants: Vec<EdgeHunterParticipant>,
    #[serde(default)]
    pub image: Option<String>,
    pub outcomes: Vec<EdgeHunterOutcome>,
    #[serde(default)]
    pub signal: Option<EdgeHunterSignal>,
    /// Required nullable frozen metadata context. Null only during the legacy-generation transition; selected reads require sidecar readiness and fail closed with 503 instead.
    #[serde(default)]
    pub market_context: Option<EdgeHunterMarketContext>,
}

/// Normalized requested selection axes. Only requested axes appear; omitted for unselected defaults. Arrays are nonempty, sorted and deduplicated. OR within an axis, AND across axes.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterSelection {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind: Option<Kind>,
    /// Resolved legacy canonical bucket or non_sport for an unmappable category.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Canonical sport buckets, including Esports and Table Tennis, matched case-insensitively. Unknown names and league aliases such as NFL are rejected in sports; use category for legacy bucket aliases or leagues for exact league selection. Omission covers every sport admitted by the selected view.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sports: Option<Vec<String>>,
    /// Normalized machine/provider league identities, such as nfl, cfb, nba, epl, cs2, lol, dota2 or valorant. Known wire/tag aliases normalize; other provider keys match exact lowercase identity. This is separate from category: category=NFL selects Football, while leagues=nfl selects NFL only. Read market_context.league for authoritative values.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub leagues: Option<Vec<String>>,
    /// Exact provider sports_market_type values. This is an open provider taxonomy, distinct from exact market IDs. Read market_context.market_type; missing selected metadata excludes the row.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub market_types: Option<Vec<String>>,
    /// Exact market selections. Raw provider condition IDs and the existing mkt_-prefixed aliases normalize to raw IDs. Unknown well-formed IDs return an empty result.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub condition_ids: Option<Vec<String>>,
    /// Exact provider event slugs. Use event_slug returned on the row; no title or slug-prefix guessing.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_slugs: Option<Vec<String>>,
    /// Exact provider series slugs. Read market_context.series_slug; a missing selected series excludes the row.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub series_slugs: Option<Vec<String>>,
}

/// Backed-side analytics, token identity, frozen ranked_at and aggregate category evidence from the ranked snapshot, plus a separately dated current quote. Scores rank attention; they are not probabilities or order instructions.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterSignal {
    #[serde(default)]
    pub piled_side: Option<String>,
    pub piled_outcome_index: i64,
    /// Fraction of graded money on the backed side, not a percentage from 0 to 100.
    #[serde(default)]
    pub sharp_pct: Option<f64>,
    pub backed_sharp_usd: f64,
    pub s_count: i64,
    pub a_count: i64,
    pub b_count: i64,
    pub graded_holders: i64,
    #[serde(default)]
    pub top_grade: Option<MarketHolderGrade>,
    #[serde(default)]
    pub smart_score: Option<f64>,
    #[serde(default)]
    pub net_side: Option<String>,
    pub conviction_score: f64,
    #[serde(default)]
    pub one_way_holder_count: Option<i64>,
    #[serde(default)]
    pub hedged_holder_count: Option<i64>,
    #[serde(default)]
    pub one_way_graded_usd: Option<f64>,
    #[serde(default)]
    pub directional_confidence: Option<f64>,
    pub directional_rank_score: f64,
    #[serde(default)]
    pub current_price: Option<EdgeHunterPrice>,
    /// Frozen provider CLOB token ID for the backed outcome. Null when unavailable; matches outcomes[piled_outcome_index].token_id when the shared provider context is available.
    #[serde(default)]
    pub token_id: Option<String>,
    /// UTC computation time copied from this ranked row's frozen signal_created_at. It dates the ranking, not the separately observed quote, metadata writer, or wallet entry.
    pub ranked_at: String,
    /// Existing aggregate category evidence copied from the same ranked snapshot. Read its status, coverage and own clocks; it never changes admission or ordering and is not a predicted return.
    pub category_skill: EdgeHunterCategorySkill,
}

/// Full Edge Hunter signals list envelope. The view literal distinguishes advanced collections, including empty pages.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterSignalsResponse {
    pub object: String,
    pub view: String,
    pub data: Vec<EdgeHunterRankedSignal>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
    /// Normalized axes requested with a selector or category; omitted on an unselected default read.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub selection: Option<EdgeHunterSelection>,
}

/// Independent sports-board supply plus stored-universe terminal accounting for one canonical sport.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EdgeHunterSportFunnelReport {
    pub sport: Category,
    /// Unique condition ids independently visible on the provider-first sports board.
    pub board_input: i64,
    /// Whether the always-applicable live-board source completed as available. False can mean a completed source failure (board_source_unavailable) or live-board work missing an internal configured-scope deadline or the outer fair-wave deadline (board_deadline_unavailable); inspect terminals to distinguish them.
    pub board_live_available: bool,
    /// Whether a provider-backed upcoming-board source is configured and applicable for this sport. False means not applicable, not provider failure.
    pub board_upcoming_configured: bool,
    /// Whether every configured upcoming-board scope completed as available. False with board_upcoming_configured=false means not applicable. When board_upcoming_configured is true and this flag is false, read board_upcoming_status for the cause (it reads unknown, i.e. no recorded cause, only on a snapshot cached before that field existed, which self-clears within one TTL): the board_source_unavailable and board_deadline_unavailable terminals are assigned only to already-started rows (the live half) and are structurally 0 for the upcoming source, so they never explain this flag.
    pub board_upcoming_available: bool,
    /// Why the upcoming-board source is (un)available. Board supply is one canonical-sport union: the bare category owns live truth and every configured composed league scope contributes upcoming rows; folded leagues without a configured board (currently NCAAB and CFL) are not in the upcoming union. available: every configured scope completed truthfully (a successful empty schedule still counts). capacity_limited: provider pagination or a configured upcoming cache published an intentionally bounded complete-event prefix; those rows are excluded from diagnostic-universe input and must not be treated as a complete upcoming universe. Cache-bound prefixes are limited to an exact 5,000,000-byte final envelope. source_unavailable: composition failed before a truthful union; resolved scope readers turn half failures into cold_unavailable, so fresh producers are whole-union identity reconciliation or a registry contract failure and carry zero rows. cold_unavailable: every scope completed but at least one reported its upcoming half unavailable because no servable entry was inside the stale-serve bound and the background warm did not land in time; it is not by itself proof of a provider outage. deadline_unavailable: an internal configured-scope deadline or the outer bounded fair wave expired. An internal deadline may retain healthy bare-category or sibling-scope rows; the outer wave records zero rows. These upcoming fields do not describe league live-membership availability. If the bare-category live scope fails, all live rows are dropped even when a league scope completed, because the bare category is the sole live-truth owner. not_configured: no upcoming scope applies to the sport. unknown: exactly one cause -- a snapshot cached before this field existed whose legacy flags recorded an unavailable-but-configured half without saying why. Every freshly computed snapshot reports a concrete status, and a legacy available or not-configured row is reconstructed exactly, so unknown self-clears within one TTL. board_upcoming_available is exactly board_upcoming_status == available.
    pub board_upcoming_status: BoardUpcomingStatus,
    /// Configured upcoming scopes that did not complete as available. Values are category, a provider league tag slug (nfl, cfb, nba, wnba, euroleague-basketball, nhl, mls, valorant, league-of-legends, counter-strike-2, or dota-2), registry when the compiled scope/projection contract drifted, union when cross-scope identity reconciliation failed, or wave when the outer fair-wave deadline expired before scope-level evidence returned. Empty means no unavailable upcoming scope was identified; this includes healthy/not-configured rows and a legacy cached row. Observation league scopes are upcoming-only and perform no live-membership read.
    pub board_upcoming_unavailable_scopes: Vec<BoardUpcomingUnavailableScopes>,
    /// Stored-universe rows plus provider-board rows missing from storage.
    pub input: i64,
    /// Sparse counts over the closed 25-value terminal vocabulary: outside_horizon, resolved, provider_closed, provider_excluded, invalid_market, missing_token, missing_stored_market, not_provider_live, board_source_unavailable, board_deadline_unavailable, primary_slate_candidate, zero_indexed_holder_research, capacity_limited, provider_unavailable, holder_deadline_unavailable, holder_computation_unavailable, holder_scan_incomplete, no_current_graded_holder, split_holder_pile, price_unavailable, wider_holder_emitted, in_play_emitted, in_play_stale_observed, in_play_directional_unavailable, or internal_unclassified. primary_slate_candidate means exact admission by the funded route's raw shared signals query before provider/holder enrichment; recent-flow rows rejected by its event, bucket, or total caps remain eligible for wider_holder measurement. capacity_limited is intentional bounded provider-work admission, is fully accounted here, and does not itself set degraded=true. board_source_unavailable means a completed board source was unavailable; board_deadline_unavailable means live-board work missed either an internal configured-scope deadline or the outer fair-wave deadline; provider_unavailable means an attempted holder-provider read failed; holder_deadline_unavailable means holder cache/provider work missed the absolute request deadline; holder_computation_unavailable means post-holder provider or DB-backed price/metadata evaluation was unavailable.
    pub terminals: std::collections::BTreeMap<String, i64>,
    /// Sum of every sparse terminal count.
    pub terminal_total: i64,
    /// True exactly when input equals terminal_total.
    pub reconciled: bool,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum EnrichmentStatus {
    /// `available`
    #[serde(rename = "available")]
    Available,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl EnrichmentStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Available => "available",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for EnrichmentStatus {
    fn from(value: &str) -> Self {
        match value {
            "available" => Self::Available,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for EnrichmentStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for EnrichmentStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ErrorCode {
    /// `bad_request`
    #[serde(rename = "bad_request")]
    BadRequest,
    /// `invalid_api_key`
    #[serde(rename = "invalid_api_key")]
    InvalidApiKey,
    /// `subscription_required`
    #[serde(rename = "subscription_required")]
    SubscriptionRequired,
    /// `forbidden`
    #[serde(rename = "forbidden")]
    Forbidden,
    /// `insufficient_scope`
    #[serde(rename = "insufficient_scope")]
    InsufficientScope,
    /// `not_found`
    #[serde(rename = "not_found")]
    NotFound,
    /// `account_locked`
    #[serde(rename = "account_locked")]
    AccountLocked,
    /// `rate_limited`
    #[serde(rename = "rate_limited")]
    RateLimited,
    /// `rate_limit_unavailable`
    #[serde(rename = "rate_limit_unavailable")]
    RateLimitUnavailable,
    /// `internal_error`
    #[serde(rename = "internal_error")]
    InternalError,
    /// `request_timeout`
    #[serde(rename = "request_timeout")]
    RequestTimeout,
    /// `endpoint_retired`
    #[serde(rename = "endpoint_retired")]
    EndpointRetired,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ErrorCode {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::BadRequest => "bad_request",
            Self::InvalidApiKey => "invalid_api_key",
            Self::SubscriptionRequired => "subscription_required",
            Self::Forbidden => "forbidden",
            Self::InsufficientScope => "insufficient_scope",
            Self::NotFound => "not_found",
            Self::AccountLocked => "account_locked",
            Self::RateLimited => "rate_limited",
            Self::RateLimitUnavailable => "rate_limit_unavailable",
            Self::InternalError => "internal_error",
            Self::RequestTimeout => "request_timeout",
            Self::EndpointRetired => "endpoint_retired",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ErrorCode {
    fn from(value: &str) -> Self {
        match value {
            "bad_request" => Self::BadRequest,
            "invalid_api_key" => Self::InvalidApiKey,
            "subscription_required" => Self::SubscriptionRequired,
            "forbidden" => Self::Forbidden,
            "insufficient_scope" => Self::InsufficientScope,
            "not_found" => Self::NotFound,
            "account_locked" => Self::AccountLocked,
            "rate_limited" => Self::RateLimited,
            "rate_limit_unavailable" => Self::RateLimitUnavailable,
            "internal_error" => Self::InternalError,
            "request_timeout" => Self::RequestTimeout,
            "endpoint_retired" => Self::EndpointRetired,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ErrorCode {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ErrorCode {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ErrorReason {
    /// `cursor_expired`
    #[serde(rename = "cursor_expired")]
    CursorExpired,
    /// `unknown_endpoint`
    #[serde(rename = "unknown_endpoint")]
    UnknownEndpoint,
    /// `pick_not_released`
    #[serde(rename = "pick_not_released")]
    PickNotReleased,
    /// `trader_not_tracked`
    #[serde(rename = "trader_not_tracked")]
    TraderNotTracked,
    /// `market_out_of_scope`
    #[serde(rename = "market_out_of_scope")]
    MarketOutOfScope,
    /// `read_model_warming`
    #[serde(rename = "read_model_warming")]
    ReadModelWarming,
    /// `database_unavailable`
    #[serde(rename = "database_unavailable")]
    DatabaseUnavailable,
    /// `request_accounting_unavailable`
    #[serde(rename = "request_accounting_unavailable")]
    RequestAccountingUnavailable,
    /// `idempotency_in_progress`
    #[serde(rename = "idempotency_in_progress")]
    IdempotencyInProgress,
    /// `webhook_delivery_in_progress`
    #[serde(rename = "webhook_delivery_in_progress")]
    WebhookDeliveryInProgress,
    /// `webhook_secret_rotation_not_prepared`
    #[serde(rename = "webhook_secret_rotation_not_prepared")]
    WebhookSecretRotationNotPrepared,
    /// `webhook_secret_rotation_overlap_active`
    #[serde(rename = "webhook_secret_rotation_overlap_active")]
    WebhookSecretRotationOverlapActive,
    /// `sandbox_api_key`
    #[serde(rename = "sandbox_api_key")]
    SandboxApiKey,
    /// `api_key_in_query`
    #[serde(rename = "api_key_in_query")]
    ApiKeyInQuery,
    /// `subscription_inactive`
    #[serde(rename = "subscription_inactive")]
    SubscriptionInactive,
    /// `monthly_quota_exceeded`
    #[serde(rename = "monthly_quota_exceeded")]
    MonthlyQuotaExceeded,
    /// `invalid_query`
    #[serde(rename = "invalid_query")]
    InvalidQuery,
    /// `unknown_query_parameter`
    #[serde(rename = "unknown_query_parameter")]
    UnknownQueryParameter,
    /// `invalid_path`
    #[serde(rename = "invalid_path")]
    InvalidPath,
    /// `invalid_body`
    #[serde(rename = "invalid_body")]
    InvalidBody,
    /// `unsupported_media_type`
    #[serde(rename = "unsupported_media_type")]
    UnsupportedMediaType,
    /// `payload_too_large`
    #[serde(rename = "payload_too_large")]
    PayloadTooLarge,
    /// `method_not_allowed`
    #[serde(rename = "method_not_allowed")]
    MethodNotAllowed,
    /// `ip_rate_limited`
    #[serde(rename = "ip_rate_limited")]
    IpRateLimited,
    /// `ip_throttled`
    #[serde(rename = "ip_throttled")]
    IpThrottled,
    /// `export_expired`
    #[serde(rename = "export_expired")]
    ExportExpired,
    /// `freshness_ceiling_unsatisfied`
    #[serde(rename = "freshness_ceiling_unsatisfied")]
    FreshnessCeilingUnsatisfied,
    /// `max_plan_required`
    #[serde(rename = "max_plan_required")]
    MaxPlanRequired,
    /// `endpoint_retired`
    #[serde(rename = "endpoint_retired")]
    EndpointRetired,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ErrorReason {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::CursorExpired => "cursor_expired",
            Self::UnknownEndpoint => "unknown_endpoint",
            Self::PickNotReleased => "pick_not_released",
            Self::TraderNotTracked => "trader_not_tracked",
            Self::MarketOutOfScope => "market_out_of_scope",
            Self::ReadModelWarming => "read_model_warming",
            Self::DatabaseUnavailable => "database_unavailable",
            Self::RequestAccountingUnavailable => "request_accounting_unavailable",
            Self::IdempotencyInProgress => "idempotency_in_progress",
            Self::WebhookDeliveryInProgress => "webhook_delivery_in_progress",
            Self::WebhookSecretRotationNotPrepared => "webhook_secret_rotation_not_prepared",
            Self::WebhookSecretRotationOverlapActive => "webhook_secret_rotation_overlap_active",
            Self::SandboxApiKey => "sandbox_api_key",
            Self::ApiKeyInQuery => "api_key_in_query",
            Self::SubscriptionInactive => "subscription_inactive",
            Self::MonthlyQuotaExceeded => "monthly_quota_exceeded",
            Self::InvalidQuery => "invalid_query",
            Self::UnknownQueryParameter => "unknown_query_parameter",
            Self::InvalidPath => "invalid_path",
            Self::InvalidBody => "invalid_body",
            Self::UnsupportedMediaType => "unsupported_media_type",
            Self::PayloadTooLarge => "payload_too_large",
            Self::MethodNotAllowed => "method_not_allowed",
            Self::IpRateLimited => "ip_rate_limited",
            Self::IpThrottled => "ip_throttled",
            Self::ExportExpired => "export_expired",
            Self::FreshnessCeilingUnsatisfied => "freshness_ceiling_unsatisfied",
            Self::MaxPlanRequired => "max_plan_required",
            Self::EndpointRetired => "endpoint_retired",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ErrorReason {
    fn from(value: &str) -> Self {
        match value {
            "cursor_expired" => Self::CursorExpired,
            "unknown_endpoint" => Self::UnknownEndpoint,
            "pick_not_released" => Self::PickNotReleased,
            "trader_not_tracked" => Self::TraderNotTracked,
            "market_out_of_scope" => Self::MarketOutOfScope,
            "read_model_warming" => Self::ReadModelWarming,
            "database_unavailable" => Self::DatabaseUnavailable,
            "request_accounting_unavailable" => Self::RequestAccountingUnavailable,
            "idempotency_in_progress" => Self::IdempotencyInProgress,
            "webhook_delivery_in_progress" => Self::WebhookDeliveryInProgress,
            "webhook_secret_rotation_not_prepared" => Self::WebhookSecretRotationNotPrepared,
            "webhook_secret_rotation_overlap_active" => Self::WebhookSecretRotationOverlapActive,
            "sandbox_api_key" => Self::SandboxApiKey,
            "api_key_in_query" => Self::ApiKeyInQuery,
            "subscription_inactive" => Self::SubscriptionInactive,
            "monthly_quota_exceeded" => Self::MonthlyQuotaExceeded,
            "invalid_query" => Self::InvalidQuery,
            "unknown_query_parameter" => Self::UnknownQueryParameter,
            "invalid_path" => Self::InvalidPath,
            "invalid_body" => Self::InvalidBody,
            "unsupported_media_type" => Self::UnsupportedMediaType,
            "payload_too_large" => Self::PayloadTooLarge,
            "method_not_allowed" => Self::MethodNotAllowed,
            "ip_rate_limited" => Self::IpRateLimited,
            "ip_throttled" => Self::IpThrottled,
            "export_expired" => Self::ExportExpired,
            "freshness_ceiling_unsatisfied" => Self::FreshnessCeilingUnsatisfied,
            "max_plan_required" => Self::MaxPlanRequired,
            "endpoint_retired" => Self::EndpointRetired,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ErrorReason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ErrorReason {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplayEvent {
    /// Opaque event identity: the ef_-encoded whale_alerts.id, stable across cursor formats. Deduplicate on this, never on cursor or sequence.
    pub id: String,
    pub r#type: String,
    /// Cursor positioned at this event: its (inserted_xid, id) commit-order position. Store the page's next_cursor to continue; this one resumes from exactly this event.
    pub cursor: String,
    /// whale_alerts.id of the event. Not monotonic across a replay: events arrive in commit order, so a lower id can follow a higher one when its write finished later. Order and resume by cursor, deduplicate by id.
    pub sequence: i64,
    pub published_at: String,
    /// What the event announces. Every field is present on every event; a field added later is additive, so a client tolerates keys it does not know.
    pub payload: EventReplayEventPayload,
    /// Present only with expand=trade: the base trade fields for this row, read at request time from one query per page. GET /api/v1/large-trades/{id} adds counterparty_analysis; replay does not include it. traded_at, side, size_usd, price, outcome, token_id, recorded_signal_score and trader.grade_at_trade with its status are the row's event-time facts; trader.grade, trader.username, signal_score, suspicion_score, suspicion_track and market title/slug/category are enrichment that can move after the event. null when that route would answer 404 for the row (its trader or market is not synced yet).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub trade: Option<LargeTrade>,
    pub source: EventReplaySource,
    pub freshness: EventReplayFreshness,
}

/// What the event announces. Every field is present on every event; a field added later is additive, so a client tolerates keys it does not know.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplayEventPayload {
    /// Whale trades this event announces. One event is minted per stored whale trade, so this is 1.
    pub count: i64,
    /// The raw whale_alerts.id of the trade, the same number as sequence. GET /api/v1/whale-trades/{id} accepts it and returns the trade with its wallet, grade, size, price and market.
    pub whale_alert_id: i64,
    /// The Polymarket condition id of the market the trade was in.
    pub condition_id: String,
    /// 0xinsider's numeric id for the wallet's trader row. It is not the trd_ id, which is derived from the address; read the address and grade from the whale trade.
    pub trader_id: i64,
    /// Provider discriminator. Polymarket only.
    pub platform: String,
    /// Keys this release does not name. The API adds fields additively; they are kept here.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, serde_json::Value>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplayFreshness {
    pub status: String,
    pub observed_at: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplayMeta {
    /// Unique request ID (req_ prefix). The same value as the X-Request-Id response header, the request's usage accounting row and its log lines.
    pub request_id: String,
    pub cached: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cache_age_s: Option<i64>,
    /// Advisory request weight (relative compute cost). 1 for simple reads; higher for heavier endpoints. Not a credit/price.
    pub cost: i64,
    pub replay: EventReplayMetaReplay,
    pub retention: EventReplayMetaRetention,
    pub completeness: EventReplayMetaCompleteness,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplayMetaCompleteness {
    /// complete: the page carries every durable event matching the filters after the cursor below the commit horizon, up to limit. caught_up: nothing matching after the cursor is visible below the horizon; read pending_beyond_horizon to tell an idle stream from held rows, and note next_cursor has still advanced to the horizon.
    pub status: EventReplayMetaCompletenessStatus,
    pub reason: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum EventReplayMetaCompletenessStatus {
    /// `complete`
    #[serde(rename = "complete")]
    Complete,
    /// `caught_up`
    #[serde(rename = "caught_up")]
    CaughtUp,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl EventReplayMetaCompletenessStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Complete => "complete",
            Self::CaughtUp => "caught_up",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for EventReplayMetaCompletenessStatus {
    fn from(value: &str) -> Self {
        match value {
            "complete" => Self::Complete,
            "caught_up" => Self::CaughtUp,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for EventReplayMetaCompletenessStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for EventReplayMetaCompletenessStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplayMetaReplay {
    /// The request cursor in canonical form (an id-only cursor is re-encoded), or the zero position when omitted.
    pub from_cursor: String,
    /// Identical to next_cursor. After a full page, the cursor of the last event; after a page that is not full, the commit horizon itself, since every row below it, matching or not, has been examined. An empty page therefore still advances.
    pub to_cursor: String,
    /// whale_alerts.id component of the request cursor (0 when omitted).
    pub from_sequence: i64,
    /// whale_alerts.id of the last event on this page, or from_sequence when the page is empty. Can sit below the position next_cursor encodes after a page that is not full.
    pub to_sequence: i64,
    /// Events are ordered by the position at which their write became visible (whale_alerts.inserted_xid), then by whale_alerts.id, and a page is bounded by the oldest write transaction still open when it was read. Before 2026-09-22 this read whale_alerts_id_asc; that order could skip a late-committing lower id (#16180).
    pub ordering: String,
    /// True when committed whale-trade rows newer than this page's commit-visibility horizon exist. They are held until every older write transaction has finished and are served on a later request, so a caught_up page with this true is not the end of the stream: poll again. A long open write transaction on the database (a single-transaction backfill) is what keeps this true for more than a few seconds.
    pub pending_beyond_horizon: bool,
    /// The effective filter set this page ran with and next_cursor is bound to. Absent on an unfiltered walk.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub filters: Option<EventReplayMetaReplayFilters>,
    /// The expansions applied to every event on this page; empty when none.
    pub expand: Vec<String>,
}

/// The effective filter set this page ran with and next_cursor is bound to. Absent on an unfiltered walk.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplayMetaReplayFilters {
    /// The trader parameter as given.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub trader: Option<String>,
    /// The raw provider condition id after mkt_ is stripped.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub condition_id: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub min_grade: Option<Grade>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub min_size: Option<f64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplayMetaRetention {
    pub status: String,
    pub retained_events: i64,
    pub cursor_expired: bool,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EventReplaySource {
    pub kind: String,
    pub producer_family: String,
    pub owner: String,
    pub provider_fetch_at_request_time: bool,
}

/// A lossless decimal atom rendered from the canonical NUMERIC or provider value. The value is a decimal string and must be parsed with a decimal library; it is never a display string and must not be converted through a binary float. `scale` is the source decimal scale. The field is omitted when its source is unavailable.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExactDecimal {
    /// Plain decimal text at full source precision, including a minus sign for negative values and trailing zeros when the source scale carries them. Parse as an arbitrary-precision decimal.
    pub value: String,
    /// Unit of the value, such as `USD`, `USD/share`, or `shares`.
    pub unit: String,
    /// Number of digits after the decimal point in `value`'s source atom.
    pub scale: i64,
    /// Backend-owned source or derivation basis. Treat it as provenance, not as a display label.
    pub basis: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ExchangeFamily {
    /// `ctf_v2`
    #[serde(rename = "ctf_v2")]
    CtfV2,
    /// `neg_risk_ctf_v2`
    #[serde(rename = "neg_risk_ctf_v2")]
    NegRiskCtfV2,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ExchangeFamily {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::CtfV2 => "ctf_v2",
            Self::NegRiskCtfV2 => "neg_risk_ctf_v2",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ExchangeFamily {
    fn from(value: &str) -> Self {
        match value {
            "ctf_v2" => Self::CtfV2,
            "neg_risk_ctf_v2" => Self::NegRiskCtfV2,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ExchangeFamily {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ExchangeFamily {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Expand {
    /// `strategy`
    #[serde(rename = "strategy")]
    Strategy,
    /// `categories`
    #[serde(rename = "categories")]
    Categories,
    /// `quant_metrics`
    #[serde(rename = "quant_metrics")]
    QuantMetrics,
    /// `trust`
    #[serde(rename = "trust")]
    Trust,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Expand {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Strategy => "strategy",
            Self::Categories => "categories",
            Self::QuantMetrics => "quant_metrics",
            Self::Trust => "trust",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Expand {
    fn from(value: &str) -> Self {
        match value {
            "strategy" => Self::Strategy,
            "categories" => Self::Categories,
            "quant_metrics" => Self::QuantMetrics,
            "trust" => Self::Trust,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Expand {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Expand {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Discriminated by `type`. A `type` this release does not know is kept whole in
/// `Unknown`, so a new kind never fails a response.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum ExploreEntry {
    /// `type` is `group`.
    Group(ExploreGroup),
    /// `type` is `standalone`.
    Standalone(ExploreStandalone),
    /// A `type` this release does not know, kept as sent.
    Unknown(serde_json::Value),
}

impl<'de> Deserialize<'de> for ExploreEntry {
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = serde_json::Value::deserialize(deserializer)?;
        match value.get("type").and_then(serde_json::Value::as_str) {
            Some("group") => serde_json::from_value(value)
                .map(Self::Group)
                .map_err(de::Error::custom),
            Some("standalone") => serde_json::from_value(value)
                .map(Self::Standalone)
                .map_err(de::Error::custom),
            _ => Ok(Self::Unknown(value)),
        }
    }
}

impl Serialize for ExploreEntry {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        match self {
            Self::Group(inner) => inner.serialize(serializer),
            Self::Standalone(inner) => inner.serialize(serializer),
            Self::Unknown(inner) => inner.serialize(serializer),
        }
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExploreFacetValue {
    pub value: String,
    pub label: String,
    pub count: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExploreFacets {
    pub categories: Vec<ExploreFacetValue>,
    pub platforms: Vec<ExploreFacetValue>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExploreGroup {
    pub r#type: String,
    pub event_slug: String,
    pub parent_title: String,
    #[serde(default)]
    pub image: Option<String>,
    /// Provider platform. Always polymarket, or null when the row carries no stored value.
    #[serde(default)]
    pub platform: Option<String>,
    #[serde(default)]
    pub category: Option<String>,
    /// Markets in the event cluster, ranked by volume with condition_id as the tie-breaker. The selected representative is retained within the 12-market cap.
    pub markets: Vec<ExploreMarket>,
    /// The volume of the group's highest-volume market, which is markets[0]: the same figure as that market's volume, Polymarket's cumulative taker volume in shares rather than cash. Null when unavailable.
    #[serde(default)]
    pub rep_volume: Option<f64>,
    /// Canonical key since #16304; rep_whales is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub rep_large_trades: Option<i64>,
    #[serde(default)]
    pub rep_whales: Option<i64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExploreMarket {
    pub id: String,
    pub condition_id: String,
    /// Non-empty market title.
    pub title: String,
    /// Provider-native market slug.
    #[serde(default)]
    pub slug: Option<String>,
    /// First-party market page slug used for internal links.
    #[serde(default)]
    pub url_slug: Option<String>,
    #[serde(default)]
    pub image: Option<String>,
    #[serde(default)]
    pub icon: Option<String>,
    #[serde(default)]
    pub category: Option<String>,
    /// Provider platform. Always polymarket, or null when the row carries no stored value.
    #[serde(default)]
    pub platform: Option<String>,
    /// closed once Polymarket has closed trading or the market has resolved; active otherwise. The same rule labels a market on markets/search, markets/explore and market/{condition_id}/snapshot.
    pub status: MarketSearchResultStatus,
    /// Polymarket's traded-volume figure for the market, as last stored: cumulative taker volume in shares, each counted at its $1 settlement value, not the cash that changed hands (100 shares bought at $0.40 add 100, not 40). It can lag Polymarket's current figure. sort=volume orders by it. Null when unavailable.
    #[serde(default)]
    pub volume: Option<f64>,
    #[serde(default)]
    pub liquidity: Option<f64>,
    /// Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub large_trade_count: Option<i64>,
    #[serde(default)]
    pub whale_trade_count: Option<i64>,
    /// Canonical key since #16304; whale_distinct_wallets is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub large_trade_distinct_wallets: Option<i64>,
    #[serde(default)]
    pub whale_distinct_wallets: Option<i64>,
    /// Canonical key since #16304; whale_total_usd is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub large_trade_total_usd: Option<f64>,
    #[serde(default)]
    pub whale_total_usd: Option<f64>,
    /// Canonical key since #16304; whale_last_trade_at is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub large_trade_last_at: Option<String>,
    #[serde(default)]
    pub whale_last_trade_at: Option<String>,
    #[serde(default)]
    pub end_date: Option<String>,
    #[serde(default)]
    pub created_at: Option<String>,
    #[serde(default)]
    pub outcome_yes: Option<String>,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the YES outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id_yes: Option<String>,
    #[serde(default)]
    pub outcome_no: Option<String>,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the NO outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id_no: Option<String>,
    #[serde(default)]
    pub event_slug: Option<String>,
    #[serde(default)]
    pub smart_score: Option<f64>,
    #[serde(default)]
    pub smart_count: Option<i64>,
    /// The outcome graded money leans toward RELATIVE TO THE PRICE: named only when the graded money's share of a side diverges from that side's price-implied share by at least 10 points, with at least $500 on the leaning side and outside the crowded-side guard. Null when the money sits with the price (no lean), when there is no graded money, or when the price is unavailable. The same rule as the market page.
    #[serde(default)]
    pub smart_label: Option<String>,
    /// When the oldest stored smart-money wallet behind this split (smart_score, smart_count and smart_label) last finished syncing. Graded wallets sync on different schedules, so this is often hours or days ago. Some holdings in the split can come from a Polymarket holder read cached for up to 3 minutes, which this time does not describe. Null when there is no split or a wallet's sync time is unknown.
    #[serde(default)]
    pub sharp_money_as_of: Option<String>,
    /// Display label for the YES/outcome_index=0 side, enriched from provider outcome metadata when available.
    #[serde(default)]
    pub outcome_yes_label: Option<String>,
    /// Display label for the NO/outcome_index=1 side, enriched from provider outcome metadata when available.
    #[serde(default)]
    pub outcome_no_label: Option<String>,
    /// Provider-owned YES/outcome_index=0 identifier when available for trade-ticket wiring.
    #[serde(default)]
    pub outcome_yes_provider_id: Option<i64>,
    /// Provider-owned NO/outcome_index=1 identifier when available for trade-ticket wiring.
    #[serde(default)]
    pub outcome_no_provider_id: Option<i64>,
    #[serde(default)]
    pub open_interest: Option<f64>,
    #[serde(default)]
    pub oi_change_pct: Option<f64>,
    #[serde(default)]
    pub price_points: Option<Vec<Vec<f64>>>,
    #[serde(default)]
    pub no_price_points: Option<Vec<Vec<f64>>>,
    #[serde(default)]
    pub last_price: Option<f64>,
    #[serde(default)]
    pub no_last_price: Option<f64>,
    #[serde(default)]
    pub change_pct_24h: Option<f64>,
    #[serde(default)]
    pub no_change_pct_24h: Option<f64>,
    /// Backend-owned deterministic market discovery score used by the hot sort.
    #[serde(default)]
    pub discover_score: Option<f64>,
    pub score_components: ExploreMarketScoreComponents,
    pub freshness: ExploreMarketFreshness,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExploreMarketFreshness {
    pub enrichment_status: EnrichmentStatus,
    pub price_status: EnrichmentStatus,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExploreMarketScoreComponents {
    #[serde(default)]
    pub volume_signal: Option<f64>,
    /// Canonical key since #16304; whale_signal is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub large_trade_signal: Option<f64>,
    #[serde(default)]
    pub whale_signal: Option<f64>,
    #[serde(default)]
    pub liquidity_signal: Option<f64>,
    #[serde(default)]
    pub recency_signal: Option<f64>,
    /// Canonical key since #16308; smart_money_signal is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub sharp_money_signal: Option<f64>,
    /// Deprecated spelling of sharp_money_signal; emitted beside it with the same value and never removed.
    #[serde(default)]
    pub smart_money_signal: Option<f64>,
    #[serde(default)]
    pub price_move_signal: Option<f64>,
    pub missing_price_penalty: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExploreMarketsResponse {
    pub object: String,
    pub data: Vec<ExploreEntry>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching visible entries after grouping. Present on the first page and omitted on cursor pages.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub facets: ExploreFacets,
    pub meta: ResponseMeta,
    /// When this response body was computed. Present whenever the body came from, or was just written to, the 60s explore cache. Pair it with fresh_for_seconds to derive how much longer the body may be reused: fresh_for_seconds - age(computed_at). Excluded from the ETag validator, so a body recomputed with identical data keeps its validator.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub computed_at: Option<String>,
    /// How long the body computed at computed_at is good for, in seconds. Deliberately not pre-subtracted: a cached body cannot carry a number that changes while it sits in the cache. Excluded from the ETag validator.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub fresh_for_seconds: Option<i64>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ExploreMarketsSort {
    /// `trending`
    #[serde(rename = "trending")]
    Trending,
    /// `hot`
    #[serde(rename = "hot")]
    Hot,
    /// `expiring`
    #[serde(rename = "expiring")]
    Expiring,
    /// `large_trades`
    #[serde(rename = "large_trades")]
    LargeTrades,
    /// `whales`
    #[serde(rename = "whales")]
    Whales,
    /// `volume`
    #[serde(rename = "volume")]
    Volume,
    /// `newest`
    #[serde(rename = "newest")]
    Newest,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ExploreMarketsSort {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Trending => "trending",
            Self::Hot => "hot",
            Self::Expiring => "expiring",
            Self::LargeTrades => "large_trades",
            Self::Whales => "whales",
            Self::Volume => "volume",
            Self::Newest => "newest",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ExploreMarketsSort {
    fn from(value: &str) -> Self {
        match value {
            "trending" => Self::Trending,
            "hot" => Self::Hot,
            "expiring" => Self::Expiring,
            "large_trades" => Self::LargeTrades,
            "whales" => Self::Whales,
            "volume" => Self::Volume,
            "newest" => Self::Newest,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ExploreMarketsSort {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ExploreMarketsSort {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExploreStandalone {
    pub r#type: String,
    pub market: ExploreMarket,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExportCompleteness {
    pub status: SnapshotCompletenessStatus,
    pub reason: String,
    pub sync_coverage: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExportCounts {
    /// Daily P&L rows. The daily P&L covers every market of the wallet.
    pub pnl_days: i64,
    /// The wallet's sports and esports markets: the rows of the export's markets section, before its 50,000-row cap.
    pub exported_markets: i64,
    /// Estimated trades in the wallet's sports and esports markets: the summed trade counts of those markets. The file counts its own rows in generation.source_watermarks.trades.rows.
    pub estimated_trade_rows: i64,
    /// Estimated file size from estimated_trade_rows and exported_markets.
    pub estimated_size_mb: f64,
}

/// `export_job_cancelled` data: the owner's export stopped because its owner cancelled it.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExportJobCancelledData {
    pub job_id: i64,
    pub status: String,
    pub format: String,
    pub next_action: String,
}

/// `export_job_expired` data: the owner's ready export passed retention.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExportJobExpiredData {
    pub job_id: i64,
    pub status: String,
    pub format: String,
    pub next_action: String,
}

/// `export_job_failed` data: the owner's asynchronous export reached a terminal failure.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExportJobFailedData {
    pub job_id: i64,
    pub status: String,
    pub format: String,
    pub next_action: String,
    pub failure_reason: String,
}

/// `export_job_ready` data: the owner's asynchronous export can be downloaded. Download authorization stays on the status and download routes.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExportJobReadyData {
    pub job_id: i64,
    pub status: String,
    pub format: String,
    pub next_action: String,
    #[serde(default)]
    pub total_trades: Option<i64>,
    #[serde(default)]
    pub processed_trades: Option<i64>,
    /// Artifact size in bytes.
    #[serde(default)]
    pub file_size: Option<i64>,
    #[serde(default)]
    pub data_as_of: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExportSourceRange {
    #[serde(default)]
    pub first_pnl_date: Option<String>,
    #[serde(default)]
    pub last_pnl_date: Option<String>,
    /// The latest trade in the wallet's sports and esports markets. Null when it has none.
    #[serde(default)]
    pub latest_trade_at: Option<String>,
    /// Same instant as latest_trade_at: the latest activity of the markets the export holds.
    #[serde(default)]
    pub latest_market_activity_at: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ExportVolumeReconciliation {
    /// Verified full-history both-sides USD cash volume. Null without coverage; the local activity numerator may cover only a subset of history.
    #[serde(default)]
    pub provider_lifetime_volume: Option<f64>,
    /// Cash in USD, buys and sells, summed over the daily P&L rows this export carries, from the fills 0xinsider has stored for the wallet. It can cover less history than provider_lifetime_volume; never Polymarket's share count.
    pub exported_activity_volume: f64,
    /// Cost basis in USD summed over the wallet's sports and esports markets, the markets section of the export.
    pub exported_market_cost_basis: f64,
    /// provider_lifetime_volume minus exported_activity_volume, in USD, rounded to cents. Null when provider_lifetime_volume is null.
    #[serde(default)]
    pub provider_activity_volume_gap: Option<f64>,
    /// exported_activity_volume divided by provider_lifetime_volume, a fraction of the cash, not a percent. Null when provider_lifetime_volume is null or zero.
    #[serde(default)]
    pub activity_volume_coverage: Option<f64>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Format {
    /// `json`
    #[serde(rename = "json")]
    Json,
    /// `ndjson`
    #[serde(rename = "ndjson")]
    Ndjson,
    /// `csv`
    #[serde(rename = "csv")]
    Csv,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Format {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Json => "json",
            Self::Ndjson => "ndjson",
            Self::Csv => "csv",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Format {
    fn from(value: &str) -> Self {
        match value {
            "json" => Self::Json,
            "ndjson" => Self::Ndjson,
            "csv" => Self::Csv,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Format {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Format {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Freshness {
    /// `fresh`
    #[serde(rename = "fresh")]
    Fresh,
    /// `refreshing`
    #[serde(rename = "refreshing")]
    Refreshing,
    /// `stale`
    #[serde(rename = "stale")]
    Stale,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Freshness {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Fresh => "fresh",
            Self::Refreshing => "refreshing",
            Self::Stale => "stale",
            Self::Unknown => "unknown",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Freshness {
    fn from(value: &str) -> Self {
        match value {
            "fresh" => Self::Fresh,
            "refreshing" => Self::Refreshing,
            "stale" => Self::Stale,
            "unknown" => Self::Unknown,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Freshness {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Freshness {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct FreshnessFailure {
    /// The caller's requested whole-response freshness ceiling in seconds.
    pub max_age_s: i64,
    /// Age in seconds of the oldest stored data_quality.as_of clock, when one is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub actual_age_s: Option<i64>,
    /// The oldest stored data-quality clock used to calculate actual_age_s, when one is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub as_of: Option<String>,
    /// The trader body's whole-response data-quality status. Only fresh can satisfy max_age_s.
    pub data_quality_status: DataQualityGroupStatus,
}

/// One sports or esports game: both sides, its schedule, provider status, linked Polymarket markets and their available provider moneyline price states. Assembled from the same provider-first live and upcoming projections the site's boards use, with no request-time provider fan-out.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Game {
    pub object: String,
    /// The game's identity, for example mlb-mil-cin-2026-06-22. The same key the live_sports_updated webhook pulse carries and the same key /api/v1/games/{event_slug} takes.
    pub event_slug: String,
    /// The provider's Gamma gameId, as a string. Omitted when the canonical owner has no single value for this slug: the provider stamps one gameId across an event's derivative siblings, so an ambiguous read is reported as unknown rather than guessed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub game_id: Option<String>,
    /// The canonical sport bucket, for example Soccer or Table Tennis. Omitted when neither the board scope nor the provider category names one.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sport: Option<String>,
    /// The league tag, for example nfl or epl. Omitted for a sport served as one whole bucket with no league scope.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub league: Option<String>,
    /// The provider's event title. Omitted when the provider sent none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    /// Kickoff in UTC, as the provider supplied it. Omitted when the provider published none; coverage.schedule then reads unavailable.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scheduled_at: Option<String>,
    pub status: GameStatus,
    /// Both sides, in the provider's own order. For a team league the provider lists the home side first. Empty when the provider identified neither side.
    pub competitors: Vec<GameCompetitor>,
    /// The esports series length, for example Bo3. Omitted for everything else.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub series_format: Option<String>,
    /// Whether this read includes a market classified as paying on a draw, including soccer's independent 1X2 draw leg. Read this instead of assuming a two-outcome moneyline.
    pub draw_offered: bool,
    /// Every market this read linked to the game, ordered by condition_id.
    pub markets: Vec<GameMarket>,
    pub freshness: GameFreshness,
    pub coverage: GameCoverage,
    /// The game's page on 0xinsider.
    pub url: String,
}

/// One side of the game.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameCompetitor {
    /// The competitor's name as the provider gives it.
    pub name: String,
    /// The provider's league-scoped competitor id, as a string. Omitted when the provider has not identified this side; coverage.competitors then reads labels.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub provider_id: Option<String>,
    /// Provider crest or logo URL. Omitted when there is none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub logo: Option<String>,
    /// The provider's score for this side, verbatim. A string because the provider sends one: a set score, a map score and a run total are not all integers. Omitted when no live-score frame carries a score.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub score: Option<String>,
    /// The provider's season record for this side, for example 12-4. Omitted when the provider sent none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub record: Option<String>,
}

/// What this game's read actually supplied, so a client branches on coverage instead of on a missing key.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameCoverage {
    /// available when a live-score frame supplied this game's scores.
    pub scores: EnrichmentStatus,
    /// provider_ids when every side carries a provider id, labels when only the provider's names identify them, unavailable when neither exists. Do not join on names when this reads labels.
    pub competitors: Competitors,
    /// available when the provider supplied a kickoff.
    pub schedule: EnrichmentStatus,
}

/// How current this game's facts are. Independent per source: the board half that produced the game, and the live-score frame that produced its scores.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameFreshness {
    /// Which board half produced this game.
    pub source: Source,
    /// Whether that half returned a truthful source body for this read.
    pub source_status: SourceStatus,
    /// Whether that half had a source body at all. not_applicable means the sport has no configured source for that half.
    pub source_availability: SourceAvailability,
    /// Freshness of the cached source body, never inferred from the response clock or the row count.
    pub source_freshness: SourceFreshness,
    /// The source body's data vintage. Omitted when the read has no vintage anchor, which is not age zero.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub source_observed_at: Option<String>,
    /// Age of source_observed_at in seconds, capped at 600. Omitted past the cap or with no anchor.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub source_age_seconds: Option<i64>,
    /// Whether a reader should be told these rows are behind. This applies the half's own servable-age bar (15 s live, 120 s upcoming), which is not the same as source_freshness: a live board whose scores are seconds old reads stale for about half of every publish cycle and is not delayed.
    pub delayed: bool,
    /// When this game's live-score frame was observed. Omitted when there is no frame.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scores_observed_at: Option<String>,
    /// The provider's own frame clock. Omitted when the frame carries none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scores_source_at: Option<String>,
}

/// One Polymarket market linked to this game.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameMarket {
    /// The mkt_-prefixed market id every other V1 response uses.
    pub id: String,
    /// The raw provider condition id.
    pub condition_id: String,
    /// Always polymarket.
    pub platform: String,
    /// The provider's market slug. Omitted when the provider sent none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub slug: Option<String>,
    /// The provider's own market type, for example moneyline or spread. Omitted when the provider sent none. Not an enum: the provider owns this vocabulary and adds to it.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sports_market_type: Option<String>,
    /// Which side of the game this market's YES leg pays. Soccer 1X2 legs are explicitly classified as home, draw or away by the provider projection. draw is a real value, not a competitor. Omitted when the provider projection cannot classify the leg, which is not the same as other.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub side: Option<GameMarketSide>,
    /// The provider's label for the YES outcome. Omitted when the provider sent none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome_yes: Option<String>,
    /// The provider's label for the NO outcome. Omitted when the provider sent none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome_no: Option<String>,
    /// Polymarket CLOB token ids in the provider's own outcome-index order. Omitted when the provider has published none for this market.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome_token_ids: Option<Vec<String>>,
    /// Default provider moneyline state. Omitted when this market has no classified moneyline projection; incomplete and invalid projections remain explicit.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prices: Option<GameMarketPrices>,
}

/// How the existing sports-board writer bound prices to competitors.
///
/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GameMarketPriceBindingProvenance {
    /// `provider_ids`
    #[serde(rename = "provider_ids")]
    ProviderIds,
    /// `exact_labels`
    #[serde(rename = "exact_labels")]
    ExactLabels,
    /// `containment_labels`
    #[serde(rename = "containment_labels")]
    ContainmentLabels,
    /// `elimination`
    #[serde(rename = "elimination")]
    Elimination,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl GameMarketPriceBindingProvenance {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::ProviderIds => "provider_ids",
            Self::ExactLabels => "exact_labels",
            Self::ContainmentLabels => "containment_labels",
            Self::Elimination => "elimination",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for GameMarketPriceBindingProvenance {
    fn from(value: &str) -> Self {
        match value {
            "provider_ids" => Self::ProviderIds,
            "exact_labels" => Self::ExactLabels,
            "containment_labels" => Self::ContainmentLabels,
            "elimination" => Self::Elimination,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for GameMarketPriceBindingProvenance {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for GameMarketPriceBindingProvenance {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// One competitor-bound provider moneyline price. No YES/NO inference is required.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameMarketPriceCompetitor {
    /// The provider competitor id when identity is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub provider_id: Option<i64>,
    /// The provider competitor label.
    pub label: String,
    /// Unrounded provider price in [0, 1].
    pub price: f64,
    /// Which provider price observation supplies this leg.
    pub price_provenance: PriceProvenance,
}

/// The provider moneyline pair is incomplete; no numeric pair is invented.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameMarketPriceIncomplete {
    pub state: String,
    pub reason: Reason,
    /// Whether competitor A is the provider YES leg.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub competitor_a_is_yes: Option<bool>,
    /// The provider competitor id when identity is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub competitor_a_provider_id: Option<i64>,
    /// The provider competitor id when identity is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub competitor_b_provider_id: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub binding_provenance: Option<GameMarketPriceBindingProvenance>,
}

/// The provider moneyline pair is invalid; no numeric pair is invented.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameMarketPriceInvalid {
    pub state: String,
    pub reason: GameMarketPriceInvalidReason,
    /// Whether competitor A is the provider YES leg.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub competitor_a_is_yes: Option<bool>,
    /// The provider competitor id when identity is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub competitor_a_provider_id: Option<i64>,
    /// The provider competitor id when identity is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub competitor_b_provider_id: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub binding_provenance: Option<GameMarketPriceBindingProvenance>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GameMarketPriceInvalidReason {
    /// `team_cardinality`
    #[serde(rename = "team_cardinality")]
    TeamCardinality,
    /// `outcome_cardinality`
    #[serde(rename = "outcome_cardinality")]
    OutcomeCardinality,
    /// `price_cardinality`
    #[serde(rename = "price_cardinality")]
    PriceCardinality,
    /// `non_finite_price`
    #[serde(rename = "non_finite_price")]
    NonFinitePrice,
    /// `out_of_range_price`
    #[serde(rename = "out_of_range_price")]
    OutOfRangePrice,
    /// `non_complementary_prices`
    #[serde(rename = "non_complementary_prices")]
    NonComplementaryPrices,
    /// `ambiguous_identity`
    #[serde(rename = "ambiguous_identity")]
    AmbiguousIdentity,
    /// `final_identity_mismatch`
    #[serde(rename = "final_identity_mismatch")]
    FinalIdentityMismatch,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl GameMarketPriceInvalidReason {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::TeamCardinality => "team_cardinality",
            Self::OutcomeCardinality => "outcome_cardinality",
            Self::PriceCardinality => "price_cardinality",
            Self::NonFinitePrice => "non_finite_price",
            Self::OutOfRangePrice => "out_of_range_price",
            Self::NonComplementaryPrices => "non_complementary_prices",
            Self::AmbiguousIdentity => "ambiguous_identity",
            Self::FinalIdentityMismatch => "final_identity_mismatch",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for GameMarketPriceInvalidReason {
    fn from(value: &str) -> Self {
        match value {
            "team_cardinality" => Self::TeamCardinality,
            "outcome_cardinality" => Self::OutcomeCardinality,
            "price_cardinality" => Self::PriceCardinality,
            "non_finite_price" => Self::NonFinitePrice,
            "out_of_range_price" => Self::OutOfRangePrice,
            "non_complementary_prices" => Self::NonComplementaryPrices,
            "ambiguous_identity" => Self::AmbiguousIdentity,
            "final_identity_mismatch" => Self::FinalIdentityMismatch,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for GameMarketPriceInvalidReason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for GameMarketPriceInvalidReason {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A validated provider moneyline pair bound to the two competitors.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameMarketPricePaired {
    pub state: String,
    pub competitor_a: GameMarketPriceCompetitor,
    pub competitor_b: GameMarketPriceCompetitor,
    /// Whether competitor A is the provider YES leg.
    pub competitor_a_is_yes: bool,
    pub binding_provenance: GameMarketPriceBindingProvenance,
}

/// Provider-owned moneyline state with the observation clock that can be compared with game freshness.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameMarketPrices {
    pub provider: GameMarketProviderPrices,
    /// Board cache vintage for Gamma or the older CLOB leg clock. Null when no reliable clock is available; never a Gamma-authored timestamp.
    #[serde(default)]
    pub observed_at: Option<String>,
    /// The clock used for observed_at. board_snapshot is this service’s cache observation, not a provider source timestamp.
    pub observation_source: ObservationSource,
}

/// Discriminated by `state`. A `state` this release does not know is kept whole in
/// `Unknown`, so a new kind never fails a response.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum GameMarketProviderPrices {
    /// `state` is `paired`.
    Paired(GameMarketPricePaired),
    /// `state` is `incomplete`.
    Incomplete(GameMarketPriceIncomplete),
    /// `state` is `invalid`.
    Invalid(GameMarketPriceInvalid),
    /// A `state` this release does not know, kept as sent.
    Unknown(serde_json::Value),
}

impl<'de> Deserialize<'de> for GameMarketProviderPrices {
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = serde_json::Value::deserialize(deserializer)?;
        match value.get("state").and_then(serde_json::Value::as_str) {
            Some("paired") => serde_json::from_value(value)
                .map(Self::Paired)
                .map_err(de::Error::custom),
            Some("incomplete") => serde_json::from_value(value)
                .map(Self::Incomplete)
                .map_err(de::Error::custom),
            Some("invalid") => serde_json::from_value(value)
                .map(Self::Invalid)
                .map_err(de::Error::custom),
            _ => Ok(Self::Unknown(value)),
        }
    }
}

impl Serialize for GameMarketProviderPrices {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        match self {
            Self::Paired(inner) => inner.serialize(serializer),
            Self::Incomplete(inner) => inner.serialize(serializer),
            Self::Invalid(inner) => inner.serialize(serializer),
            Self::Unknown(inner) => inner.serialize(serializer),
        }
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GameMarketSide {
    /// `home`
    #[serde(rename = "home")]
    Home,
    /// `away`
    #[serde(rename = "away")]
    Away,
    /// `draw`
    #[serde(rename = "draw")]
    Draw,
    /// `other`, the documented value; `Other` holds values this release does not know.
    #[serde(rename = "other")]
    OtherValue,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl GameMarketSide {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Home => "home",
            Self::Away => "away",
            Self::Draw => "draw",
            Self::OtherValue => "other",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for GameMarketSide {
    fn from(value: &str) -> Self {
        match value {
            "home" => Self::Home,
            "away" => Self::Away,
            "draw" => Self::Draw,
            "other" => Self::OtherValue,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for GameMarketSide {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for GameMarketSide {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Where the game is in its own life, as the provider reports it. A postponement, a cancellation and a suspension each keep their own state, so a client can tell a game that will be played later from one that never will be.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GameStatus {
    /// scheduled: kickoff is ahead or the provider still calls it scheduled. live: the provider reports it in play. paused: halftime or a provider-reported break. ended: the provider reported a final, an award or a forfeit. postponed, cancelled, suspended, delayed: the provider's own verdict, kept distinct. unknown: no provider state reached this read. A kickoff in the past is never read as live on its own.
    pub state: State,
    /// The provider status folded onto one vocabulary across leagues. unknown means the provider sent a value this API has no meaning for; provider_status keeps that value verbatim. Omitted when no live-score frame carries a status.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub match_status: Option<MatchStatus>,
    /// The provider's status string, verbatim. Omitted when the provider sent none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub provider_status: Option<String>,
    /// The provider's period label, for example Q3, End Q2 or T5. Omitted when the provider sent none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub period: Option<String>,
    /// The game clock as the provider spells it, never reformatted. Omitted when the provider sent none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clock: Option<String>,
    /// Whether the game is in play. It is the provider's own in-play flag, except that a game the provider reports suspended (period SUS) or rescheduled to a later kickoff reads false. Omitted when no live-score frame exists, which is not the same as false.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub live: Option<bool>,
    /// Whether the game is over. Always present.
    pub ended: bool,
}

/// What this deployment covers, published with every page so a client never has to guess whether an empty list means no games or no coverage.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GamesCoverage {
    /// Canonical sport buckets served, sorted.
    pub sports: Vec<String>,
    /// League tags served, sorted. EuroLeague is euroleague under the Basketball sport bucket.
    pub leagues: Vec<String>,
    /// Scopes whose source half was unavailable for this read, as <sport>:<half>. Empty means every scope answered.
    pub sources_unavailable: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetApiDiscoveryResponse {
    pub object: String,
    pub data: ApiDiscovery,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetCoverageResponse {
    pub object: String,
    pub data: Platforms,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetDailyReportSnapshotResponse {
    pub object: String,
    pub data: ReportSnapshot,
    pub meta: ResponseMeta,
}

/// Only trades of at least this USD amount. Decimal and scientific query spellings normalize exactly to cents, rounding half away from zero; maximum 1e15 USD. Pass the dataset continuation decimal string unchanged to preserve the bound. Bound to the cursor.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum GetEventReplaySinceMinSize {
    /// A numeric request value.
    Number(f64),
    /// The exact decimal query spelling, kept unchanged.
    Text(String),
}
impl From<f64> for GetEventReplaySinceMinSize {
    fn from(value: f64) -> Self {
        Self::Number(value)
    }
}
impl From<String> for GetEventReplaySinceMinSize {
    fn from(value: String) -> Self {
        Self::Text(value)
    }
}
impl From<&str> for GetEventReplaySinceMinSize {
    fn from(value: &str) -> Self {
        Self::Text(value.to_owned())
    }
}
impl std::fmt::Display for GetEventReplaySinceMinSize {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Number(value) => value.fmt(f),
            Self::Text(value) => value.fmt(f),
        }
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetEventReplaySinceResponse {
    pub object: String,
    pub data: Vec<EventReplayEvent>,
    pub has_more: bool,
    pub next_cursor: String,
    pub meta: EventReplayMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetGameResponse {
    pub object: String,
    pub data: Game,
    /// When this read assembled the catalog. Per-source vintage is on freshness.
    pub as_of: String,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetHealthResponse {
    pub object: String,
    pub data: GetHealthResponseData,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetHealthResponseData {
    pub status: GetHealthResponseDataStatus,
    pub db: bool,
    pub cache: bool,
    pub subsystems: GetHealthResponseDataSubsystems,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GetHealthResponseDataStatus {
    /// `ok`
    #[serde(rename = "ok")]
    Ok,
    /// `degraded`
    #[serde(rename = "degraded")]
    Degraded,
    /// `down`
    #[serde(rename = "down")]
    Down,
    /// `maintenance`
    #[serde(rename = "maintenance")]
    Maintenance,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl GetHealthResponseDataStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Ok => "ok",
            Self::Degraded => "degraded",
            Self::Down => "down",
            Self::Maintenance => "maintenance",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for GetHealthResponseDataStatus {
    fn from(value: &str) -> Self {
        match value {
            "ok" => Self::Ok,
            "degraded" => Self::Degraded,
            "down" => Self::Down,
            "maintenance" => Self::Maintenance,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for GetHealthResponseDataStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for GetHealthResponseDataStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetHealthResponseDataSubsystems {
    /// Whether the webhook outbox schema validated on this probe. false lowers status to degraded. true during a maintenance window, when nothing is probed.
    pub webhook_compatibility: bool,
    /// Public-safe aggregate status for expected background job successful-completion heartbeats. Does not expose Redis keys, job names, raw errors, provider payloads, wallet addresses, or condition IDs.
    pub background_jobs: GetHealthResponseDataSubsystemsBackgroundJobs,
}

/// Public-safe aggregate status for expected background job successful-completion heartbeats. Does not expose Redis keys, job names, raw errors, provider payloads, wallet addresses, or condition IDs.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetHealthResponseDataSubsystemsBackgroundJobs {
    pub status: GetHealthResponseDataSubsystemsBackgroundJobsStatus,
    pub checked: bool,
    pub total: i64,
    pub healthy: i64,
    pub stale: i64,
    pub missing: i64,
    pub invalid: i64,
    pub unconfigured: i64,
    /// Heavy-periodic jobs that are stale/missing/invalid while the heavy executor is disabled (heavy_pipeline_control.executor_mode != 'active'), so this binary does not dispatch them. Observable but expected; they never drive status to 'down' (paused > 0 yields 'degraded').
    pub paused: i64,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GetHealthResponseDataSubsystemsBackgroundJobsStatus {
    /// `ok`
    #[serde(rename = "ok")]
    Ok,
    /// `degraded`
    #[serde(rename = "degraded")]
    Degraded,
    /// `down`
    #[serde(rename = "down")]
    Down,
    /// `not_checked`
    #[serde(rename = "not_checked")]
    NotChecked,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl GetHealthResponseDataSubsystemsBackgroundJobsStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Ok => "ok",
            Self::Degraded => "degraded",
            Self::Down => "down",
            Self::NotChecked => "not_checked",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for GetHealthResponseDataSubsystemsBackgroundJobsStatus {
    fn from(value: &str) -> Self {
        match value {
            "ok" => Self::Ok,
            "degraded" => Self::Degraded,
            "down" => Self::Down,
            "not_checked" => Self::NotChecked,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for GetHealthResponseDataSubsystemsBackgroundJobsStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for GetHealthResponseDataSubsystemsBackgroundJobsStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetInsiderRadarFlagResponse {
    pub object: String,
    pub data: SuspiciousTrade,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetLargeTradeResponse {
    pub object: String,
    pub data: LargeTradeDetail,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetMarketCandlesResponse {
    pub object: String,
    pub data: MarketCandles,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetMarketFlowResponse {
    pub object: String,
    pub data: MarketFlow,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GetMarketHoldersOutcome {
    /// `yes`
    #[serde(rename = "yes")]
    Yes,
    /// `no`
    #[serde(rename = "no")]
    No,
    /// `all`
    #[serde(rename = "all")]
    All,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl GetMarketHoldersOutcome {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Yes => "yes",
            Self::No => "no",
            Self::All => "all",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for GetMarketHoldersOutcome {
    fn from(value: &str) -> Self {
        match value {
            "yes" => Self::Yes,
            "no" => Self::No,
            "all" => Self::All,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for GetMarketHoldersOutcome {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for GetMarketHoldersOutcome {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetMarketHoldersResponse {
    pub object: String,
    pub data: Vec<MarketHolder>,
    pub has_more: bool,
    /// Absent on the last page.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Holders matching the request's `outcome` and `min_grade` filters across every page.
    pub total: i64,
    pub market: MarketHoldersMarket,
    pub scan: MarketHoldersScan,
    pub totals: MarketHoldersTotals,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetMarketIntelResponse {
    pub object: String,
    pub data: MarketFlow,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetMarketSnapshotResponse {
    pub object: String,
    pub data: MarketSnapshot,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetMonthlyReportSnapshotResponse {
    pub object: String,
    pub data: ReportSnapshot,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetPickOfTheDayArchiveResponse {
    pub object: String,
    pub data: PickOfTheDayArchive,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetPickOfTheDayLedgerEntryResponse {
    pub object: String,
    pub data: PickOfTheDayLedgerEntry,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetPickOfTheDayLedgerResponse {
    pub object: String,
    pub data: PickOfTheDayLedger,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetPickOfTheDayResponse {
    pub object: String,
    pub data: serde_json::Value,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetPlatformsResponse {
    pub object: String,
    pub data: Platforms,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetPositionTimelineByIdResponse {
    pub object: String,
    pub data: Vec<PositionTimelineEvent>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetPositionTimelineResponse {
    pub object: String,
    pub data: Vec<PositionTimelineEvent>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetReportsResponse {
    pub object: String,
    pub data: ReportSnapshot,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetSuspiciousTradeResponse {
    pub object: String,
    pub data: SuspiciousTrade,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetTraderCategoryRecordsResponse {
    pub object: String,
    pub data: TraderCategoryRecords,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetTraderContextResponse {
    pub object: String,
    pub data: TraderContext,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetTraderExportSnapshotResponse {
    pub object: String,
    pub data: TraderExportSnapshot,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetTraderGradeAtResponse {
    pub object: String,
    pub data: TraderGradeAt,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetTraderPnlResponse {
    pub object: String,
    pub data: TraderPnl,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetTraderResponse {
    pub object: String,
    pub data: Trader,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetWebhookResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetWebhookVerificationAttemptResponse {
    pub object: String,
    pub data: WebhookVerificationAttempt,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetWeeklyReportSnapshotResponse {
    pub object: String,
    pub data: ReportSnapshot,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GetWhaleTradeResponse {
    pub object: String,
    pub data: LargeTradeDetail,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Grade {
    /// `S`
    #[serde(rename = "S")]
    S,
    /// `A`
    #[serde(rename = "A")]
    A,
    /// `B`
    #[serde(rename = "B")]
    B,
    /// `C`
    #[serde(rename = "C")]
    C,
    /// `D`
    #[serde(rename = "D")]
    D,
    /// `F`
    #[serde(rename = "F")]
    F,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Grade {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::S => "S",
            Self::A => "A",
            Self::B => "B",
            Self::C => "C",
            Self::D => "D",
            Self::F => "F",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Grade {
    fn from(value: &str) -> Self {
        match value {
            "S" => Self::S,
            "A" => Self::A,
            "B" => Self::B,
            "C" => Self::C,
            "D" => Self::D,
            "F" => Self::F,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Grade {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Grade {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GradeAtTradeStatus {
    /// `graded`
    #[serde(rename = "graded")]
    Graded,
    /// `ungraded`
    #[serde(rename = "ungraded")]
    Ungraded,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl GradeAtTradeStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Graded => "graded",
            Self::Ungraded => "ungraded",
            Self::Unknown => "unknown",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for GradeAtTradeStatus {
    fn from(value: &str) -> Self {
        match value {
            "graded" => Self::Graded,
            "ungraded" => Self::Ungraded,
            "unknown" => Self::Unknown,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for GradeAtTradeStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for GradeAtTradeStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Granularity {
    /// `daily`
    #[serde(rename = "daily")]
    Daily,
    /// `weekly`
    #[serde(rename = "weekly")]
    Weekly,
    /// `monthly`
    #[serde(rename = "monthly")]
    Monthly,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Granularity {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Daily => "daily",
            Self::Weekly => "weekly",
            Self::Monthly => "monthly",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Granularity {
    fn from(value: &str) -> Self {
        match value {
            "daily" => Self::Daily,
            "weekly" => Self::Weekly,
            "monthly" => Self::Monthly,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Granularity {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Granularity {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Current category evidence, independent of the global grade. Pick of the Day stamps only the served display roster; frozen entry snapshots remain unchanged.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct HolderCategoryEvidence {
    pub status: Status,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub canonical_category: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub skill: Option<CategorySkillV2>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum IdentityStatus {
    /// `resolved`
    #[serde(rename = "resolved")]
    Resolved,
    /// `infrastructure`
    #[serde(rename = "infrastructure")]
    Infrastructure,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl IdentityStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Resolved => "resolved",
            Self::Infrastructure => "infrastructure",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for IdentityStatus {
    fn from(value: &str) -> Self {
        match value {
            "resolved" => Self::Resolved,
            "infrastructure" => Self::Infrastructure,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for IdentityStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for IdentityStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Kind {
    /// `sports`
    #[serde(rename = "sports")]
    Sports,
    /// `esports`
    #[serde(rename = "esports")]
    Esports,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Kind {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Sports => "sports",
            Self::Esports => "esports",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Kind {
    fn from(value: &str) -> Self {
        match value {
            "sports" => Self::Sports,
            "esports" => Self::Esports,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Kind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Kind {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeExportPolicy {
    pub mode: String,
    pub current_internal_route: String,
    /// Programmatic API-key-gated export routes (submit/status/download/cancel) and supported formats (json, ndjson, csv).
    pub v1_async: LargeExportPolicyV1Async,
    pub direct_streaming: serde_json::Map<String, serde_json::Value>,
    pub async_job: serde_json::Map<String, serde_json::Value>,
    pub rate_limit: serde_json::Map<String, serde_json::Value>,
}

/// Programmatic API-key-gated export routes (submit/status/download/cancel) and supported formats (json, ndjson, csv).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeExportPolicyV1Async {
    /// POST route template to submit an export job. fresh=true asks for a snapshot read after the submit instead of reusing a finished one.
    pub submit_route: String,
    /// GET route template to poll job status.
    pub status_route: String,
    /// GET route template that 302-redirects to the file.
    pub download_route: String,
    /// POST route template to cancel a queued or running job.
    pub cancel_route: String,
    /// Supported ?format= values.
    pub formats: Vec<Format>,
    /// Possible job status values.
    pub status_values: Vec<TraderExportJobDataStatus>,
    /// How long a finished export is retained before expiry.
    pub retention: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargePosition {
    /// Composite prefixed ID `pos_<wallet>:<condition_id>:<outcome_index>`.
    pub id: String,
    /// Provider discriminator. Always polymarket.
    pub platform: String,
    /// Provider currentValue in USD for the outcome named by outcome_label / token_id, and for that outcome only. An absent key means the provider supplied no value for this leg, not a zero position. combined_value_usd carries the wallet's whole-market total.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total_size_usd: Option<f64>,
    /// Provider unrealized mark-to-market P&L (Polymarket cashPnl) for that same one outcome. An absent key means unavailable, not break-even.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub position_unrealized_pnl: Option<f64>,
    /// The wallet's currentValue across every outcome it holds in this market. Equals total_size_usd unless is_two_sided is true, and is the value the feed ranked this row by.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub combined_value_usd: Option<f64>,
    /// The wallet's unrealized P&L across every outcome it holds in this market. Equals position_unrealized_pnl unless is_two_sided is true.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub combined_unrealized_pnl: Option<f64>,
    /// Whether the wallet holds shares on both outcomes of this market.
    pub is_two_sided: bool,
    /// Every outcome the wallet holds, primary first. holdings[0] restates the top-level per-outcome fields; a further entry is a leg those fields do not describe. No amount here is a share-proportional slice of a both-sides total.
    pub holdings: Vec<LargePositionHoldingsItem>,
    /// Live share count for this position.
    pub share_count: f64,
    /// Volume-weighted entry price.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub avg_entry_price: Option<f64>,
    /// Latest provider mark price for the position's token.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub current_price: Option<f64>,
    /// Backend-resolved outcome label (provider outcome, else Yes/No from the binary index).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome_label: Option<String>,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for this outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Legs collapsed into this representative row for one (wallet, event, outcome side) group. 1 means standalone.
    pub event_leg_count: i64,
    /// Sum of the collapsed sibling legs' own holding values for this (wallet, event) group; equals total_size_usd when event_leg_count = 1, and omitted when any member's value is unknown.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_total_value_usd: Option<f64>,
    pub first_seen_at: String,
    pub last_updated_at: String,
    pub trader: LargePositionTrader,
    pub market: LargePositionMarket,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargePositionHoldingsItem {
    /// 0 = Yes, 1 = No.
    pub outcome_index: i64,
    /// The market's label for this outcome.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome_label: Option<String>,
    /// Polymarket CLOB token id for this outcome; null for an unsynced market.
    #[serde(default)]
    pub token_id: Option<String>,
    /// Shares held on this outcome.
    pub share_count: f64,
    /// Provider average entry price for this outcome.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub avg_entry_price: Option<f64>,
    /// Provider mark price for this outcome.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub current_price: Option<f64>,
    /// Provider currentValue for this outcome. An absent key means unavailable, not zero.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value_usd: Option<f64>,
    /// Provider unrealized P&L for this outcome. An absent key means unavailable, not break-even.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unrealized_pnl: Option<f64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargePositionMarket {
    /// Prefixed ID (`mkt_...`).
    pub id: String,
    pub condition_id: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub slug: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_slug: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargePositionTrader {
    /// Prefixed ID (`trd_...`).
    pub id: String,
    pub address: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grade: Option<Grade>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub win_rate: Option<f64>,
    /// Polymarket's net total P&L for the wallet in USD: native Polymarket position P&L across all markets, fees included, plus credited maker and taker rebates. The 0xinsider profile's Total P&L is this figure unless the wallet has a published correction for neg-risk conversions, which GET /api/v1/trader/{address} serves as pnl.correction; the profile then shows pnl.correction.net_total. Distinct from this position's position_unrealized_pnl. Omitted when the wallet has no native accounting snapshot.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pnl: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub markets_traded: Option<i64>,
}

/// `large_positions_updated` data: one large-positions refresh finished.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargePositionsUpdatedData {
    /// Positions the refresh published.
    pub count: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTrade {
    /// Prefixed ID (wt_...).
    pub id: String,
    pub traded_at: String,
    pub size_usd: f64,
    pub side: LargeTradeInsertedV2DataSide,
    /// Traded outcome label (e.g. "Yes"/"No"/team name), resolved provider-first from the trade's outcome_index against market_canonical (index 0 -> yes, 1 -> no). Distinct axis from side (BUY/SELL): side is the trade direction, outcome is which leg was traded. null for multi-outcome (outcome_index >= 2) or unsynced markets, and for a Polymarket trade recorded before 2026-04-02T00:00:00Z unless its stored outcome_index was verified against the fill's own trade records (before that date the stored index was wrong for a large share of trades; an unverified side is unknown, not defaulted).
    #[serde(default)]
    pub outcome: Option<String>,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the traded outcome; null when unavailable (e.g. unsynced markets) and for a Polymarket trade recorded before 2026-04-02T00:00:00Z whose traded side is not verified (the same rule as outcome).
    #[serde(default)]
    pub token_id: Option<String>,
    pub price: f64,
    /// Current trade review score on a 0..1 scale; higher values indicate a stronger review signal. This is the current response value and can differ from the recorded score. Missing measurements remain unavailable.
    pub review_score: f64,
    /// Deprecated alias of review_score with the same current value and 0..1 scale.
    pub signal_score: f64,
    /// 0.0–1.0 review score written once when the trade row is inserted, from the trader's statistics at that moment. Populated from 2026-08-03T11:59Z; older rows return null and are never backfilled, because a backfill could only read today's statistics. If a trade is added later, its time-sensitive recorded score reflects that delay. Canonical since #16311; recorded_signal_score carries the same value.
    #[serde(default)]
    pub recorded_review_score: Option<f64>,
    /// 0.0–1.0 review score written once when the trade row is inserted; null before 2026-08-03T11:59Z. Deprecated (#16311): `recorded_review_score` is the canonical spelling and carries the same value; this key stays on the wire.
    #[serde(default)]
    pub recorded_signal_score: Option<f64>,
    /// Persisted live suspicion score from the scorer. Null when the row has no persisted score.
    #[serde(default)]
    pub suspicion_score: Option<i64>,
    /// Persisted scorer track. Null when a legacy row has no stored track label.
    #[serde(default)]
    pub suspicion_track: Option<SuspicionTrack>,
    /// This fill's size relative to its market: its share count (size_usd / price) divided by the shares the market has traded, Polymarket's recorded volume, which counts shares rather than dollars, as observed at or after the trade, so the value always falls between 0 and 1 inclusive. A 20,000-share fill is 0.00005 of a market that has traded 400M shares and 0.125 of one that has traded 160,000, which size_usd alone cannot distinguish. Absent when no volume figure recorded at or after the trade is available, or when that figure is smaller than the fill; never 0 as a stand-in and never capped at 1, because a denominator we cannot trust publishes nothing rather than a trimmed number. A market's volume keeps growing, so the same trade reports a smaller share as the market trades on.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub market_volume_share: Option<f64>,
    pub trader: LargeTradeTrader,
    pub market: LargeTradeMarket,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTradeDetail {
    #[serde(flatten)]
    pub large_trade: LargeTrade,
    pub counterparty_analysis: CounterpartyAnalysis,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTradeHistoryMeta {
    /// Unique request ID (req_ prefix). The same value as the X-Request-Id response header, the request's usage accounting row and its log lines.
    pub request_id: String,
    pub cached: bool,
    /// Cache age in seconds; the key is absent when the response was not cached.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cache_age_s: Option<i64>,
    pub source: LargeTradeHistoryMetaSource,
    pub completeness: LargeTradeHistoryMetaCompleteness,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTradeHistoryMetaCompleteness {
    pub status: String,
    /// Explains that local replay completeness can vary by market and time window.
    pub reason: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTradeHistoryMetaSource {
    pub kind: String,
    pub table: String,
    pub provider_fetch_at_request_time: bool,
}

/// `large_trade_inserted_v2` data (Pro and Max): one large trade, with the trade itself. The three amounts are decimal strings that keep the stored precision: parse them with a decimal library when the exact value matters. The endpoint's `trade_filters` decide which trades it receives.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTradeInsertedV2Data {
    /// Stable identity of this trade's event. It equals the envelope `id`, and the `id` of the same event on `GET /api/v1/events/feed/since`.
    pub event_id: String,
    /// Numeric id of the trade. `GET /api/v1/large-trades/{id}` accepts it.
    pub whale_alert_id: i64,
    /// Polymarket condition id of the market.
    pub condition_id: String,
    /// 0xinsider's numeric id for the wallet.
    pub trader_id: i64,
    /// Address of the wallet that made the trade.
    pub wallet: String,
    /// The wallet's grade when the event was published; `null` when it has none.
    #[serde(default)]
    pub grade: Option<Grade>,
    /// USD notional of the trade; decimal string.
    pub size_usd: String,
    /// Shares traded; decimal string.
    pub shares: String,
    /// Price paid per share; decimal string.
    pub price: String,
    pub side: LargeTradeInsertedV2DataSide,
    /// Polymarket's index of the outcome traded.
    pub outcome_index: i64,
    /// When the trade filled on Polymarket. The envelope's `created_at` is this instant.
    pub traded_at: String,
    pub platform: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum LargeTradeInsertedV2DataSide {
    /// `BUY`
    #[serde(rename = "BUY")]
    Buy,
    /// `SELL`
    #[serde(rename = "SELL")]
    Sell,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl LargeTradeInsertedV2DataSide {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Buy => "BUY",
            Self::Sell => "SELL",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for LargeTradeInsertedV2DataSide {
    fn from(value: &str) -> Self {
        match value {
            "BUY" => Self::Buy,
            "SELL" => Self::Sell,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for LargeTradeInsertedV2DataSide {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for LargeTradeInsertedV2DataSide {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTradeMarket {
    pub id: String,
    pub condition_id: String,
    pub title: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub slug: Option<String>,
    /// Provider-backed market_canonical category.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
}

/// All present fields narrow large_trade_inserted_v2 delivery. Grade is observed at publication; ungraded trades do not match min_grade. An empty object matches every large trade.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct LargeTradeSubscriptionFilters {
    /// Raw provider condition ID or mkt_-prefixed market ID.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub condition_id: Option<String>,
    /// Polymarket wallet address; matching is case-insensitive.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub wallet: Option<String>,
    /// S is best; ungraded trades do not match.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub min_grade: Option<Grade>,
    /// Positive USD notional as an exact decimal string.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub min_size_usd: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTradeTrader {
    pub id: String,
    pub address: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    /// The trader's grade today, on every row however old. For what the grade was when the trade happened, read grade_at_trade.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grade: Option<String>,
    /// The grade the trader held when the trade happened, from recorded grade history (recorded from 2026-09-19T23:00Z). Null unless grade_at_trade_status is graded. Never today's grade projected backward.
    #[serde(default)]
    pub grade_at_trade: Option<Grade>,
    /// graded: grade_at_trade holds the recorded grade. ungraded: the trader was recorded without a grade at that moment. unknown: no record covers the moment, which is every trade before 2026-09-19T23:00Z and a trade that fell between a grade change and its confirmation. unknown never means ungraded.
    pub grade_at_trade_status: GradeAtTradeStatus,
}

/// `large_trades_inserted` data (Pro and Max): new large trades were ingested. It carries a count and no trade; subscribe to `large_trade_inserted_v2` for the trade itself. The deprecated spelling `whale_trades_inserted` delivers the same object.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LargeTradesInsertedData {
    /// Large trades the producing batch admitted.
    pub count: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LeaderboardEntry {
    pub id: String,
    pub address: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grade: Option<String>,
    /// Hot-streak tier (trailing-7d cross-sectional percentile); a separate axis from the all-time grade. Omitted when there is no recent activity.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub streak_tier: Option<StreakTier>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub score: Option<f64>,
    /// Polymarket's all-time leaderboard P&L in USD, from Polymarket's latest observation of this wallet on its all-time leaderboard (dated by the leaderboard_pnl data_quality group). Omitted when that leaderboard has no current observation ranking the wallet; 0xinsider requests one, and never serves an older stored figure in its place. Includes unrealized open positions. Kept for back-compat. Not the profile's Total P&L, which GET /api/v1/trader/{address} serves as pnl.net_total; the two can differ by a wide margin. Prefer realized_pnl for the banked figure.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pnl: Option<f64>,
    /// Native realized P&L plus credited maker and taker rebates in USD, with fees already included. The exact numeric value is truncated toward zero to cents before JSON conversion. Omitted when the wallet has no native snapshot or the snapshot has no net realized value; never filled from another P&L basis.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub realized_pnl: Option<f64>,
    /// The 0xinsider correction to Polymarket's P&L for neg-risk conversions. Present only when one is published; realized_pnl keeps Polymarket's own figure and pnl_correction.realized adds the amount to it. The grade and the ranking use the corrected figure. net_total is omitted here.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pnl_correction: Option<PnlCorrection>,
    /// Full-history both-sides USD cash volume from a verified Polymarket user-volume observation. Omitted without coverage.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub volume: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub markets_traded: Option<i64>,
    /// The wallet's win rate across ALL categories, not the filtered one. ?category= decides WHICH wallets are listed (the wallet must be ranked in that category); it does not rescope this field, so a soccer-filtered list still reports each wallet's overall rate. For a per-category record use GET /api/v1/trader/{address}/categories.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub win_rate: Option<f64>,
    /// Observed trading style identifier. New rows use two_sided, category_focused, high_activity, diversified, mixed, or unclassified, counted over the wallet's sports and esports markets only. Historical identifiers remain readable during normal reclassification; style does not predict skill or intent.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub strategy_type: Option<String>,
    /// Provider platform. Always polymarket.
    pub platform: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_active: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListGamesResponse {
    pub object: String,
    pub data: Vec<Game>,
    pub has_more: bool,
    /// Pass as cursor for the next page. Present only when has_more is true.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// When this read assembled the catalog. Per-source vintage is on each game's freshness.
    pub as_of: String,
    pub coverage: GamesCoverage,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListInsiderRadarResponse {
    pub object: String,
    pub data: Vec<SuspiciousTrade>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListLargePositionsResponse {
    pub object: String,
    pub data: Vec<LargePosition>,
    pub has_more: bool,
    /// Opaque cursor for the next page; absent on the last page.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total ranked rows when the read model exposes a count; may be absent.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListLargeTradeCounterpartyExecutionsResponse {
    pub object: String,
    pub data: CounterpartyAnalysis,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListLargeTradeCounterpartyMakersResponse {
    pub object: String,
    pub data: CounterpartyMakerPage,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListLargeTradeHistoryResponse {
    pub object: String,
    pub data: Vec<LargeTrade>,
    /// Writer-backed age and coverage for this page; it is part of the representation and the ETag, while transport cache facts remain in meta.
    pub data_quality: DataQuality,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: LargeTradeHistoryMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListLargeTradesResponse {
    pub object: String,
    pub data: Vec<LargeTrade>,
    /// Writer-backed age and coverage for this page; it is part of the representation and the ETag, while transport cache facts remain in meta.
    pub data_quality: DataQuality,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; absent (or null) when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListLeaderboardResponse {
    pub object: String,
    pub data: Vec<LeaderboardEntry>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListPositionsResponse {
    pub object: String,
    pub data: Vec<Position>,
    /// Writer-backed age and coverage for this page; it is part of the representation and the ETag, while transport cache facts remain in meta.
    pub data_quality: DataQuality,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    /// Present only with consistency=snapshot. Dates the frozen response rows, not the provider's underlying observations.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub snapshot: Option<ListPositionsResponseSnapshot>,
    pub meta: ResponseMeta,
}

/// Present only with consistency=snapshot. Dates the frozen response rows, not the provider's underlying observations.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListPositionsResponseSnapshot {
    pub as_of: String,
    pub expires_at: String,
    pub row_count: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListSharpMoneyFlowsResponse {
    pub object: String,
    pub data: Vec<SmartMoneyFlowMarket>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListSmartMoneyFlowsResponse {
    pub object: String,
    pub data: Vec<SmartMoneyFlowMarket>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListSuspiciousTradesResponse {
    pub object: String,
    pub data: Vec<SuspiciousTrade>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListTrendingWalletsResponse {
    pub object: String,
    pub data: Vec<TrendingWallet>,
    pub has_more: bool,
    /// Opaque cursor for the next page; absent on the last page.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total ranked rows when the read model exposes a count; may be absent.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ListTrendingWalletsWindow {
    /// `7d`
    #[serde(rename = "7d")]
    V7d,
    /// `30d`
    #[serde(rename = "30d")]
    V30d,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ListTrendingWalletsWindow {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::V7d => "7d",
            Self::V30d => "30d",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ListTrendingWalletsWindow {
    fn from(value: &str) -> Self {
        match value {
            "7d" => Self::V7d,
            "30d" => Self::V30d,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ListTrendingWalletsWindow {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ListTrendingWalletsWindow {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListWebhookDeliveriesResponse {
    pub object: String,
    pub data: Vec<WebhookDelivery>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListWebhookEventsResponse {
    pub object: String,
    pub data: Vec<WebhookEventDescriptor>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListWebhooksResponse {
    pub object: String,
    pub data: Vec<WebhookEndpoint>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListWhaleTradeCounterpartyExecutionsResponse {
    pub object: String,
    pub data: CounterpartyAnalysis,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListWhaleTradeCounterpartyMakersResponse {
    pub object: String,
    pub data: CounterpartyMakerPage,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListWhaleTradeHistoryResponse {
    pub object: String,
    pub data: Vec<LargeTrade>,
    /// Writer-backed age and coverage for this page; it is part of the representation and the ETag, while transport cache facts remain in meta.
    pub data_quality: DataQuality,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; absent (or null) when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: LargeTradeHistoryMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ListWhaleTradesResponse {
    pub object: String,
    pub data: Vec<LargeTrade>,
    /// Writer-backed age and coverage for this page; it is part of the representation and the ETag, while transport cache facts remain in meta.
    pub data_quality: DataQuality,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

/// One side's score line inside a `live_sports_updated` pulse.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LiveSportsScoreEntry {
    /// Team name, ordered for the league (away first where the league reads that way).
    pub team: String,
    /// This side's score as the provider sends it.
    pub score: String,
    /// Esports series only: this side's current-map score. Absent on other sports.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub map_score: Option<String>,
}

/// `live_sports_updated` data: one bounded pulse for one live game. A pulse fires when a material field moved since this game's previous delivered pulse (`scores`, `status`, `period`, `live`, `ended`), at most once per game per 20 seconds. A `live` or `ended` transition is exempt from that interval, and the game clock alone never fires a pulse. Suppressed frames are folded into the next pulse's `changed`, and its body carries the current state.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LiveSportsUpdatedData {
    /// The Polymarket event slug this game trades under.
    pub event_slug: String,
    /// Provider game id, or `null` when the frame carried none.
    #[serde(default)]
    pub game_id: Option<String>,
    /// League abbreviation, or `null`.
    #[serde(default)]
    pub league: Option<String>,
    /// Durable per-game pulse ordinal, increasing by one per delivered pulse. Deliveries are not ordered, so drop a pulse whose version you already saw.
    pub version: i64,
    /// Material fields that moved since this game's previous delivered pulse.
    pub changed: Vec<Changed>,
    /// Provider frame time, or `null` when the frame carried none. Never replaced with a local clock.
    #[serde(default)]
    pub observed_at: Option<String>,
    /// When the pulse was admitted.
    pub published_at: String,
    /// Provider status text, or `null`.
    #[serde(default)]
    pub status: Option<String>,
    /// Provider period text ("Q3", "Map 2/3"), or `null`.
    #[serde(default)]
    pub period: Option<String>,
    /// Game clock, or `null`. Not a material field: it never fires a pulse on its own.
    #[serde(default)]
    pub clock: Option<String>,
    /// Provider live flag, or `null` when the frame carried none.
    #[serde(default)]
    pub live: Option<bool>,
    /// Whether the provider has marked this game final.
    pub ended: bool,
    /// Per-side scores, one line per team.
    pub scores: Vec<LiveSportsScoreEntry>,
    /// Esports `BoN` series token, or `null` on every other sport.
    #[serde(default)]
    pub series_format: Option<String>,
    /// Public game page. Re-read it after a gap instead of replaying pulses.
    pub snapshot_url: String,
}

/// Provider-first bucketed OHLC price candles for a market's outcome tokens, derived from our stored copy of the Polymarket CLOB prices-history series (covers open and resolved markets).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketCandles {
    /// Market condition id the candles were read for.
    pub condition_id: String,
    /// Bucketing granularity that produced these candles.
    pub resolution: Resolution,
    /// One entry per present provider token (YES first, then NO); empty when no tokens have been fetched yet.
    pub outcomes: Vec<OutcomeCandles>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketFlow {
    pub market: MarketFlowMarket,
    /// Outcome-aware flow from all tracked whale trades in the window, without a grade filter. BUY YES and SELL NO add net exposure; BUY NO and SELL YES subtract it. Gross buy/sell volumes count both outcomes. Top positions are separately graded. Direction uses unrounded net: negative is NO, otherwise YES; the zero tie-break is not conviction. Canonical; smart_money is a deprecated byte-identical alias.
    pub sharp_money: MarketFlowSharpMoney,
    /// Deprecated alias of sharp_money; byte-identical and retained for backward compatibility.
    pub smart_money: MarketFlowSmartMoney,
    pub timeframe: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketFlowMarket {
    pub id: String,
    pub condition_id: String,
    pub title: String,
    #[serde(default)]
    pub slug: Option<String>,
    #[serde(default)]
    pub category: Option<String>,
    /// Provider platform. Always polymarket, or null when the row carries no stored value.
    #[serde(default)]
    pub platform: Option<String>,
}

/// Outcome-aware flow from all tracked whale trades in the window, without a grade filter. BUY YES and SELL NO add net exposure; BUY NO and SELL YES subtract it. Gross buy/sell volumes count both outcomes. Top positions are separately graded. Direction uses unrounded net: negative is NO, otherwise YES; the zero tie-break is not conviction. Canonical; smart_money is a deprecated byte-identical alias.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketFlowSharpMoney {
    pub net_flow_usd: f64,
    pub direction: Direction,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the net-flow direction outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value.
    pub large_trade_count: i64,
    pub whale_trade_count: i64,
    pub buy_volume_usd: f64,
    pub sell_volume_usd: f64,
    pub top_positions: Vec<MarketFlowSharpMoneyTopPositionsItem>,
    /// Age of the oldest stored position snapshot behind top_positions: the minimum wallet sync clock over the positions this body publishes. The roster is a stored read rather than a live one, and graded wallets sit on different sync tiers, so this names how current the whole roster is; the response is no fresher than this timestamp. Null when the roster is empty or no published position carries a sync clock. It does not date net_flow_usd, the volumes or the trade counts, which come from large-trade event times.
    #[serde(default)]
    pub oldest_snapshot_as_of: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketFlowSharpMoneyTopPositionsItem {
    pub id: String,
    pub address: String,
    #[serde(default)]
    pub username: Option<String>,
    #[serde(default)]
    pub grade: Option<String>,
    pub side: Direction,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for this outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    pub size_usd: f64,
}

/// Deprecated alias of sharp_money; byte-identical and retained for backward compatibility.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketFlowSmartMoney {
    pub net_flow_usd: f64,
    pub direction: Direction,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the net-flow direction outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value.
    pub large_trade_count: i64,
    pub whale_trade_count: i64,
    pub buy_volume_usd: f64,
    pub sell_volume_usd: f64,
    pub top_positions: Vec<MarketFlowSmartMoneyTopPositionsItem>,
    /// Age of the oldest stored position snapshot behind top_positions: the minimum wallet sync clock over the positions this body publishes. The roster is a stored read rather than a live one, and graded wallets sit on different sync tiers, so this names how current the whole roster is; the response is no fresher than this timestamp. Null when the roster is empty or no published position carries a sync clock. It does not date net_flow_usd, the volumes or the trade counts, which come from large-trade event times.
    #[serde(default)]
    pub oldest_snapshot_as_of: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketFlowSmartMoneyTopPositionsItem {
    pub id: String,
    pub address: String,
    #[serde(default)]
    pub username: Option<String>,
    #[serde(default)]
    pub grade: Option<String>,
    pub side: Direction,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for this outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    pub size_usd: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketHolder {
    /// Composite `pos_<wallet>:<condition_id>:<outcome_index>`, the same id `GET /api/v1/positions` gives this leg.
    pub id: String,
    /// `trd_`-prefixed trader id, accepted by `GET /api/v1/trader/{address}`.
    pub trader_id: String,
    /// Lowercased proxy wallet.
    pub address: String,
    /// Polymarket's public display name from the same holder snapshot; null for a private wallet, which the provider redacts at the source.
    #[serde(default)]
    pub name: Option<String>,
    /// The outcome this wallet nets to. A wallet holding both outcomes is listed once, on its net side; see `other_outcome_shares`.
    pub side: Direction,
    /// Polymarket CLOB token id (ERC1155 asset id, decimal string) for `side`; null when the market has no stored token id.
    #[serde(default)]
    pub token_id: Option<String>,
    /// All-time trader grade. This route lists the S/A/B cohort only, the same cohort a Pick of the Day roster lists.
    #[serde(default)]
    pub grade: Option<MarketHolderGrade>,
    /// Shares held on `side`, from the complete provider scan.
    pub shares: f64,
    /// Polymarket's own currentValue for this leg, in USD. Null when the snapshot predates the value map.
    #[serde(default)]
    pub current_value_usd: Option<f64>,
    /// Shares on the other outcome when the wallet holds both. Absent when the wallet is one-sided.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub other_outcome_shares: Option<f64>,
    /// The wallet's last recorded trade anywhere, null when unknown.
    #[serde(default)]
    pub last_traded_at: Option<String>,
    /// This wallet's win rate in the market's canonical category (`market.category`): the share of its resolved markets in that category whose realized P&L closed positive, as a 0..1 fraction. Present only with `category_win_rate_status` = `measured`. The same read `GET /api/v1/trader/{address}/categories` serves per wallet.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_win_rate: Option<f64>,
    /// The two counts `category_win_rate` is the ratio of, from the same row: `wins / decided` equals the rate. Every resolved Polymarket market the wallet traded in the market's canonical category, at any position size, rebuilt daily. Present only with `category_win_rate_status` = `measured`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_win_record: Option<MarketHolderCategoryWinRecord>,
    /// The wallet's average entry price in the market's canonical category, as a 0..1 fraction of $1 (0.98 is 98 cents). Its sample is the wallet's settled markets in that category of $20 or more where it bought one side at a known price, so it can differ from the `category_win_record` sample. A wallet that buys near-certain outcomes wins almost every time, so read the win rate beside this price. Present only with `category_win_rate_status` = `measured`, and only when that sample has at least 5 markets. When `category_win_rate_game` is present the price is still the `Esports` category's: there is no per-game price. Absent otherwise and on payloads predating the field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_avg_price: Option<f64>,
    /// For an esports market, the game `category_win_rate` and `category_win_record` were measured in: `LoL`, `CS2`, `Dota 2`, `Valorant`, `Call of Duty`, `Honor of Kings`, `Mobile Legends: Bang Bang`, `Overwatch`, `Rainbow Six Siege`, `Rocket League` or `StarCraft II`. Present only when the wallet's record in that game clears the 5-resolved-market floor, in which case the rate and record are the game's rather than the `Esports` bucket's. Absent when the rate is the bucket's (the wallet's game history is under the floor), on every non-esports market, and beside every non-measured status. Label the rate with this when present and with the market's `category` otherwise.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_win_rate_game: Option<String>,
    /// Why `category_win_rate` is present or absent: `measured` (rate present), `not_enough_data` (under the floor of 5 decided markets in the category), or `unavailable` (the market has no canonical category, or the read failed; retry later). Always present on this route.
    pub category_win_rate_status: CategoryWinRateStatus,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_evidence: Option<HolderCategoryEvidence>,
    /// Days since this wallet's first trade. The five badge fields are present together, only for a wallet that draws at least one badge.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub wallet_age_days: Option<f64>,
    /// True when the wallet's first trade was under 30 days ago.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub is_new_wallet: Option<bool>,
    /// Distinct markets the wallet has traded.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub markets_traded: Option<i64>,
    /// True when the wallet is flagged as automated.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub is_bot: Option<bool>,
    /// The wallet's X handle without the @, when linked.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub x_username: Option<String>,
}

/// The two counts `category_win_rate` is the ratio of, from the same row: `wins / decided` equals the rate. Every resolved Polymarket market the wallet traded in the market's canonical category, at any position size, rebuilt daily. Present only with `category_win_rate_status` = `measured`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketHolderCategoryWinRecord {
    /// Resolved markets in the category that this wallet closed with a profit.
    pub wins: i64,
    /// Resolved markets in the category that this wallet closed with a profit or a loss. A market resolved at zero realized P&L is in neither count.
    pub decided: i64,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum MarketHolderGrade {
    /// `S`
    #[serde(rename = "S")]
    S,
    /// `A`
    #[serde(rename = "A")]
    A,
    /// `B`
    #[serde(rename = "B")]
    B,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl MarketHolderGrade {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::S => "S",
            Self::A => "A",
            Self::B => "B",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for MarketHolderGrade {
    fn from(value: &str) -> Self {
        match value {
            "S" => Self::S,
            "A" => Self::A,
            "B" => Self::B,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for MarketHolderGrade {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for MarketHolderGrade {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketHoldersMarket {
    /// `mkt_`-prefixed market id.
    pub id: String,
    pub condition_id: String,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub slug: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_slug: Option<String>,
    /// The canonical category bucket `category_win_rate` is measured in.
    #[serde(default)]
    pub category: Option<String>,
    #[serde(default)]
    pub outcome_yes: Option<String>,
    #[serde(default)]
    pub outcome_no: Option<String>,
    #[serde(default)]
    pub token_id_yes: Option<String>,
    #[serde(default)]
    pub token_id_no: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub end_date: Option<String>,
    /// A settled market's roster is whatever the provider still lists as open; it empties as holders redeem.
    pub status: MarketHoldersMarketStatus,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum MarketHoldersMarketStatus {
    /// `open`
    #[serde(rename = "open")]
    Open,
    /// `closed`
    #[serde(rename = "closed")]
    Closed,
    /// `resolved`
    #[serde(rename = "resolved")]
    Resolved,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl MarketHoldersMarketStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Open => "open",
            Self::Closed => "closed",
            Self::Resolved => "resolved",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for MarketHoldersMarketStatus {
    fn from(value: &str) -> Self {
        match value {
            "open" => Self::Open,
            "closed" => Self::Closed,
            "resolved" => Self::Resolved,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for MarketHoldersMarketStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for MarketHoldersMarketStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketHoldersScan {
    /// `cached`: the shared holder snapshot, at most 180 s old at compute time. `live`: the provider answered a fresh complete walk for this compute.
    pub source: ProviderReadSource,
    /// Always true on a served roster. An incomplete or unstable scan is a 503, never a partial list.
    pub complete: bool,
    /// When the provider walk that produced the holder population finished.
    #[serde(default)]
    pub fetched_at: Option<String>,
    /// Every distinct wallet the complete walk saw with open shares, graded or not. The roster lists the graded S/A/B subset.
    pub wallet_count: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketHoldersSideGrades {
    pub s: i64,
    pub a: i64,
    pub b: i64,
}

/// Roster totals BEFORE any `outcome` or `min_grade` filter, so a page always knows the whole market it was cut from.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketHoldersTotals {
    /// Distinct graded wallets with net exposure; a two-sided wallet counts once.
    pub graded_count: i64,
    pub yes_count: i64,
    pub no_count: i64,
    pub yes_shares: f64,
    pub no_shares: f64,
    /// Polymarket currentValue summed over the graded wallets netting YES.
    pub yes_usd: f64,
    /// Polymarket currentValue summed over the graded wallets netting NO.
    pub no_usd: f64,
    pub yes_grades: MarketHoldersSideGrades,
    pub no_grades: MarketHoldersSideGrades,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum MarketScope {
    /// `all_markets`
    #[serde(rename = "all_markets")]
    AllMarkets,
    /// `sports_and_esports`
    #[serde(rename = "sports_and_esports")]
    SportsAndEsports,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl MarketScope {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::AllMarkets => "all_markets",
            Self::SportsAndEsports => "sports_and_esports",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for MarketScope {
    fn from(value: &str) -> Self {
        match value {
            "all_markets" => Self::AllMarkets,
            "sports_and_esports" => Self::SportsAndEsports,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for MarketScope {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for MarketScope {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSearchResult {
    pub id: String,
    pub condition_id: String,
    pub title: String,
    #[serde(default)]
    pub slug: Option<String>,
    #[serde(default)]
    pub category: Option<String>,
    /// Provider platform. Always polymarket, or null when the row carries no stored value.
    #[serde(default)]
    pub platform: Option<String>,
    /// closed once Polymarket has closed trading or the market has resolved; active otherwise. The same rule labels a market on markets/search, markets/explore and market/{condition_id}/snapshot.
    pub status: MarketSearchResultStatus,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum MarketSearchResultStatus {
    /// `active`
    #[serde(rename = "active")]
    Active,
    /// `closed`
    #[serde(rename = "closed")]
    Closed,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl MarketSearchResultStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Closed => "closed",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for MarketSearchResultStatus {
    fn from(value: &str) -> Self {
        match value {
            "active" => Self::Active,
            "closed" => Self::Closed,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for MarketSearchResultStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for MarketSearchResultStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshot {
    pub market: MarketSnapshotMarket,
    pub outcomes: Vec<MarketSnapshotOutcomesItem>,
    pub liquidity: MarketSnapshotLiquidity,
    pub sports: MarketSnapshotSports,
    pub freshness: MarketSnapshotFreshnessBySource,
    /// Price and spread trust metadata. Present only when expand=trust or expand[]=trust is requested.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub trust: Option<MarketSnapshotTrust>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotFreshness {
    pub status: MarketSnapshotFreshnessStatus,
    pub source: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub as_of: Option<String>,
    /// Age-relative freshness bound when known. Omitted for live_sports: its as_of records compute start, while its two-second freshness marker starts at publication.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub stale_after_s: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotFreshnessBySource {
    pub market_data: MarketSnapshotFreshness,
    pub top_of_book: MarketSnapshotFreshness,
    /// Freshness requires the dedicated two-second post-publication marker to match the retained vintage and non-invalidated data timestamp; timestamp presence alone is insufficient. as_of records compute start, so stale_after_s is omitted rather than implying as_of plus two seconds. Missing membership is not_live only in a fresh source; stale membership remains stale and unreadable source data is unavailable. Repeated lookups reuse the shared payload and typed index for an unchanged generation.
    pub live_sports: MarketSnapshotFreshness,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum MarketSnapshotFreshnessStatus {
    /// `fresh`
    #[serde(rename = "fresh")]
    Fresh,
    /// `stale`
    #[serde(rename = "stale")]
    Stale,
    /// `available`
    #[serde(rename = "available")]
    Available,
    /// `not_live`
    #[serde(rename = "not_live")]
    NotLive,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl MarketSnapshotFreshnessStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Fresh => "fresh",
            Self::Stale => "stale",
            Self::Available => "available",
            Self::NotLive => "not_live",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for MarketSnapshotFreshnessStatus {
    fn from(value: &str) -> Self {
        match value {
            "fresh" => Self::Fresh,
            "stale" => Self::Stale,
            "available" => Self::Available,
            "not_live" => Self::NotLive,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for MarketSnapshotFreshnessStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for MarketSnapshotFreshnessStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotLiquidity {
    pub source: String,
    /// Polymarket's traded-volume figure for the market, as last stored: cumulative taker volume in shares, each counted at its $1 settlement value, not the cash that changed hands (100 shares bought at $0.40 add 100, not 40). It can lag Polymarket's current figure. The name ends in _usd because Polymarket prints this figure with a dollar sign; it is a share count. Null when unavailable.
    #[serde(default)]
    pub volume_usd: Option<f64>,
    #[serde(default)]
    pub liquidity_usd: Option<f64>,
    /// Polymarket's taker volume over the 24 hours before volume_24h_as_of, in shares, each counted at its $1 settlement value, not the cash that changed hands (100 shares bought at $0.40 add 100, not 40). The name ends in _usd because Polymarket prints volume with a dollar sign; it is a share count. Null when Polymarket does not report one: it omits the figure on closed markets and on open markets with no trades in the last 24 hours.
    #[serde(default)]
    pub volume_24h_usd: Option<f64>,
    /// When 0xinsider read volume_24h_usd from Polymarket; the figure covers the 24 hours before this time. Null exactly when volume_24h_usd is null.
    #[serde(default)]
    pub volume_24h_as_of: Option<String>,
    /// Always null. Polymarket snapshot prices come from outcome top-of-book midpoints.
    #[serde(default)]
    pub last_price: Option<f64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotMarket {
    pub id: String,
    pub condition_id: String,
    pub provider: String,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub slug: Option<String>,
    #[serde(default)]
    pub page_slug: Option<String>,
    #[serde(default)]
    pub event_slug: Option<String>,
    #[serde(default)]
    pub category: Option<String>,
    /// closed once Polymarket has closed trading or the market has resolved; active otherwise. The same rule labels a market on markets/search, markets/explore and market/{condition_id}/snapshot.
    pub status: MarketSearchResultStatus,
    #[serde(default)]
    pub description: Option<String>,
    #[serde(default)]
    pub image: Option<String>,
    /// Polymarket series slug from the canonical identity row, null when unavailable. A sports series identifies a league and must not be used as a per-matchup grouping key.
    #[serde(default)]
    pub series_slug: Option<String>,
    /// Always null. Deprecated (#24169): 0xinsider has never stored a value for this field. The key stays on the wire so existing clients keep parsing; do not read it.
    #[serde(default)]
    pub market_type: Option<String>,
    /// Always null. Deprecated (#24169): 0xinsider stores no value for this field on a Polymarket market. The key stays on the wire so existing clients keep parsing; do not read it. market.status and market.resolved_at say whether the market has closed or resolved.
    #[serde(default)]
    pub market_result: Option<String>,
    #[serde(default)]
    pub created_at: Option<String>,
    #[serde(default)]
    pub end_date: Option<String>,
    #[serde(default)]
    pub resolved_at: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotOutcomesItem {
    pub side: Side,
    pub label: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub token_id: Option<String>,
    /// The outcome's display price, the probability Polymarket shows for it: the midpoint of the cached top of book when the spread is at most 0.10, otherwise the token's last trade price. Omitted when neither is known, including a book wider than 0.10 with no last trade on record; top_of_book still carries that book's best_bid and best_ask. expand=trust explains a missing value in trust.current_price.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub current_price: Option<f64>,
    pub top_of_book: MarketSnapshotTopOfBook,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotSports {
    pub status: MarketSnapshotSportsStatus,
    pub source: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub live_match_key: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub live_league_key: Option<String>,
    /// Live-score period and elapsed may be omitted when unavailable (older responses use null). A score entry may omit full_name when it equals team; fall back to team. Distinct aliases and score admission markers are preserved. For live esports, scores[].map_score retains an available pair through an update omitting both sides only within the same live map, series format and series totals. Map changes and final state follow current provider updates; absent detail remains unavailable. Optional tennis_points supplies independently sourced current-game points and serving side; absence means unavailable. Compatible unexpired tennis_points survives temporary supplemental snapshot unavailability or contention; expiry and set/game mismatch still clear it.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub live_score: Option<MarketSnapshotSportsLiveScore>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
}

/// Live-score period and elapsed may be omitted when unavailable (older responses use null). A score entry may omit full_name when it equals team; fall back to team. Distinct aliases and score admission markers are preserved. For live esports, scores[].map_score retains an available pair through an update omitting both sides only within the same live map, series format and series totals. Map changes and final state follow current provider updates; absent detail remains unavailable. Optional tennis_points supplies independently sourced current-game points and serving side; absence means unavailable. Compatible unexpired tennis_points survives temporary supplemental snapshot unavailability or contention; expiry and set/game mismatch still clear it.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotSportsLiveScore {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tennis_points: Option<TennisPoints>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum MarketSnapshotSportsStatus {
    /// `fresh`
    #[serde(rename = "fresh")]
    Fresh,
    /// `stale`
    #[serde(rename = "stale")]
    Stale,
    /// `not_live`
    #[serde(rename = "not_live")]
    NotLive,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl MarketSnapshotSportsStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Fresh => "fresh",
            Self::Stale => "stale",
            Self::NotLive => "not_live",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for MarketSnapshotSportsStatus {
    fn from(value: &str) -> Self {
        match value {
            "fresh" => Self::Fresh,
            "stale" => Self::Stale,
            "not_live" => Self::NotLive,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for MarketSnapshotSportsStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for MarketSnapshotSportsStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotTopOfBook {
    pub status: EnrichmentStatus,
    pub source: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub best_bid: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub best_ask: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub spread_bps: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub bid_depth_usdc: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ask_depth_usdc: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
}

/// Price and spread trust metadata returned only when GET /api/v1/market/{condition_id}/snapshot includes expand=trust.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MarketSnapshotTrust {
    pub current_price: TrustMetadata,
    pub spread_bps: TrustMetadata,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum MatchStatus {
    /// `scheduled`
    #[serde(rename = "scheduled")]
    Scheduled,
    /// `in_progress`
    #[serde(rename = "in_progress")]
    InProgress,
    /// `halftime`
    #[serde(rename = "halftime")]
    Halftime,
    /// `penalty_shootout`
    #[serde(rename = "penalty_shootout")]
    PenaltyShootout,
    /// `delayed`
    #[serde(rename = "delayed")]
    Delayed,
    /// `suspended`
    #[serde(rename = "suspended")]
    Suspended,
    /// `final`
    #[serde(rename = "final")]
    Final,
    /// `final_overtime`
    #[serde(rename = "final_overtime")]
    FinalOvertime,
    /// `final_shootout`
    #[serde(rename = "final_shootout")]
    FinalShootout,
    /// `awarded`
    #[serde(rename = "awarded")]
    Awarded,
    /// `forfeit`
    #[serde(rename = "forfeit")]
    Forfeit,
    /// `not_necessary`
    #[serde(rename = "not_necessary")]
    NotNecessary,
    /// `postponed`
    #[serde(rename = "postponed")]
    Postponed,
    /// `cancelled`
    #[serde(rename = "cancelled")]
    Cancelled,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl MatchStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Scheduled => "scheduled",
            Self::InProgress => "in_progress",
            Self::Halftime => "halftime",
            Self::PenaltyShootout => "penalty_shootout",
            Self::Delayed => "delayed",
            Self::Suspended => "suspended",
            Self::Final => "final",
            Self::FinalOvertime => "final_overtime",
            Self::FinalShootout => "final_shootout",
            Self::Awarded => "awarded",
            Self::Forfeit => "forfeit",
            Self::NotNecessary => "not_necessary",
            Self::Postponed => "postponed",
            Self::Cancelled => "cancelled",
            Self::Unknown => "unknown",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for MatchStatus {
    fn from(value: &str) -> Self {
        match value {
            "scheduled" => Self::Scheduled,
            "in_progress" => Self::InProgress,
            "halftime" => Self::Halftime,
            "penalty_shootout" => Self::PenaltyShootout,
            "delayed" => Self::Delayed,
            "suspended" => Self::Suspended,
            "final" => Self::Final,
            "final_overtime" => Self::FinalOvertime,
            "final_shootout" => Self::FinalShootout,
            "awarded" => Self::Awarded,
            "forfeit" => Self::Forfeit,
            "not_necessary" => Self::NotNecessary,
            "postponed" => Self::Postponed,
            "cancelled" => Self::Cancelled,
            "unknown" => Self::Unknown,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for MatchStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for MatchStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum MatchType {
    /// `COMPLEMENTARY`
    #[serde(rename = "COMPLEMENTARY")]
    Complementary,
    /// `MINT`
    #[serde(rename = "MINT")]
    Mint,
    /// `MERGE`
    #[serde(rename = "MERGE")]
    Merge,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl MatchType {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Complementary => "COMPLEMENTARY",
            Self::Mint => "MINT",
            Self::Merge => "MERGE",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for MatchType {
    fn from(value: &str) -> Self {
        match value {
            "COMPLEMENTARY" => Self::Complementary,
            "MINT" => Self::Mint,
            "MERGE" => Self::Merge,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for MatchType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for MatchType {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct McpJsonRpcError {
    pub jsonrpc: String,
    #[serde(default)]
    pub id: Option<serde_json::Value>,
    pub error: McpJsonRpcErrorError,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct McpJsonRpcErrorError {
    pub code: i64,
    pub message: String,
    /// Optional JSON-serializable error data.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub data: Option<serde_json::Value>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum McpMethod {
    /// `initialize`
    #[serde(rename = "initialize")]
    Initialize,
    /// `notifications/initialized`
    #[serde(rename = "notifications/initialized")]
    NotificationsInitialized,
    /// `notifications/cancelled`
    #[serde(rename = "notifications/cancelled")]
    NotificationsCancelled,
    /// `ping`
    #[serde(rename = "ping")]
    Ping,
    /// `tools/list`
    #[serde(rename = "tools/list")]
    ToolsList,
    /// `tools/call`
    #[serde(rename = "tools/call")]
    ToolsCall,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl McpMethod {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Initialize => "initialize",
            Self::NotificationsInitialized => "notifications/initialized",
            Self::NotificationsCancelled => "notifications/cancelled",
            Self::Ping => "ping",
            Self::ToolsList => "tools/list",
            Self::ToolsCall => "tools/call",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for McpMethod {
    fn from(value: &str) -> Self {
        match value {
            "initialize" => Self::Initialize,
            "notifications/initialized" => Self::NotificationsInitialized,
            "notifications/cancelled" => Self::NotificationsCancelled,
            "ping" => Self::Ping,
            "tools/list" => Self::ToolsList,
            "tools/call" => Self::ToolsCall,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for McpMethod {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for McpMethod {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Mode {
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `stable`
    #[serde(rename = "stable")]
    Stable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Mode {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Live => "live",
            Self::Stable => "stable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Mode {
    fn from(value: &str) -> Self {
        match value {
            "live" => Self::Live,
            "stable" => Self::Stable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Mode {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Mode {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum NextAction {
    /// `poll`
    #[serde(rename = "poll")]
    Poll,
    /// `download`
    #[serde(rename = "download")]
    Download,
    /// `resubmit`
    #[serde(rename = "resubmit")]
    Resubmit,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl NextAction {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Poll => "poll",
            Self::Download => "download",
            Self::Resubmit => "resubmit",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for NextAction {
    fn from(value: &str) -> Self {
        match value {
            "poll" => Self::Poll,
            "download" => Self::Download,
            "resubmit" => Self::Resubmit,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for NextAction {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for NextAction {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ObservationSource {
    /// `board_snapshot`
    #[serde(rename = "board_snapshot")]
    BoardSnapshot,
    /// `clob_display`
    #[serde(rename = "clob_display")]
    ClobDisplay,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ObservationSource {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::BoardSnapshot => "board_snapshot",
            Self::ClobDisplay => "clob_display",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ObservationSource {
    fn from(value: &str) -> Self {
        match value {
            "board_snapshot" => Self::BoardSnapshot,
            "clob_display" => Self::ClobDisplay,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ObservationSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ObservationSource {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Outcome {
    /// `pending`
    #[serde(rename = "pending")]
    Pending,
    /// `win`
    #[serde(rename = "win")]
    Win,
    /// `loss`
    #[serde(rename = "loss")]
    Loss,
    /// `void`
    #[serde(rename = "void")]
    Void,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Outcome {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Pending => "pending",
            Self::Win => "win",
            Self::Loss => "loss",
            Self::Void => "void",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Outcome {
    fn from(value: &str) -> Self {
        match value {
            "pending" => Self::Pending,
            "win" => Self::Win,
            "loss" => Self::Loss,
            "void" => Self::Void,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Outcome {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Outcome {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// One outcome token's bucketed candle series.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct OutcomeCandles {
    /// Provider CLOB token id the candles were read for.
    pub token_id: String,
    /// Canonical side label.
    pub outcome: Direction,
    /// OHLC candles for this outcome token, ascending by bucket start.
    pub candles: Vec<Candle>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PaidDataAccess {
    /// `active`
    #[serde(rename = "active")]
    Active,
    /// `lapsed`
    #[serde(rename = "lapsed")]
    Lapsed,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl PaidDataAccess {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Lapsed => "lapsed",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for PaidDataAccess {
    fn from(value: &str) -> Self {
        match value {
            "active" => Self::Active,
            "lapsed" => Self::Lapsed,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for PaidDataAccess {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for PaidDataAccess {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickHolder {
    pub address: String,
    #[serde(default)]
    pub name: Option<String>,
    /// All-time trader grade (S, A, B, C, D, F).
    #[serde(default)]
    pub grade: Option<String>,
    /// The wallet's most recent recorded trade time, stamped at serve time from its current trader record rather than frozen with the pick. Always sent; null when no trade time is recorded.
    #[serde(default)]
    pub last_traded_at: Option<String>,
    /// 0xinsider profile path segment this wallet links to: `@<username>` when that username resolves to this wallet alone, otherwise the lowercase wallet. Percent-encode the part after `@` and append to `https://0xinsider.com/profile/`. Stamped at serve time; absent on a body cached before the field shipped.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub profile_segment: Option<String>,
    pub shares: f64,
    /// USD entry value of this wallet's position: `shares` times the pick's frozen `backed_price`. An entry valuation, never a live balance or the provider's current value. Omitted when the holder snapshot has no valid price.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub entry_value_usd: Option<f64>,
    /// This wallet's win rate in the pick's canonical category bucket (the pick's `category` field, e.g. Basketball -- label the rate with it, never with the narrower `display_category` league, except when `category_win_rate_game` is present, in which case the rate is that game's and is labelled with it): the share of the wallet's resolved markets in that category whose realized P&L closed positive, as a 0..1 fraction. Present only with `category_win_rate_status` = `measured`, on `display_holders` entries, and only when the wallet clears the resolved-market floor; recomputed at serve time from the current category read model, not frozen with the pick. Absent on `holders` entries, legacy rows, and payloads predating the field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_win_rate: Option<f64>,
    /// The two counts `category_win_rate` is the ratio of, read from the same row: `wins / decided` equals the rate. Counts every resolved Polymarket market the wallet traded in the pick's canonical category (or in its game, when `category_win_rate_game` is present), at any position size; the counts are rebuilt daily. Present only with `category_win_rate_status` = `measured`; absent otherwise and on payloads predating the field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_win_record: Option<PickHolderCategoryWinRecord>,
    /// The wallet's average entry price in the pick's canonical category, as a 0..1 fraction of $1 (0.98 is 98 cents). Its sample is the wallet's settled markets in that category of $20 or more where it bought one side at a known price, so it can differ from the `category_win_record` sample. A wallet that buys near-certain outcomes wins almost every time, so read the win rate beside this price. Present only with `category_win_rate_status` = `measured`, and only when that sample has at least 5 markets. When `category_win_rate_game` is present the price is still the `Esports` category's: there is no per-game price. Absent otherwise and on payloads predating the field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_avg_price: Option<f64>,
    /// For an esports pick, the game `category_win_rate` and `category_win_record` were measured in, by the same name the pick's `display_category` uses for it: `LoL`, `CS2`, `Dota 2`, `Valorant`, `Call of Duty`, `Honor of Kings`, `Mobile Legends: Bang Bang`, `Overwatch`, `Rainbow Six Siege`, `Rocket League` or `StarCraft II`. Present only when the wallet's record in that game clears the 5-resolved-market floor, in which case the rate and record are the game's rather than the `Esports` bucket's. Absent when the rate is the bucket's (the wallet's game history is under the floor), on every non-esports pick, beside every non-measured status, and on payloads predating the field. Label the rate with this when present and with `category` otherwise.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_win_rate_game: Option<String>,
    /// Why `category_win_rate` is present or absent on a `display_holders` entry: `measured` (rate present), `not_enough_data` (the wallet is below the resolved-market floor of 5 in the category), or `unavailable` (the annotation read failed; retry later). Absent entirely on `holders` entries, legacy rows, and payloads predating the field -- absence means the roster was never annotated, not a small sample.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_win_rate_status: Option<CategoryWinRateStatus>,
    /// Days since this wallet's first trade. Stamped at serve time from the wallet's current trader record, never frozen with the pick. The five badge fields are present together, and only for a wallet that carries at least one badge; all absent means no badge, or a body cached before the fields shipped.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub wallet_age_days: Option<f64>,
    /// True when the wallet's first trade was under 30 days ago. Stamped at serve time from the wallet's current trader record, never frozen with the pick. The five badge fields are present together, and only for a wallet that carries at least one badge; all absent means no badge, or a body cached before the fields shipped.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub is_new_wallet: Option<bool>,
    /// Distinct markets this wallet has traded. Stamped at serve time from the wallet's current trader record, never frozen with the pick. The five badge fields are present together, and only for a wallet that carries at least one badge; all absent means no badge, or a body cached before the fields shipped.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub markets_traded: Option<i64>,
    /// True when the wallet has traded 10,000 or more distinct markets, the breadth floor 0xinsider uses to mark automated wallets. It is a breadth rule, not proof of automation. Stamped at serve time from the wallet's current trader record, never frozen with the pick. The five badge fields are present together, and only for a wallet that carries at least one badge; all absent means no badge, or a body cached before the fields shipped.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub is_bot: Option<bool>,
    /// The wallet's X handle from its Polymarket profile, normalized to 1-15 characters of [A-Za-z0-9_] with no `@`. Link it as `https://x.com/<handle>`. Stamped at serve time from the wallet's current trader record, never frozen with the pick. The five badge fields are present together, and only for a wallet that carries at least one badge; all absent means no badge, or a body cached before the fields shipped.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub x_username: Option<String>,
}

/// The two counts `category_win_rate` is the ratio of, read from the same row: `wins / decided` equals the rate. Counts every resolved Polymarket market the wallet traded in the pick's canonical category (or in its game, when `category_win_rate_game` is present), at any position size; the counts are rebuilt daily. Present only with `category_win_rate_status` = `measured`; absent otherwise and on payloads predating the field.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickHolderCategoryWinRecord {
    /// Resolved markets in the category that this wallet closed with a profit.
    pub wins: i64,
    /// Resolved markets in the category that this wallet closed with a profit or a loss. A market resolved at zero realized P&L is in neither count.
    pub decided: i64,
}

/// Recorded lead wallet facts on a full response when available. Position and category history are frozen at publication; they are not live balances or pick win probabilities.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickLeadBacker {
    /// Lead trader wallet address.
    pub address: String,
    /// Recorded provider display name.
    #[serde(default)]
    pub name: Option<String>,
    /// Trader grade recorded at publication.
    pub grade: String,
    /// Canonical sport of the recorded directional history.
    pub category: String,
    /// Provider-reported position value on the backed outcome at publication, in USD. It is the gross value on that outcome and does not subtract shares the wallet held on the other outcome; see net_position_usd. It is not the entry cost or a live balance.
    pub position_usd: f64,
    /// Net value of the lead's position toward the backed outcome at publication, in USD: shares held on the backed outcome minus shares held on the other outcome of the same market, valued at the backed outcome's provider price at publication. Present only when the wallet also held the other outcome; absent for a one-sided position, whose net equals position_usd. It is not a live balance.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub net_position_usd: Option<f64>,
    /// Start time of the provider position fetch used at publication. This conservative observation clock precedes completion; the position is not a live balance.
    pub position_observed_at: String,
    /// Distinct directional events in the recorded category history.
    pub directional_event_count: i64,
    /// Events with strictly positive native terminal P&L in the same frozen category sample as directional_event_count, realized_pnl_usd and roi. Multiple market positions in one event contribute one combined event result. Zero-profit events remain in directional_event_count but do not increase this count. This is a recorded wallet result, not a market win rate or the pick's win probability.
    pub profitable_event_count: i64,
    /// Realized P&L over the recorded directional category sample, in USD. Excludes open positions and later changes.
    pub realized_pnl_usd: f64,
    /// Recorded entry basis of that directional sample, in USD; not a claim of complete trading costs or fees.
    pub entry_basis_usd: f64,
    /// Realized P&L divided by recorded entry basis, as a fraction: 0.10 means 10%. This is a wallet statistic, not a pick win probability.
    pub roi: f64,
    /// Peak-to-trough realized P&L drawdown after each event result in the recorded sample, in USD. Excludes intragame, unrealized, and account equity drawdown.
    pub max_realized_drawdown_usd: f64,
    /// Timestamp when the directional history evidence was recorded, separate from the provider position snapshot clock.
    pub recorded_at: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDay {
    /// Full success containing entitled proof-readable picks.
    pub state: String,
    /// The pick's local publication date (YYYY-MM-DD).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pick_date: Option<String>,
    /// Deprecated compatibility daily release slot; use pick_id for identity and publication_order for scheduling.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pick_rank: Option<i64>,
    /// Published picks for this product day in the returned display order. Use pick_id for identity.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub picks: Option<Vec<PickOfTheDay>>,
    /// Number of items in `picks`: the proof-readable picks. Picks held in `proof_pending_picks` are not counted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pick_count: Option<i64>,
    /// Rank-ordered entitled selections that have not released. Every row retains release_at and kickoff; unauthorized scheduled ranks appear only in identity-free locked_picks.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scheduled_picks: Option<Vec<ScheduledPickSlot>>,
    /// Human-readable matchup (e.g. "Portugal vs. Uzbekistan").
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub matchup: Option<String>,
    /// Recorded canonical sport category. Prefer display_category for the public competition label.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Frozen public presentation category. Tennis uses the provider-verified ATP or WTA tour, including Wimbledon and doubles; unknown tours retain Tennis. Every men's and women's cricket competition uses Cricket. Other sports use the curated league, esports title or soccer competition label, then the provider series name without its season year, then category when no competition is known. The canonical category and measured cohort are unchanged: an esports title still uses the pooled Esports category. Optional for mixed-version client compatibility.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub display_category: Option<String>,
    /// Provider platform. Always polymarket.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub platform: Option<String>,
    /// The pick's stored release instant. Use the returned timestamp; published_at records when publication occurred.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub release_at: Option<String>,
    /// True only before the pick's stored release instant (a pre-release embargo flag); effectively always false on a served, already-published pick. To detect that the backed game has kicked off, use `game_started`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub is_locked: Option<bool>,
    /// True once the backed game's kickoff has passed (kickoff <= now). When true the snapshotted pre-game price is no longer actionable. Absent for a legacy pick with no stored kickoff (treat as not-started).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub game_started: Option<bool>,
    /// Whether the backed game is over according to the cached live scoreboard, read at serve time. Tells a finished game from one still in play before `outcome` settles. Omitted when the pick has no event slug or no scoreboard is cached for it; absence is unknown, never false.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub game_ended: Option<bool>,
    /// Settlement outcome of the backed side; 'pending' until the market resolves.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome: Option<Outcome>,
    /// Pre-formatted SETTLEMENT STATUS for display: "Win" / "Loss" / "Void" / "Pending" -- the outcome enum above as a label. Convenience only; outcome is the source value. NOTE: this is the win/loss STATUS, not the backed side. The backed side is pick_outcome_label ("Belgium (-2.5)") -- a different field answering a different question.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome_display: Option<String>,
    /// The backed side phrased as a bet: a team for a moneyline (e.g. "Portugal"), the handicap line for a spread (e.g. "Belgium (-2.5)"), or "{team} to advance" for a knockout advancement market (e.g. "Spain to advance").
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pick_outcome_label: Option<String>,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the backed outcome; omitted when unavailable (e.g. unsynced markets).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub token_id: Option<String>,
    /// The backed side phrased as a bet (e.g. "Portugal to win").
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub position: Option<String>,
    /// One-line summary of which side sharp money is backing. Required on every item in `picks`: a current-day published pick whose required holder proof is not safely readable is listed in `proof_pending_picks` instead of being served with a partial success shape or a synthetic zero, and the route returns 503 read_model_warming only when no published pick has readable proof.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub side_summary: Option<String>,
    /// S/A wallet count on the backed side in the public V1 compatibility projection.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sharp_wallet_count: Option<i64>,
    /// Deprecated spelling of sharp_wallet_count with the same value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub smart_wallet_count: Option<i64>,
    /// Best recorded S/A grade in the public V1 compatibility projection.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub top_grade: Option<String>,
    /// Recorded sharp-money magnitude in USD when available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sharp_usd: Option<f64>,
    /// Deprecated spelling of sharp_usd with the same value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub smart_usd: Option<f64>,
    /// Frozen pre-game probability (0..1) for the backed side, written once at publication. It is the Polymarket CLOB order book midpoint at release, not an executed fill: a buyer lifts the ask, so a subscriber's own entry is usually a little worse than this price.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub backed_price: Option<f64>,
    /// Full-only disclosure when backed_price was recovered from provider history within 30 seconds before publication. Render beside the price. Absent for ordinary publication captures and teasers; this is a historical reference, not an executed fill.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub entry_price_note: Option<String>,
    /// Pre-formatted backed_price as cents-on-the-dollar odds, to ONE decimal: "62.0c" / "99.9c". Never rounded to a whole cent -- a 99.9c favorite is not a 100c certainty. Convenience only; backed_price is the source value. Omitted when backed_price is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub odds_display: Option<String>,
    /// The flat stake the published record puts on every pick, in USD: 1000 since 2026-09-22 (it was 100 before). Present exactly when return_usd is, so a reader never has to know the stake from anywhere else.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub stake_usd: Option<f64>,
    /// Gross return of stake_usd at the frozen midpoint price (stake_usd / backed_price). A real fill pays the ask, so an executed stake usually returns a little less. Omitted with backed_price.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub return_usd: Option<f64>,
    /// The same return on a literal $100 (100 / backed_price), kept for compatibility: the field predates stake_usd and its name promises the $100 basis, so a client that scales it to its own stake stays right. Present exactly when return_usd is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub return_per_100: Option<f64>,
    /// Pre-formatted return_usd as USD with cents and thousands separators: "$1,612.90" / "$12,500.00". The GROSS return (the stake included), so it carries no sign. Convenience only; return_usd is the source value. Omitted when return_usd is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub payout_display: Option<String>,
    /// Pre-formatted PROFIT on the stake -- return_usd minus stake_usd, i.e. the payout net of what you put in -- as a signed USD string: "+$612.90". Distinct from payout_display, which is gross. Omitted when return_usd is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub profit_display: Option<String>,
    /// Backend-owned CLV capture disposition. "pending" means no capture decision exists yet; terminal provider or quality statuses remain distinguishable. The raw close price and timestamp are never serialized.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_status: Option<String>,
    /// Backend-owned CLV evidence basis. `frozen_displayed_entry` uses the persisted displayed entry. `historical_provider_entry` uses a known-CLOB point at or before publication. `historical_provider_price_match` requires the latest point in the prior hour to match. `historical_provider_nearby_price_match` requires a matching point within five minutes before publication. Source-null bases preserve unknown original provenance.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_basis: Option<String>,
    /// Closing-line value toward the backed side, computed as (close / entry - 1) * 100. The basis-specific provider p entry must match the stored display; historical_provider_price_match also requires source provenance to remain null and its latest entry to be within the one-hour window at or before publication. Every basis requires a later quality-checked p close from the same series in the bounded post-entry, pre-kickoff window. Omitted when not measured.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_pct: Option<f64>,
    /// Backend-formatted signed CLV percentage, present exactly when clv_pct is present.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_display: Option<String>,
    /// Backend-owned CLV formula text with the entry probability, close probability, and rounded result. Provider timestamps remain private.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_explanation: Option<String>,
    /// Net return for the pick in stake units (return_usd / stake_usd - 1); one unit is one stake_usd stake, and the figure is the same under any stake size. Omitted when the outcome is not valued.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit_score: Option<f64>,
    /// Backend-formatted signed unit score, present exactly when unit_score is present.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit_score_display: Option<String>,
    /// Recorded sharp-money share as a 0..1 fraction when available. This is not a winning probability.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sharp_pct: Option<f64>,
    /// Recorded market-implied probability as a 0..1 fraction when available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub market_pct: Option<f64>,
    /// Optional recorded specialist facts on a full response. These describe the trader, not the pick's win probability. Omitted when no recorded specialist is available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub qualifying_expert: Option<PickOfTheDayQualifyingExpert>,
    /// Public V1 S/A wallet count on the backed side, equal to sharp_wallet_count.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub traders: Option<i64>,
    /// Recorded aggregate backed-side position value in USD when available, not a live balance or entry cost. The display_holders roster can include additional wallets; use the returned aggregate rather than summing that roster.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub backed_sharp_usd: Option<f64>,
    /// Bounded S/A holder display projection from the recorded snapshot. Historical rows retain their recorded display shape.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub holders: Option<Vec<PickHolder>>,
    /// Optional recorded holder roster in display order, with lead_backer first when present. Preserve the returned order. The roster can include wallets outside the recorded count and aggregate fields; do not derive holder_count, wallet counts or backed_sharp_usd from its length or a sum. Position values are gross holdings on the backed outcome and can coexist with holdings on the other outcome. Historical rows retain their recorded display shape.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub display_holders: Option<Vec<PickHolder>>,
    /// S/A holder count for the public V1 compatibility projection. display_holders can include additional grades.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub holder_count: Option<i64>,
    /// Display-ready explanation of the recorded pick. Render the returned text rather than reconstructing it from holder counts or grades.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub thesis: Option<String>,
    /// Canonical web market URL.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub market_url: Option<String>,
    /// Where this pick's outbound Polymarket link lands: Polymarket's own redirect answer for `/event/<event_slug>`, carrying the referral tag. Omitted until that redirect has been resolved; link to the event page instead when it is absent.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub polymarket_url: Option<String>,
    /// The canonical /event game-page slug (one neutral page per game); omitted when the game has no neutral event page.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_slug: Option<String>,
    /// Backend-resolved /event destination slug for the source market. Omitted outside full responses; null is an authoritative no-link decision.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_link_slug: Option<String>,
    /// Provider-first sports context for the pick's market (team logos, league branding, live score). Full-state only; omitted when the pick is not a team-sports market.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sports_context: Option<PickSportsContext>,
    /// Risk disclaimer shown with every pick.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub disclaimer: Option<String>,
    /// Entitled published picks whose holder proof is unreadable, ordered by rank. Unauthorized ranks appear only in locked_picks and cannot trigger proof warming. Read retry_at for the next read.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub proof_pending_picks: Option<Vec<ProofPendingPickSlot>>,
    /// Optional full-response entry authorization. Missing or expired authorization cannot authorize an automated entry.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub entry_authorization: Option<PotdEntryAuthorization>,
    /// Unauthorized unresolved published or scheduled ranks. Contains no game, provider identity, price, or identifying clock. Pro may upgrade to Max to open these ranks.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub locked_picks: Option<Vec<PickOfTheDayLockedPicksItem>>,
    /// Actionable status, including Upgrade to Max when only locked ranks are published.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub message: Option<String>,
    /// Stable pick row identity as decimal text. Never use a quality rank as identity.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pick_id: Option<String>,
    /// Compatibility release slot. No quality claim; historic scheduling order is retained.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub publication_order: Option<i64>,
    /// Viewer-independent free selection designation. New rows store it explicitly; historic null storage uses the original free slot.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub is_free_selection: Option<bool>,
    /// Deprecated (#24157): always null. No replacement lineage was ever recorded in this field; the key stays so existing V1 clients keep parsing. Identify a pick by pick_id.
    #[serde(default)]
    pub supersedes_pick_id: Option<String>,
    /// Optional full-only lead wallet publication facts. Omitted on legacy picks or when the recorded evidence is unavailable.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub lead_backer: Option<PickLeadBacker>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayArchive {
    /// Published Pick of the Day selections that have not been withdrawn, newest first by pick_date and then pick_rank within each product day. Withdrawn rows stay excluded after settlement.
    pub picks: Vec<PickOfTheDayArchiveEntry>,
    /// One entry per product day that has a published pick included in the archive, newest first, in the same order as picks. Each carries that day's net units, accumulated in the same backend pass and behind the same visibility gate as hit_rate.unit_score, so both cover the same population of picks. Re-adding the day totals reproduces hit_rate.unit_score to display precision rather than bit-for-bit, since that re-associates the floating-point sum.
    pub days: Vec<PickOfTheDayArchiveDay>,
    pub hit_rate: PickOfTheDayHitRate,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayArchiveDay {
    /// The product day (YYYY-MM-DD).
    pub date: String,
    /// Published picks on the day: wins + losses + void + pending.
    pub picks: i64,
    /// Picks on the day that resolved as a win, counted by the same pass as hit_rate.wins, so the day entries sum to the headline record.
    pub wins: i64,
    /// Picks on the day that resolved as a loss, counted by the same pass as hit_rate.losses.
    pub losses: i64,
    /// Picks on the day that resolved void: the market settled with no winner, or the game was suspended or postponed and not completed within 72 hours of kickoff. A void is neither a win nor a loss and is not staked, so it enters no money figure.
    pub void: i64,
    /// Picks on the day not yet resolved. A day whose picks are all pending is a real 0-0 day with pending > 0, not a missing record.
    pub pending: i64,
    /// Net units over the day's visible, valued, staked (win or loss) picks: the same population staked_usd runs over. Omitted when the day has not scored -- every pick still pending or void, or a price-gated current row -- which is not the same as a real 0.0 day.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit_score: Option<f64>,
    /// unit_score pre-formatted as signed units to two decimals (for example +1.24u or -2.00u), by the same formatter the per-pick unit_score_display and hit_rate.unit_score_display use. Present exactly when unit_score is; unit_score is the source value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit_score_display: Option<String>,
    /// win when every decided pick on the day won, loss when every one lost, over at least three decided (win or loss) picks with nothing pending. Omitted for every other day. A void is not a result: it neither lifts a day over the floor nor spoils a sweep.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sweep: Option<Sweep>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayArchiveEntry {
    /// The pick's local publication date (YYYY-MM-DD).
    pub pick_date: String,
    /// Deprecated compatibility daily release slot; use pick_id for identity and publication_order for scheduling.
    pub pick_rank: i64,
    /// When this selection was published, as RFC3339 UTC. Use this instant for publication feeds and timelines; pick_date is the America/New_York product day, not a publication timestamp. Absent only for historical rows whose publication instant is unknown.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub published_at: Option<String>,
    /// Human-readable matchup (e.g. "Portugal vs. Uzbekistan").
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub matchup: Option<String>,
    /// Frozen canonical sport bucket (e.g. "Basketball", "MMA", or "Soccer"). Existing semantics are unchanged; presentation consumers should prefer display_category when present.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Frozen public presentation category. Tennis uses the provider-verified ATP or WTA tour, including Wimbledon and doubles; unknown tours retain Tennis. Every men's and women's cricket competition uses Cricket. Other sports use the curated league, esports title or soccer competition label, then the provider series name without its season year, then category when no competition is known. The canonical category and measured cohort are unchanged: an esports title still uses the pooled Esports category. Optional for mixed-version client compatibility.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub display_category: Option<String>,
    /// Provider (Polymarket Gamma) market thumbnail URL (markets.image); omitted (not null) when the market has no image. Public regardless of the backed-side gate, so present for pending rows too.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub image_url: Option<String>,
    /// The backed side's outcome label. Omitted for a still-pending pick when the request is not from an authenticated Pro key.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pick_outcome_label: Option<String>,
    /// Recorded top grade on the backed side in the public V1 compatibility projection. Omitted when unavailable. Historical values remain recorded snapshots.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub top_grade: Option<String>,
    /// Settlement outcome of the backed side; 'pending' until the market resolves.
    pub outcome: Outcome,
    /// Pre-formatted settlement status for display: "Win" / "Loss" / "Void" / "Pending" -- the outcome enum above as a label, from the same formatter the pick payload's outcome_display uses. Convenience only; outcome is the source value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome_display: Option<String>,
    /// When outcome was LAST written to a settled value (RFC3339 UTC), the same instant the commitment ledger publishes. It moves with a corrected market re-mapping an already-settled pick. Omitted (not null) for a pending pick and for a pick that settled before the instant was recorded, so absence means the instant is unknown, never that the pick is unsettled -- outcome answers that. Additive and optional for mixed-version client compatibility.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resolved_at: Option<String>,
    /// The flat stake this row was valued at, in USD: 1000 since 2026-09-22 (100 before). Every row of the record is valued at the current stake, including picks published before the change. Present exactly when return_usd is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub stake_usd: Option<f64>,
    /// Gross return of stake_usd on this resolved pick: a win returns stake_usd / backed_price and a loss returns 0. A loss always returns 0 (the whole stake is lost regardless of price). The operand is published beside it as backed_price on every row that carries a return, so the entry never has to be recovered by inverting this number. Omitted (not null) for a still-pending pick, for a void (the market settled with no winner, or the game was suspended or postponed and not completed within 72 hours of kickoff, so the pick is not staked) and for a resolved WIN with no frozen price (a win's payout needs the price); mirrors the backend skip-when-absent behavior and the route-client optional (non-nullable) schema.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub return_usd: Option<f64>,
    /// The same return on a literal $100 (a win returns 100 / backed_price, a loss 0), kept for compatibility: the field predates stake_usd and its name promises the $100 basis. Present exactly when return_usd is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub return_per_100: Option<f64>,
    /// Pre-formatted return_usd as USD with cents: "$2,000.00". Present exactly when return_usd is -- it is formatted from that already-gated value -- so it is omitted for a still-pending pick, a void, an unpriced win, and any pick whose backed side is withheld. Convenience only; return_usd is the source value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub payout_display: Option<String>,
    /// Frozen price of the backed side (0..1) that return_usd and return_per_100 were computed from: on a win, stake_usd / backed_price equals return_usd. It is the Polymarket CLOB order book midpoint at release, frozen write-once at publication, not an executed fill: a buyer lifts the ask, so a subscriber's own entry is usually a little worse than this price. Present exactly when return_usd is, and on a void, which carries no return: so it is omitted for a still-pending pick, an unpriced win, and any pick whose backed side is withheld.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub backed_price: Option<f64>,
    /// Closing-line value toward the backed side, computed as (close / entry - 1) * 100. Omitted when the row is gated, ineligible, or not measured.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_pct: Option<f64>,
    /// Backend-formatted signed CLV percentage, present exactly when clv_pct is present.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_display: Option<String>,
    /// Entry operand of clv_pct: the frozen pick probability the close is compared against. It equals backed_price, which CLV eligibility requires. Present exactly when clv_pct is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_entry_price: Option<f64>,
    /// Close operand of clv_pct: the last valid Polymarket probability before the close bound (kickoff, or the first instant the live feed reported the game in progress when that came earlier). Present exactly when clv_pct is; the close timestamp stays private.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_close_price: Option<f64>,
    /// Whether CLV applies. A visible resolved pick published after kickoff is not_applicable.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_applicability: Option<ClvApplicability>,
    /// Backend-owned CLV text. A measured row names the entry, then the close, then the formula (close / entry - 1) x 100 and its rounded result; otherwise it gives the reason CLV does not apply or is unavailable.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_explanation: Option<String>,
    /// Exact backend CLV capture disposition for this visible row. Pending and terminal provider or quality statuses are distinguishable; capture timestamps are never serialized, while a measured row's entry and close prices are published as clv_entry_price and clv_close_price.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_status: Option<String>,
    /// Backend-owned CLV evidence basis. Source-null price-match bases preserve unknown original provenance. `historical_provider_nearby_price_match` requires a matching Polymarket point within five minutes before publication.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_basis: Option<String>,
    /// Net return for this pick in stake units (return_usd / stake_usd - 1), where one unit is one stake_usd stake; the same figure under any stake size. Omitted when the backed side is withheld or the pick is not valued.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit_score: Option<f64>,
    /// Backend-formatted signed unit score, present exactly when unit_score is present.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit_score_display: Option<String>,
    /// The account or paid tier needed to open this unresolved rank.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub required_tier: Option<RequiredTier>,
    /// True for an unauthorized unresolved row. Game identity, category, image, publication clock and all backed facts are omitted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub backed_side_locked: Option<bool>,
    /// Stable pick row identity as decimal text. Never use a quality rank as identity.
    pub pick_id: String,
    /// Compatibility release slot. No quality claim; historic scheduling order is retained.
    pub publication_order: i64,
    /// Viewer-independent free selection designation. New rows store it explicitly; historic null storage uses the original free slot.
    pub is_free_selection: bool,
    /// Deprecated (#24157): always null. No replacement lineage was ever recorded in this field; the key stays so existing V1 clients keep parsing. Identify a pick by pick_id.
    #[serde(default)]
    pub supersedes_pick_id: Option<String>,
}

/// Select using the entry commitment_version, never implicit payload shape. All historic v1 hashes remain unchanged.
pub type PickOfTheDayCommitmentPayload = serde_json::Value;

/// The frozen identity of the pick, exactly as the hash was taken over it. Served byte for byte as it was hashed -- keys sorted by UTF-8 byte value, no insignificant whitespace -- so a verifier concatenates and hashes with nothing to reconstruct. Property order below is the wire order. The outcome is deliberately NOT part of it: surviving a corrected outcome unchanged is the case the commitment exists for. Worked example: {"backed_price":"0.545000","condition_id":"0xabc","kickoff":"2026-09-20T23:05:00Z","pick_date":"2026-09-20","pick_outcome_index":1,"pick_outcome_label":"Lakers","pick_rank":1,"platform":"polymarket"} with the nonce 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f hashes to 44d18fa5e2aa3a2bf3c971dcc9317c8ccbdfd5480a4773b6d8ffd5fbeeea84dc.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayCommitmentPayloadV1 {
    /// Frozen pre-game price of the backed side, 0..1, as the plain decimal text of the stored NUMERIC at full stored precision, trailing zeros included. A string, never a number: a float round-trip would change the bytes and break the hash. Deliberately not normalized -- 0.545000 stays "0.545000".
    pub backed_price: String,
    /// Provider condition id of the backed market.
    pub condition_id: String,
    /// Frozen provider kickoff, whole seconds, UTC, literal Z. Fixed precision, never a shortest-lossless rendering.
    pub kickoff: String,
    /// ET product day (YYYY-MM-DD).
    pub pick_date: String,
    /// Index of the backed outcome within the market.
    pub pick_outcome_index: i64,
    /// Frozen display label of the backed outcome.
    pub pick_outcome_label: String,
    /// 1-based daily slot.
    pub pick_rank: i64,
    /// Provider platform. Always polymarket.
    pub platform: String,
}

/// Version 2 rank-free canonical payload: sorted nine keys, unchanged string escaping, exact decimal text and whole-second UTC kickoff. pick_id is decimal text; version is JSON integer 2.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayCommitmentPayloadV2 {
    /// Frozen pre-game price of the backed side, 0..1, as the plain decimal text of the stored NUMERIC at full stored precision, trailing zeros included. A string, never a number: a float round-trip would change the bytes and break the hash. Deliberately not normalized -- 0.545000 stays "0.545000".
    pub backed_price: String,
    /// Provider condition id of the backed market.
    pub condition_id: String,
    /// Frozen provider kickoff, whole seconds, UTC, literal Z. Fixed precision, never a shortest-lossless rendering.
    pub kickoff: String,
    /// ET product day (YYYY-MM-DD).
    pub pick_date: String,
    /// Index of the backed outcome within the market.
    pub pick_outcome_index: i64,
    /// Frozen display label of the backed outcome.
    pub pick_outcome_label: String,
    /// Provider platform. Always polymarket.
    pub platform: String,
    /// Stable pick row identity as decimal text. Never use a quality rank as identity.
    pub pick_id: String,
    pub version: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayHitRate {
    /// Number of decided picks that won.
    pub wins: i64,
    /// Number of decided picks that lost.
    pub losses: i64,
    /// Number of decided picks (wins + losses); excludes void and pending.
    pub decided: i64,
    /// Rolling hit rate as a percentage (wins / decided * 100, to 1 decimal); 0 when none are decided.
    pub pct: f64,
    /// Number of picks that resolved void (excluded from the hit rate).
    pub void: i64,
    /// Number of picks still pending resolution (excluded from the hit rate).
    pub pending: i64,
    /// The flat stake every money figure here assumes, in USD: 1000 since 2026-09-22 (100 before). Always present.
    pub stake_usd: f64,
    /// Cumulative profit (USD) of a stake_usd-per-pick strategy over visible valued settled picks: a priced win pays stake_usd/backed_price - stake_usd, every visible loss pays -stake_usd independent of price. A void is not staked and adds nothing. An unpriced visible win and a current non-Insider row whose price is gated remain in wins/losses but are excluded from price-derived totals.
    pub net_profit_usd: f64,
    /// Total staked (USD) = stake_usd * count of visible valued settled picks: every visible loss and every priced win. Voids, unpriced wins and current non-Insider rows whose price is gated are excluded.
    pub staked_usd: f64,
    /// Return on the staked amount as a percentage (net_profit_usd / staked_usd * 100, to 1 decimal); 0 when nothing is staked.
    pub roi_pct: f64,
    /// Pre-formatted net profit for display, e.g. "+$100" / "-$40". Whole dollars, signed, round-then-signed so a rounds-to-zero record reads "+$0" (never "-$0"). Convenience only; net_profit_usd is the source value.
    pub net_profit_display: String,
    /// Pre-formatted ROI for display, e.g. "+8.3%" / "-20.0%". One decimal, signed, round-then-signed so a rounds-to-zero record reads "+0.0%" (never "-0.0%"). Convenience only; roi_pct is the source value.
    pub roi_display: String,
    /// Pre-formatted win rate for display, e.g. "92.3%". One decimal, unsigned. Convenience only; pct is the source value.
    pub win_rate_display: String,
    /// Cumulative net return in stake units over the same valued win/loss population as net_profit_usd.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit_score: Option<f64>,
    /// Backend-formatted signed cumulative unit score, for example "+1.25u". Omitted when no valued settled pick contributes to the aggregate.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit_score_display: Option<String>,
    /// Visible resolved archive rows with no CLV capture disposition yet.
    pub clv_pending: i64,
    /// Visible resolved archive rows with a terminal non-measured CLV disposition.
    pub clv_unavailable: i64,
    /// Aggregate CLV state. Counts remain available for mixed measured/pending/unavailable populations.
    pub clv_state: ClvState,
    /// Visible resolved archive rows with valid basis-specific CLV entry evidence. Known-source bases require CLOB provenance; historical_provider_price_match instead requires source provenance to remain null and the latest provider p entry in the one-hour window at or before publication to match the stored display.
    pub clv_eligible: i64,
    /// Every visible resolved archive row, including post-kickoff picks. A price-gated current row is excluded until its backed side becomes visible.
    pub clv_total: i64,
    /// Eligible resolved public rows with a measured Polymarket CLOB close.
    pub clv_measured: i64,
    /// Visible resolved rows published before kickoff. This is the CLV coverage denominator.
    pub clv_applicable: i64,
    /// Visible resolved rows published after kickoff. These rows remain public but do not enter coverage.
    pub clv_not_applicable: i64,
    /// Measured divided by clv_applicable as a percentage. Omitted when clv_applicable is zero.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_coverage_pct: Option<f64>,
    /// Backend-formatted measured/clv_applicable coverage percentage.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_coverage_display: Option<String>,
    /// Backend-owned coverage count text, including the excluded post-kickoff count.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_coverage_explanation: Option<String>,
    /// Arithmetic mean of per-pick ratio CLV, (close / entry - 1) * 100. A cheap entry weighs more here than a favorite, so the headline average is clv_avg_pp; this field is kept for continuity. Suppressed until at least five measured rows exist.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_avg_pct: Option<f64>,
    /// Backend-formatted signed average CLV percentage, present when clv_avg_pct is present.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_avg_display: Option<String>,
    /// Arithmetic mean of the measured closing-line move in percentage points, (close - entry) * 100, so every pick counts on the same scale. The headline CLV average. Covers the same measured rows as clv_avg_pct and is suppressed under the same five-row floor.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_avg_pp: Option<f64>,
    /// Backend-formatted signed average in percentage points, for example "+0.4 pp"; a value that rounds to zero reads "0.0 pp". Present when clv_avg_pp is present.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub clv_avg_pp_display: Option<String>,
    /// Measured public rows where close is strictly greater than entry.
    pub clv_beats_close: i64,
    /// Measured public rows where close exactly equals entry.
    pub clv_ties: i64,
    /// Cumulative track-record series, one point per decided (win/loss) pick in ascending pick_date order (pending and void picks add no point). A non-valued decided row carries cumulative profit forward while advancing hit rate. The last point's net_profit_usd and hit_rate_pct equal the headline net_profit_usd and pct by construction. Empty when nothing is decided.
    pub series: Vec<PickOfTheDayHitRateSeriesItem>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayHitRateSeriesItem {
    /// The decided pick's publish date (YYYY-MM-DD).
    pub date: String,
    /// Running cumulative stake_usd-per-pick profit (USD) through this pick; valued losses and priced wins are booked, while a non-valued decided row carries profit forward unchanged.
    pub net_profit_usd: f64,
    /// Running rolling hit rate (wins / decided * 100, to 1 decimal) through this pick.
    pub hit_rate_pct: f64,
}

/// The commitment ledger: every published pick, ascending, in the state its commitment is actually in. The counts are derived from entries in the same pass that builds it.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayLedger {
    /// One entry per published (pick_date, pick_rank), ascending by pick_date then pick_rank.
    pub entries: Vec<PickOfTheDayLedgerEntry>,
    /// Number of entries, all states included.
    pub entry_count: i64,
    /// Entries committed to and not yet settled.
    pub sealed_count: i64,
    /// Entries committed to and verifiable now.
    pub opened_count: i64,
    /// Entries carrying no commitment, so provable by nothing: the honest size of the unprovable part of the record. It only stops growing; no pick is ever retro-sealed.
    pub uncommitted_count: i64,
}

/// One ledger entry. Read `state` to know which shape you have; the three are disjoint.
///
/// Discriminated by `state`. A `state` this release does not know is kept whole in
/// `Unknown`, so a new kind never fails a response.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum PickOfTheDayLedgerEntry {
    /// `state` is `sealed`.
    Sealed(PickOfTheDayLedgerSealedEntry),
    /// `state` is `opened`.
    Opened(PickOfTheDayLedgerOpenedEntry),
    /// `state` is `uncommitted`.
    Uncommitted(PickOfTheDayLedgerUncommittedEntry),
    /// A `state` this release does not know, kept as sent.
    Unknown(serde_json::Value),
}

impl<'de> Deserialize<'de> for PickOfTheDayLedgerEntry {
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = serde_json::Value::deserialize(deserializer)?;
        match value.get("state").and_then(serde_json::Value::as_str) {
            Some("sealed") => serde_json::from_value(value)
                .map(Self::Sealed)
                .map_err(de::Error::custom),
            Some("opened") => serde_json::from_value(value)
                .map(Self::Opened)
                .map_err(de::Error::custom),
            Some("uncommitted") => serde_json::from_value(value)
                .map(Self::Uncommitted)
                .map_err(de::Error::custom),
            _ => Ok(Self::Unknown(value)),
        }
    }
}

impl Serialize for PickOfTheDayLedgerEntry {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        match self {
            Self::Sealed(inner) => inner.serialize(serializer),
            Self::Opened(inner) => inner.serialize(serializer),
            Self::Uncommitted(inner) => inner.serialize(serializer),
            Self::Unknown(inner) => inner.serialize(serializer),
        }
    }
}

/// A settled pick whose commitment is open: the nonce plus the exact payload the hash was taken over. Concatenate the payload bytes as received with the decoded nonce and sha256 them to reproduce commitment_hash.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayLedgerOpenedEntry {
    pub state: String,
    /// ET product day the pick belongs to (YYYY-MM-DD).
    pub pick_date: String,
    /// Deprecated compatibility daily release slot; use pick_id for identity and publication_order for scheduling.
    pub pick_rank: i64,
    /// sha256(canonical_json(payload) || nonce), lowercase hex, no 0x prefix. Publishable the moment the pick releases: without the nonce it is not invertible.
    pub commitment_hash: String,
    /// The 32-byte nonce the hash was taken over, lowercase hex, no 0x prefix. Secret while the pick is live: a pick payload is low entropy, so a published nonce on a live pick would hand out the backed side.
    pub commitment_nonce: String,
    /// The construction the hash was taken with, stated in the response so a verifier never has to guess the serialization.
    pub commitment_algo: String,
    /// When the hash was frozen. Always strictly before kickoff: a pick that reaches kickoff unsealed stays unsealed forever, because a seal written after the game started would be a backdated proof.
    pub sealed_at: String,
    /// When outcome was LAST written to a settled value, or null when that instant is unknown. It moves with a corrected market re-mapping an already-settled pick, while commitment_hash stays untouched -- which is how a mirror that keeps history sees a correction.
    #[serde(default)]
    pub resolved_at: Option<String>,
    /// The frozen provider kickoff in the canonical payload form: whole seconds, UTC, literal Z. This exact string reappears inside payload.kickoff when the pick opens.
    pub kickoff: String,
    pub payload: PickOfTheDayCommitmentPayload,
    /// How the pick settled. Never pending: a pending pick is a sealed entry.
    pub outcome: PickOfTheDayLedgerOpenedEntryOutcome,
    /// Why the site withdrew this pick from its track record, or null when the pick counts. provider_game_cancelled: Polymarket marked the game Cancelled while the pick was pending. published_after_kickoff: the pick was published at or after its game started, including a suspended match that resumed later, so it was never a pre-game pick; this can be set after the pick settled. A withdrawn pick keeps its commitment and its real outcome here, but the site's record leaves it out of every count and money figure. Not part of the hashed payload, so it never moves commitment_hash.
    #[serde(default)]
    pub withdrawal_reason: Option<WithdrawalReason>,
    /// Frozen matchup, for a reader.
    pub matchup: String,
    /// Frozen canonical sport bucket (for example Basketball or MMA), not the exact public league identity; the archive owns that.
    pub category: String,
    /// The pick's public page.
    pub permalink: String,
    /// Stable pick row identity as decimal text. Never use a quality rank as identity.
    pub pick_id: String,
    /// Compatibility release slot. No quality claim; historic scheduling order is retained.
    pub publication_order: i64,
    /// Viewer-independent free selection designation. New rows store it explicitly; historic null storage uses the original free slot.
    pub is_free_selection: bool,
    /// Deprecated (#24157): always null. No replacement lineage was ever recorded in this field; the key stays so existing V1 clients keep parsing. Identify a pick by pick_id.
    #[serde(default)]
    pub supersedes_pick_id: Option<String>,
    /// Explicit proof provenance: 1 retains historic eight-field canonical JSON; 2 binds stable pick_id and version without pick_rank.
    pub commitment_version: i64,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PickOfTheDayLedgerOpenedEntryOutcome {
    /// `win`
    #[serde(rename = "win")]
    Win,
    /// `loss`
    #[serde(rename = "loss")]
    Loss,
    /// `void`
    #[serde(rename = "void")]
    Void,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl PickOfTheDayLedgerOpenedEntryOutcome {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Win => "win",
            Self::Loss => "loss",
            Self::Void => "void",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for PickOfTheDayLedgerOpenedEntryOutcome {
    fn from(value: &str) -> Self {
        match value {
            "win" => Self::Win,
            "loss" => Self::Loss,
            "void" => Self::Void,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for PickOfTheDayLedgerOpenedEntryOutcome {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for PickOfTheDayLedgerOpenedEntryOutcome {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// An unresolved published pick. Carries only date, rank, hash, algorithm, seal instant and permalink. Kickoff and game identity are withheld; seal time remains public commitment provenance.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayLedgerSealedEntry {
    pub state: String,
    /// ET product day the pick belongs to (YYYY-MM-DD).
    pub pick_date: String,
    /// Deprecated compatibility daily release slot; use pick_id for identity and publication_order for scheduling.
    pub pick_rank: i64,
    /// sha256(canonical_json(payload) || nonce), lowercase hex, no 0x prefix. Publishable the moment the pick releases: without the nonce it is not invertible.
    pub commitment_hash: String,
    /// The construction the hash was taken with, stated in the response so a verifier never has to guess the serialization.
    pub commitment_algo: String,
    /// When the hash was frozen. Always strictly before kickoff: a pick that reaches kickoff unsealed stays unsealed forever, because a seal written after the game started would be a backdated proof.
    pub sealed_at: String,
    /// The pick's public page.
    pub permalink: String,
    /// Stable pick row identity as decimal text. Never use a quality rank as identity.
    pub pick_id: String,
    /// Compatibility release slot. No quality claim; historic scheduling order is retained.
    pub publication_order: i64,
    /// Viewer-independent free selection designation. New rows store it explicitly; historic null storage uses the original free slot.
    pub is_free_selection: bool,
    /// Deprecated (#24157): always null. No replacement lineage was ever recorded in this field; the key stays so existing V1 clients keep parsing. Identify a pick by pick_id.
    #[serde(default)]
    pub supersedes_pick_id: Option<String>,
    /// Explicit proof provenance: 1 retains historic eight-field canonical JSON; 2 binds stable pick_id and version without pick_rank.
    pub commitment_version: i64,
}

/// A pick without a commitment, retained so the record cannot omit unprovable entries. Unresolved entries omit game identity; once resolved, matchup, category and payload become public. Existing opened canonical payload bytes and hashes are unchanged.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayLedgerUncommittedEntry {
    pub state: String,
    /// ET product day the pick belongs to (YYYY-MM-DD).
    pub pick_date: String,
    /// Deprecated compatibility daily release slot; use pick_id for identity and publication_order for scheduling.
    pub pick_rank: i64,
    /// Always true: this pick has no commitment and never will.
    pub pre_commitment: bool,
    /// How the pick settled, or pending.
    pub outcome: Outcome,
    /// Omitted while the pick is pending; once it settles, why the site withdrew it from its track record, or null when the pick counts. provider_game_cancelled: Polymarket marked the game Cancelled while the pick was pending. published_after_kickoff: the pick was published at or after its game started, including a suspended match that resumed later, so it was never a pre-game pick; this can be set after the pick settled. A withdrawn pick stays here with its real outcome, but the site's record leaves it out of every count and money figure.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub withdrawal_reason: Option<WithdrawalReason>,
    /// Frozen matchup, for a reader.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub matchup: Option<String>,
    /// Frozen canonical sport bucket (for example Basketball or MMA), not the exact public league identity; the archive owns that.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// When outcome was LAST written to a settled value, or null when that instant is unknown. It moves with a corrected market re-mapping an already-settled pick, while commitment_hash stays untouched -- which is how a mirror that keeps history sees a correction.
    #[serde(default)]
    pub resolved_at: Option<String>,
    /// The pick's market, side and price once it has settled; null while it is pending, and null for a settled pick whose stored row lacks one of these columns. Not hashed: nothing was committed over these values, which is what pre_commitment: true says.
    #[serde(default)]
    pub payload: Option<PickOfTheDayUncommittedPayload>,
    /// The pick's public page.
    pub permalink: String,
    /// Stable pick row identity as decimal text. Never use a quality rank as identity.
    pub pick_id: String,
    /// Compatibility release slot. No quality claim; historic scheduling order is retained.
    pub publication_order: i64,
    /// Viewer-independent free selection designation. New rows store it explicitly; historic null storage uses the original free slot.
    pub is_free_selection: bool,
    /// Deprecated (#24157): always null. No replacement lineage was ever recorded in this field; the key stays so existing V1 clients keep parsing. Identify a pick by pick_id.
    #[serde(default)]
    pub supersedes_pick_id: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayLockedPicksItem {
    pub pick_rank: i64,
    pub required_tier: String,
}

/// A successful current-day entitlement response when only unauthorized ranks have published. It carries an empty pick set, identity-free locked ranks and an upgrade message. Selection IDs, game identity, prices and unauthorized clocks are absent. Any scheduled or proof-pending rows are entitled rows.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayNoEntitledPicks {
    /// Only locked ranks are published for this account.
    pub state: String,
    /// Current product date in America/New_York (YYYY-MM-DD).
    pub pick_date: String,
    /// Empty: no entitled proof-readable picks are returned.
    pub picks: Vec<PickOfTheDay>,
    /// Zero entitled proof-readable picks.
    pub pick_count: i64,
    /// Unauthorized unresolved published or scheduled ranks. Contains no game, provider identity, price, or identifying clock. Pro may upgrade to Max to open these ranks.
    pub locked_picks: Vec<PickOfTheDayNoEntitledPicksLockedPicksItem>,
    /// Actionable status, including Upgrade to Max when only locked ranks are published.
    pub message: String,
    /// Rank-ordered entitled selections that have not released. Every row retains release_at and kickoff; unauthorized scheduled ranks appear only in identity-free locked_picks.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scheduled_picks: Option<Vec<ScheduledPickSlot>>,
    /// Entitled published picks whose holder proof is unreadable, ordered by rank. Unauthorized ranks appear only in locked_picks and cannot trigger proof warming. Read retry_at for the next read.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub proof_pending_picks: Option<Vec<ProofPendingPickSlot>>,
    /// Deprecated (#24157): always null. No replacement lineage was ever recorded in this field; the key stays so existing V1 clients keep parsing. Identify a pick by pick_id.
    #[serde(default)]
    pub supersedes_pick_id: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayNoEntitledPicksLockedPicksItem {
    pub pick_rank: i64,
    pub required_tier: String,
}

/// Optional recorded specialist facts on a full response. These describe the trader, not the pick's win probability. Omitted when no recorded specialist is available.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayQualifyingExpert {
    /// Trader wallet address.
    pub address: String,
    /// Provider display name, or null for an unnamed wallet.
    #[serde(default)]
    pub name: Option<String>,
    /// Recorded trader grade. Public V1 preserves its S/A compatibility projection.
    #[serde(default)]
    pub grade: Option<String>,
    /// The canonical sport bucket the win rate was measured over (for example Basketball). Can be BROADER than the pick's display_category, which names an exact league such as NBA — label the rate with this field, never with display_category.
    pub canonical_category: String,
    /// Share of the trader’s resolved markets in canonical_category with positive realized P&L, as a 0..1 fraction. Null when not measured. This is a trader statistic, not the pick’s probability of winning.
    #[serde(default)]
    pub win_rate: Option<f64>,
    /// Number of resolved markets behind win_rate; null when not measured.
    #[serde(default)]
    pub n_resolved: Option<i64>,
    /// Recorded Polymarket position value on the backed outcome, in USD. It can change after this snapshot.
    pub position_usd: f64,
    /// Recorded position value on the other outcome of this market, in USD. Omitted when not recorded; zero is a measured value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub opposite_position_usd: Option<f64>,
    /// Timestamp of the recorded trader statistics.
    pub stats_computed_at: String,
}

/// A settled uncommitted pick's market, side and price. The same eight fields as PickOfTheDayCommitmentPayload, in the same key order, so a settled pick's side and price sit under payload whatever the entry's state. It is NOT a commitment: no hash was taken over it before the game, and it proves nothing about when the pick was made.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickOfTheDayUncommittedPayload {
    /// Frozen pre-game price of the backed side, 0..1, as the plain decimal text of the stored NUMERIC at full stored precision, trailing zeros included -- rendered exactly as the commitment payload renders it.
    pub backed_price: String,
    /// Provider condition id of the backed market.
    pub condition_id: String,
    /// Frozen provider kickoff, UTC, literal Z; null when no kickoff was frozen. Whole seconds render exactly as the commitment payload does; a sub-second instant keeps its fraction rather than being truncated, since nothing here is hashed.
    #[serde(default)]
    pub kickoff: Option<String>,
    /// ET product day (YYYY-MM-DD).
    pub pick_date: String,
    /// Index of the backed outcome within the market.
    pub pick_outcome_index: i64,
    /// Frozen display label of the backed outcome.
    pub pick_outcome_label: String,
    /// 1-based daily slot.
    pub pick_rank: i64,
    /// Provider platform. Always polymarket.
    pub platform: String,
}

/// Provider-first sports context for a Pick of the Day market: team crests, league branding, and live score. Team logos and league logo are provider-owned (Polymarket /teams crests for clubs, country flags for national teams and tennis players); no local derivation.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickSportsContext {
    /// League or competition display name (e.g. "Premier League").
    #[serde(default)]
    pub league_name: Option<String>,
    /// Provider-owned event taxonomy from Gamma eventMetadata, joined in league · serie · tournament order with blanks and case-insensitive duplicates removed. Separate from league_name; omitted when the provider does not supply the metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub competition_label: Option<String>,
    /// League logo URL (provider-owned).
    #[serde(default)]
    pub league_logo: Option<String>,
    /// The team mapped to the market's YES outcome, or the parent-event home/first team when event_matchup is true.
    #[serde(default)]
    pub yes_team: Option<PickSportsTeam>,
    /// The team mapped to the market's NO outcome, or the parent-event away/second team when event_matchup is true.
    #[serde(default)]
    pub no_team: Option<PickSportsTeam>,
    /// Provider game identifier (Polymarket Gamma gameId); omitted when the provider supplies none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub game_id: Option<i64>,
    /// Always present. True when the two teams are the parent-event match identity for a teamless binary leg (e.g. a draw, totals, or prop market), not the market's own outcomes.
    pub event_matchup: bool,
    /// Present only alongside event_matchup: the event team the binary leg is about (provider group_item_title matched to a matchup team, e.g. Belgium for "Will Belgium win?"), i.e. the winner on a Yes resolution. Omitted for teamless legs (draw, totals, prop).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_subject_team: Option<PickSportsTeam>,
    /// The two teams as a single whole-game label, joined "<home> – <away>" (en-dash) in provider display order (e.g. "Portugal – Uzbekistan"). Composed server-side from the provider team names (no title/slug parsing). Present when both teams resolve a name; omitted for single-subject, teamless, or non-two-team contexts.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub matchup_title: Option<String>,
}

/// A single sports team or competitor in a Pick of the Day market's sports context. Identity and score fields are provider-owned and nullable. The structured score fields (`sets`, `format`, `sets_won`) and the tennis fields (`headshot`, `headshot_revision`, `tour`) are backend-owned and are OMITTED rather than null when they do not apply, so a consumer must treat an absent key and a null the same way.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PickSportsTeam {
    /// Team display label as it appears on the market outcome (e.g. "Portugal").
    #[serde(default)]
    pub label: Option<String>,
    /// Abbreviated team label (e.g. "POR").
    #[serde(default)]
    pub short_label: Option<String>,
    /// Full team or competitor name (e.g. "Portugal national football team").
    #[serde(default)]
    pub full_name: Option<String>,
    /// Provider team identifier (Polymarket /teams id).
    #[serde(default)]
    pub provider_id: Option<i64>,
    /// Team crest or flag URL. Official NFL (32), WNBA (15), NBA (30), NHL (32), and MLB (30) club crests use same-origin relative paths (`/api/sports/team-logos/{league}/{abbr}.svg?v=<content hash>`); resolve relative URLs against the API origin. Vendored soccer club crests use the same path with `.png`. Other teams use provider artwork, including country flags for national teams and tennis players. Novelty and national-team rows outside the vendored club sets retain provider artwork.
    #[serde(default)]
    pub logo: Option<String>,
    /// True when artwork measurements show that the team mark needs a light plate on a dark background. Vendored crest verdicts are tied to the exact asset bytes; provider artwork is measured by the teams sync. Always sent; false when no current measurement marks the logo dark.
    pub logo_mark_dark: bool,
    /// Team brand color as a hex string (provider-owned).
    #[serde(default)]
    pub color: Option<String>,
    /// Win-loss record as a display string (e.g. "12-4").
    #[serde(default)]
    pub record: Option<String>,
    /// Live or final score as a display string when the game is in play or settled.
    #[serde(default)]
    pub score: Option<String>,
    /// Tennis player headshot URL, served same-origin. Present only for a tennis competitor the headshot resolver matched; absent for team sports and for unmatched players, where `logo` stays the fallback.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headshot: Option<String>,
    /// Tennis tour this competitor belongs to. Present for every tennis entry whether or not `headshot` resolved, so a consumer can tell a tennis player with no photo from a non-tennis team. Absent for every other sport. Only `atp` and `wta` name a gender; the ITF World Tennis Tour runs men's and women's events and the provider does not say which, so `itf` means tennis with gender unknown.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tour: Option<Tour>,
    /// Per-set score cells for this side, in set order. Backend-owned: render these rather than parsing `score`. Omitted entirely when the provider score is not a structured multi-set match or could not be parsed, so an absent array and an empty one carry the same meaning.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sets: Option<Vec<ScoreCell>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub format: Option<ScoreFormat>,
    /// Completed sets won by this side. Present only when both sides expose the same set columns, so a partially parsed scoreline reports no tally rather than a misleading one.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sets_won: Option<i64>,
    /// Optional monotonic photo revision for this tennis player, independent of the sports score revision. Legacy stored photos start at zero. Successful new or changed image bytes advance it; source checks and attribution changes do not. Compare only for the same tour and provider_id: a higher revision replaces the portrait, an equal revision may fill a missing portrait, and a lower revision must not replace a newer one. Absent when no photo resolved.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headshot_revision: Option<i64>,
    /// Optional latest retrieved ATP/WTA singles rank for this player. Absent for unranked, ambiguous, doubles, expired, or unavailable identities. This is not rank at match time.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ranking: Option<TennisRanking>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Platform {
    /// `polymarket`
    #[serde(rename = "polymarket")]
    Polymarket,
    /// `all`
    #[serde(rename = "all")]
    All,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Platform {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Polymarket => "polymarket",
            Self::All => "all",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Platform {
    fn from(value: &str) -> Self {
        match value {
            "polymarket" => Self::Polymarket,
            "all" => Self::All,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Platform {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Platform {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PlatformCapabilities {
    pub grade: PlatformCapabilityStatus,
    pub pnl: PlatformCapabilityStatus,
    pub strategy: PlatformCapabilityStatus,
    pub timeline: PlatformCapabilityStatus,
    /// The large-trade feed. Canonical key since #16304; whale_signal is its deprecated spelling, emitted beside it with the same value.
    pub large_trades: PlatformCapabilityStatus,
    pub whale_signal: PlatformCapabilityStatus,
    pub suspicious_trades: PlatformCapabilityStatus,
    pub insider_radar: PlatformCapabilityStatus,
    pub market_snapshot: PlatformCapabilityStatus,
}

/// Every capability the API serves reports supported. The field names a per-capability status so a client can branch on coverage; no other value is emitted.
pub type PlatformCapabilityStatus = String;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Platforms {
    pub platforms: PlatformsPlatforms,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PlatformsPlatforms {
    pub polymarket: PlatformCapabilities,
}

/// A derived 0xinsider correction to Polymarket's P&L, never a Polymarket value. Polymarket misbooks neg-risk conversions, in both directions: it puts cost on placeholder YES outcomes minted by a conversion and never books it as a loss (negative amount), and its position records leave out shares the wallet really got, such as YES minted by a conversion, so it books no P&L on them (positive amount). Per neg-risk market the wallet converted in, 0xinsider measures Polymarket's own activity cash against the sum of its position P&L, and sums the difference over every measured market whose shares did not move by direct transfer: transferred shares have no activity row, so such a market keeps Polymarket's figure and is counted in markets_excluded. It is published once every neg-risk market the wallet converted in is measured and checked for transfers, and stays as last published until then (on the trader body, pnl.correction_pending says so); a sum under $1 either way publishes nothing. The body's own P&L fields keep Polymarket's figures; this object adds the amount and the corrected figures. Money is truncated toward zero to cents.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PnlCorrection {
    /// The correction method.
    pub basis: String,
    /// The correction in USD. Negative when Polymarket overstates the wallet.
    pub amount: f64,
    /// Polymarket's net realized P&L plus amount: the figure 0xinsider grades on. Omitted when Polymarket's figure is.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub realized: Option<f64>,
    /// Polymarket's net total P&L plus amount: the 0xinsider profile's Total P&L. Omitted when Polymarket's figure is, and on leaderboard entries.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub net_total: Option<f64>,
    /// The newest measurement among the measured markets.
    pub as_of: String,
    /// Neg-risk markets whose measurement amount sums.
    pub markets_measured: i64,
    /// Measured neg-risk markets left out because shares moved in or out of the wallet by direct transfer; they keep Polymarket's figure. Omitted when none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub markets_excluded: Option<i64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Position {
    /// Composite prefixed ID `pos_<wallet>:<condition_id>:<outcome_index>`.
    pub id: String,
    /// Provider discriminator. Polymarket only.
    pub platform: String,
    /// Lowercased proxy wallet address.
    pub wallet: String,
    /// Binary outcome side. Non-binary positions are not surfaced on V1.
    pub side: Direction,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for this outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Live share count from the wallet_positions mirror.
    pub shares: f64,
    /// Volume-weighted entry price for this leg.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub avg_price: Option<f64>,
    /// Current mark-to-market value in USD (always non-null on V1 — pre-reconcile rows are excluded).
    pub current_value_usd: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub initial_value_usd: Option<f64>,
    /// Unrealized P&L for the open position (Polymarket `cashPnl`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cash_pnl: Option<f64>,
    /// Closed-leg P&L rolled up (Polymarket `realizedPnl`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub realized_pnl: Option<f64>,
    /// Additive lossless source atoms for the display-safe position fields. Parse every `value` with decimal-safe arithmetic; never recover exact values from the numeric twins.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<PositionExact>,
    /// Max updated_at across mirror legs for this pair.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_reconciled_at: Option<String>,
    /// Backend-computed staleness bucket derived from last_reconciled_at.
    pub freshness: Freshness,
    pub trader: PositionTrader,
    pub market: PositionMarket,
}

/// Lossless position atoms from `wallet_positions`. `shares` and `current_value_usd` are required when this object is present; other source values are omitted when the mirror has no verified value.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PositionExact {
    pub shares: ExactDecimal,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cost_basis_usd: Option<ExactDecimal>,
    /// Exact derived price: `wallet_positions.cost_basis_usd / wallet_positions.shares`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub avg_price: Option<ExactDecimal>,
    pub current_value_usd: ExactDecimal,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub initial_value_usd: Option<ExactDecimal>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cash_pnl: Option<ExactDecimal>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub realized_pnl: Option<ExactDecimal>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PositionMarket {
    /// Prefixed ID (`mkt_...`).
    pub id: String,
    pub condition_id: String,
    pub title: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub slug: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_slug: Option<String>,
    /// Provider-backed market_canonical category.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Provider-reported outcome label (e.g. team name for sports). Separate from `side` because provider labels can diverge from the binary Yes/No axis.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub outcome_label: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub end_date: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PositionTimelineEvent {
    /// Prefixed ID (pe_...).
    pub id: String,
    /// ISO 8601 timestamp of the on-chain fill.
    pub event_timestamp: String,
    /// The wallet's own side of this fill: buy or sell.
    pub action: Action,
    pub outcome_side: Side,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for this outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Signed share delta (+ on buy, − on sell).
    pub amount_delta: f64,
    /// Fill price in USDC per share, in [0,1].
    pub price: f64,
    /// Positive USDC notional of the fill.
    pub usdc_notional: f64,
    /// Polygon transaction hash of the fill.
    pub tx_hash: String,
    /// Cumulative signed stored-fill amount for this outcome after this fill, including older pages. Stable across limits/cursors for unchanged source history. Excludes split, merge, redemption and neg-risk activity; not complete holdings. Incomplete fill history can also leave a negative amount.
    pub running_amount: f64,
    /// Cumulative buy-weighted average of stored fills for this outcome, including older pages; not provider current-position avgPrice. Sells do not change this value. 0 when no stored buys have occurred yet.
    pub running_avg_price: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PositionTrader {
    /// Prefixed ID (`trd_...`).
    pub id: String,
    pub address: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grade: Option<Grade>,
    /// Win rate as a ratio from 0 to 1 (0.62 means 62%), the same scale as stats.win_rate on GET /api/v1/trader/{address}. Absent when unknown.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub win_rate: Option<f64>,
    /// Polymarket's net total P&L for the wallet in USD: native Polymarket position P&L across all markets, fees included, plus credited maker and taker rebates (trader_trading_pnl.net_total_pnl). The 0xinsider profile's Total P&L is this figure unless the wallet has a published correction for neg-risk conversions, which GET /api/v1/trader/{address} serves as pnl.correction; the profile then shows pnl.correction.net_total. Not the Polymarket leaderboard figure, which GET /api/v1/trader/{address} still serves as pnl.total. Omitted when the wallet has no native accounting snapshot; the leaderboard figure is never substituted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pnl: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub markets: Option<i64>,
    /// Days since the wallet's first-seen time. For a wallet 0xinsider first recorded on or after March 21, 2026, that is when 0xinsider recorded it. For a wallet recorded earlier, it is usually the wallet's first Polymarket activity, so the age can run to years. It is not the wallet's on-chain age or the time of its first trade. Absent when the first-seen time is unknown.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub wallet_age_days: Option<f64>,
    /// True when wallet_age_days is under the new-wallet threshold (30 days), which means 0xinsider first recorded the wallet in the last 30 days. False when wallet_age_days is absent. This public V1 field is first-seen recency, not the wallet's on-chain age.
    pub is_new_wallet: bool,
}

/// Returned entry permission bound to the named market, token and outcome. Honor the immutable max_entry_price and expires_at, and quote a current executable book for the actual stake. The submitted order price must remain within the returned limit; fills may be lower. Fees are separate, and this grant does not guarantee liquidity, execution or positive expected value.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PotdEntryAuthorization {
    pub version: i64,
    pub authorization_id: String,
    /// Identifier for the policy recorded with this authorization. It does not replace the returned max_entry_price or expires_at. Existing grants retain their recorded values.
    pub policy_version: i64,
    pub condition_id: String,
    pub token_id: String,
    pub outcome_index: i64,
    /// Canonical sport bucket, not display_category.
    pub category: String,
    /// Exact provider parent event ID, or provider event ID when no parent exists.
    pub canonical_event_id: String,
    /// Maximum authorized order price as an exact decimal string, excluding fees. Quote a current executable book for the actual stake and keep the submitted order price at or below this bound. Actual fills may be lower; this limit does not guarantee a fill or define fair probability.
    pub max_entry_price: String,
    /// Selected-token best ask from the recorded reference book at issuance. This is a reference quote, not the authorized order-price limit; use max_entry_price for that limit.
    pub reference_best_ask: String,
    pub reference_book_hash: String,
    pub reference_book_at: String,
    pub issued_at: String,
    /// Authorization expiry timestamp. Existing grants do not extend; an expired authorization cannot authorize a new automated entry.
    pub expires_at: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PrepareWebhookSecretResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PriceProvenance {
    /// `gamma_outcome_prices`
    #[serde(rename = "gamma_outcome_prices")]
    GammaOutcomePrices,
    /// `clob_display`
    #[serde(rename = "clob_display")]
    ClobDisplay,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl PriceProvenance {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::GammaOutcomePrices => "gamma_outcome_prices",
            Self::ClobDisplay => "clob_display",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for PriceProvenance {
    fn from(value: &str) -> Self {
        match value {
            "gamma_outcome_prices" => Self::GammaOutcomePrices,
            "clob_display" => Self::ClobDisplay,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for PriceProvenance {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for PriceProvenance {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// One PUBLISHED same-day pick whose holder proof is not readable yet: its stable slot rank, the release and kickoff instants, and the instant before which a retry cannot succeed. Every item in `picks` carries its full required shape, so a pick that cannot meet it is listed here instead of being served with missing fields or a synthetic zero.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ProofPendingPickSlot {
    /// Deprecated compatibility daily release slot; use pick_id for identity and publication_order for scheduling.
    pub pick_rank: i64,
    /// The pick's stored release instant.
    pub release_at: String,
    /// The backed game's frozen kickoff instant; absent for a legacy row without one.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kickoff: Option<String>,
    /// Recommended next read: 30 seconds ahead while pre-game proof is warming, one hour ahead for a post-kickoff pending legacy row that only settlement can make readable. Schedule against it instead of polling.
    pub retry_at: String,
    /// Stable pick row identity as decimal text. Never use a quality rank as identity.
    pub pick_id: String,
    /// Compatibility release slot. No quality claim; historic scheduling order is retained.
    pub publication_order: i64,
    /// Viewer-independent free selection designation. New rows store it explicitly; historic null storage uses the original free slot.
    pub is_free_selection: bool,
    /// Deprecated (#24157): always null. No replacement lineage was ever recorded in this field; the key stays so existing V1 clients keep parsing. Identify a pick by pick_id.
    #[serde(default)]
    pub supersedes_pick_id: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ProviderReadSource {
    /// `cached`
    #[serde(rename = "cached")]
    Cached,
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ProviderReadSource {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Cached => "cached",
            Self::Live => "live",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ProviderReadSource {
    fn from(value: &str) -> Self {
        match value {
            "cached" => Self::Cached,
            "live" => Self::Live,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ProviderReadSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ProviderReadSource {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum RankingSource {
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `db_only`
    #[serde(rename = "db_only")]
    DbOnly,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl RankingSource {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Live => "live",
            Self::DbOnly => "db_only",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for RankingSource {
    fn from(value: &str) -> Self {
        match value {
            "live" => Self::Live,
            "db_only" => Self::DbOnly,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for RankingSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for RankingSource {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Reason {
    /// `outcome_prices_missing`
    #[serde(rename = "outcome_prices_missing")]
    OutcomePricesMissing,
    /// `outcome_price_leg_missing`
    #[serde(rename = "outcome_price_leg_missing")]
    OutcomePriceLegMissing,
    /// `zero_price_sentinel`
    #[serde(rename = "zero_price_sentinel")]
    ZeroPriceSentinel,
    /// `display_price_pair_unavailable`
    #[serde(rename = "display_price_pair_unavailable")]
    DisplayPricePairUnavailable,
    /// `outcome_identity_unavailable`
    #[serde(rename = "outcome_identity_unavailable")]
    OutcomeIdentityUnavailable,
    /// `final_score_unavailable`
    #[serde(rename = "final_score_unavailable")]
    FinalScoreUnavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Reason {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::OutcomePricesMissing => "outcome_prices_missing",
            Self::OutcomePriceLegMissing => "outcome_price_leg_missing",
            Self::ZeroPriceSentinel => "zero_price_sentinel",
            Self::DisplayPricePairUnavailable => "display_price_pair_unavailable",
            Self::OutcomeIdentityUnavailable => "outcome_identity_unavailable",
            Self::FinalScoreUnavailable => "final_score_unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Reason {
    fn from(value: &str) -> Self {
        match value {
            "outcome_prices_missing" => Self::OutcomePricesMissing,
            "outcome_price_leg_missing" => Self::OutcomePriceLegMissing,
            "zero_price_sentinel" => Self::ZeroPriceSentinel,
            "display_price_pair_unavailable" => Self::DisplayPricePairUnavailable,
            "outcome_identity_unavailable" => Self::OutcomeIdentityUnavailable,
            "final_score_unavailable" => Self::FinalScoreUnavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Reason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Reason {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RedeliverWebhookDeliveryResponse {
    pub object: String,
    pub data: WebhookDelivery,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RegisterAgentResponse {
    pub object: String,
    pub data: AgentRegistration,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReportPayload {
    /// Canonical key since #16304; total_whale_trades is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub total_large_trades: Option<i64>,
    #[serde(default)]
    pub total_whale_trades: Option<i64>,
    /// Canonical key since #16304; total_whale_volume is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub total_large_trade_volume: Option<f64>,
    #[serde(default)]
    pub total_whale_volume: Option<f64>,
    #[serde(default)]
    pub biggest_trade_size: Option<f64>,
    #[serde(default)]
    pub active_traders: Option<i64>,
    /// Canonical key since #16304; top_whale_trades is its deprecated spelling, emitted beside it with the same value.
    #[serde(default)]
    pub top_large_trades: Option<Vec<ReportPayloadTopLargeTradesItem>>,
    #[serde(default)]
    pub top_whale_trades: Option<Vec<ReportPayloadTopWhaleTradesItem>>,
    #[serde(default)]
    pub categories: Option<Vec<serde_json::Map<String, serde_json::Value>>>,
    /// Counts of current grades for distinct Polymarket traders with at least one whale alert in the report's source date range. The grade is the current projection at snapshot materialization time, not a historical grade at trade time. Traders without a current ranking projection are omitted; a null grade entry means the active trader's current grade is unavailable.
    #[serde(default)]
    pub grade_distribution: Option<Vec<serde_json::Map<String, serde_json::Value>>>,
    /// Which markets the report counts. sports_and_esports for a period that ends on or after 2026-10-21: totals, categories, top trades and the grade cohort cover sports and esports markets only. all_markets for an earlier period, whose stored report keeps every Polymarket market it published.
    pub market_scope: MarketScope,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReportPayloadTopLargeTradesItem {
    /// Provider outcome label for the traded side.
    #[serde(default)]
    pub outcome: Option<String>,
    /// Trade direction (BUY or SELL), not the outcome side.
    #[serde(default)]
    pub side: Option<String>,
    /// Market title.
    #[serde(default)]
    pub title: Option<String>,
    /// Trade size in USD.
    #[serde(default)]
    pub size: Option<f64>,
    /// Trade price in provider [0, 1] units.
    #[serde(default)]
    pub price: Option<f64>,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the traded outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Whale trade id.
    #[serde(default)]
    pub id: Option<i64>,
    /// Trade timestamp (UTC).
    #[serde(default)]
    pub trade_time: Option<String>,
    /// Provider market category.
    #[serde(default)]
    pub market_category: Option<String>,
    /// Always polymarket, or null when the row carries no stored value.
    #[serde(default)]
    pub platform: Option<String>,
    /// Trader display name, when known.
    #[serde(default)]
    pub name: Option<String>,
    /// Trader pseudonym, when no display name is known.
    #[serde(default)]
    pub pseudonym: Option<String>,
    /// Trader grade (S-F) at snapshot time.
    #[serde(default)]
    pub trader_grade: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReportPayloadTopWhaleTradesItem {
    /// Provider outcome label for the traded side.
    #[serde(default)]
    pub outcome: Option<String>,
    /// Trade direction (BUY or SELL), not the outcome side.
    #[serde(default)]
    pub side: Option<String>,
    /// Market title.
    #[serde(default)]
    pub title: Option<String>,
    /// Trade size in USD.
    #[serde(default)]
    pub size: Option<f64>,
    /// Trade price in provider [0, 1] units.
    #[serde(default)]
    pub price: Option<f64>,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the traded outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Whale trade id.
    #[serde(default)]
    pub id: Option<i64>,
    /// Trade timestamp (UTC).
    #[serde(default)]
    pub trade_time: Option<String>,
    /// Provider market category.
    #[serde(default)]
    pub market_category: Option<String>,
    /// Always polymarket, or null when the row carries no stored value.
    #[serde(default)]
    pub platform: Option<String>,
    /// Trader display name, when known.
    #[serde(default)]
    pub name: Option<String>,
    /// Trader pseudonym, when no display name is known.
    #[serde(default)]
    pub pseudonym: Option<String>,
    /// Trader grade (S-F) at snapshot time.
    #[serde(default)]
    pub trader_grade: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReportReconciliation {
    pub volume_kind: String,
    /// Where the whale volume in this report is read from: the column name `whale_alerts.usdc_notional_num`, followed in parentheses by the reconciliation note the server attaches to it. The server has always sent the note with the name, so this is not a bare constant; match on the prefix, not the whole string.
    pub whale_volume_source: String,
    pub notes: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReportSnapshot {
    pub kind: Granularity,
    pub generated_at: String,
    pub source_range: ReportSourceRange,
    pub snapshot: SnapshotState,
    pub completeness: SnapshotCompleteness,
    pub reconciliation: ReportReconciliation,
    pub report: ReportPayload,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReportSourceRange {
    pub start_date: String,
    pub end_date: String,
    pub timezone: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum RequiredTier {
    /// `account`
    #[serde(rename = "account")]
    Account,
    /// `insider`
    #[serde(rename = "insider")]
    Insider,
    /// `max`
    #[serde(rename = "max")]
    Max,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl RequiredTier {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Account => "account",
            Self::Insider => "insider",
            Self::Max => "max",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for RequiredTier {
    fn from(value: &str) -> Self {
        match value {
            "account" => Self::Account,
            "insider" => Self::Insider,
            "max" => Self::Max,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for RequiredTier {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for RequiredTier {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Resolution {
    /// `1d`
    #[serde(rename = "1d")]
    V1d,
    /// `1w`
    #[serde(rename = "1w")]
    V1w,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Resolution {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::V1d => "1d",
            Self::V1w => "1w",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Resolution {
    fn from(value: &str) -> Self {
        match value {
            "1d" => Self::V1d,
            "1w" => Self::V1w,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Resolution {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Resolution {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ResponseMeta {
    /// Unique request ID (req_ prefix). The same value as the X-Request-Id response header, the request's usage accounting row and its log lines.
    pub request_id: String,
    pub cached: bool,
    /// Cache age in seconds. Omitted when the response was not cached, and also when it was cached but its age cannot be established (an entry stored before its cache carried a computed instant). Never a placeholder: an unknown age is reported as no value rather than as the cache TTL.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cache_age_s: Option<i64>,
    /// Advisory request weight (relative compute cost). 1 for simple reads; higher for heavier endpoints. Not a credit/price.
    pub cost: i64,
    /// Committed PostgreSQL-owned leaderboard generation for the returned rows and cursor. Present on GET /api/v1/leaderboard; omitted on endpoints that do not read this ranking.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ranking_generation: Option<i64>,
    /// Authoritative RFC3339 timestamp from cache_generations.updated_at for ranking_generation. It is read in the same repeatable-read snapshot as the leaderboard rows and is not request time, cache write time, or row insertion order.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ranking_as_of: Option<String>,
    /// Directional evidence provenance for Edge Hunter signals collections. The default board carries this provenance in data.directional_source and omits this optional meta field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub directional_source: Option<DirectionalSource>,
    /// Ranking evidence provenance for Edge Hunter signals collections. The default board carries this clock/provenance in data.ranking_source and omits this optional meta field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ranking_source: Option<RankingSource>,
    /// Whole filtered snapshot category-evidence status before pagination. Operational live always remains partial source coverage.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_source: Option<CategorySkillSource>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_model_version: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_taxonomy_version: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_platform: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_scope: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_source_coverage: Option<SourceCoverage>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_observation_started_at: Option<String>,
    /// Whole-model operational readiness captured with the category model snapshot. Present on category-enriched responses even when the filtered signal list is empty. When true, category_skill_source is degraded and Edge Hunter signals uses the shorter degraded cache TTL.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_model_operationally_degraded: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_status_counts: Option<ResponseMetaCategorySkillStatusCounts>,
    /// SHA-256 of the funded signal membership/order/rank/cursor vector immediately before category-skill enrichment. Edge Hunter signals view only.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_base_payload_hash: Option<String>,
    /// Independent SHA-256 recomputation over the same base fields immediately after category-skill enrichment. Equality with category_skill_base_payload_hash proves category-skill enrichment did not change funded inputs. Edge Hunter signals view only.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_enriched_base_payload_hash: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ResponseMetaCategorySkillStatusCounts {
    pub live: i64,
    pub insufficient: i64,
    pub stale: i64,
    pub unknown: i64,
    pub degraded: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RetireWebhookSecretResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum RetryScheduleReason {
    /// `receiver_retry_after`
    #[serde(rename = "receiver_retry_after")]
    ReceiverRetryAfter,
    /// `transient_failure`
    #[serde(rename = "transient_failure")]
    TransientFailure,
    /// `permanent_or_auth_failure`
    #[serde(rename = "permanent_or_auth_failure")]
    PermanentOrAuthFailure,
    /// `manual_redelivery`
    #[serde(rename = "manual_redelivery")]
    ManualRedelivery,
    /// `configuration_changed`
    #[serde(rename = "configuration_changed")]
    ConfigurationChanged,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl RetryScheduleReason {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::ReceiverRetryAfter => "receiver_retry_after",
            Self::TransientFailure => "transient_failure",
            Self::PermanentOrAuthFailure => "permanent_or_auth_failure",
            Self::ManualRedelivery => "manual_redelivery",
            Self::ConfigurationChanged => "configuration_changed",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for RetryScheduleReason {
    fn from(value: &str) -> Self {
        match value {
            "receiver_retry_after" => Self::ReceiverRetryAfter,
            "transient_failure" => Self::TransientFailure,
            "permanent_or_auth_failure" => Self::PermanentOrAuthFailure,
            "manual_redelivery" => Self::ManualRedelivery,
            "configuration_changed" => Self::ConfigurationChanged,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for RetryScheduleReason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for RetryScheduleReason {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RotateWebhookSecretResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

/// An entitled same-day slot with a future scheduled release: stable identity and backend-owned release/kickoff instants. It leaves this list at its release instant; an unpublished slot is never a delayed recommendation. No matchup, category, platform, side, price, or holder fields appear before release. Unauthorized scheduled ranks appear only in locked_picks.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ScheduledPickSlot {
    /// Deprecated compatibility daily release slot; use pick_id for identity and publication_order for scheduling.
    pub pick_rank: i64,
    /// The slot's future release instant. Remove this preview at that instant and read again for published picks; a scheduled slot does not guarantee publication.
    pub release_at: String,
    /// The backed game's current kickoff instant.
    pub kickoff: String,
    /// Stable pick row identity as decimal text. Never use a quality rank as identity.
    pub pick_id: String,
    /// Compatibility release slot. No quality claim; historic scheduling order is retained.
    pub publication_order: i64,
    /// Viewer-independent free selection designation. New rows store it explicitly; historic null storage uses the original free slot.
    pub is_free_selection: bool,
    /// Deprecated (#24157): always null. No replacement lineage was ever recorded in this field; the key stays so existing V1 clients keep parsing. Identify a pick by pick_id.
    #[serde(default)]
    pub supersedes_pick_id: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SchemaVersion {
    /// `trader-export-json-v1`
    #[serde(rename = "trader-export-json-v1")]
    TraderExportJsonV1,
    /// `trader-export-ndjson-v1`
    #[serde(rename = "trader-export-ndjson-v1")]
    TraderExportNdjsonV1,
    /// `trader-export-csv-v1`
    #[serde(rename = "trader-export-csv-v1")]
    TraderExportCsvV1,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SchemaVersion {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::TraderExportJsonV1 => "trader-export-json-v1",
            Self::TraderExportNdjsonV1 => "trader-export-ndjson-v1",
            Self::TraderExportCsvV1 => "trader-export-csv-v1",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SchemaVersion {
    fn from(value: &str) -> Self {
        match value {
            "trader-export-json-v1" => Self::TraderExportJsonV1,
            "trader-export-ndjson-v1" => Self::TraderExportNdjsonV1,
            "trader-export-csv-v1" => Self::TraderExportCsvV1,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SchemaVersion {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SchemaVersion {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// One side's score in a single set. The verbatim provider text stays on the team's `score` string; this is the parsed form.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ScoreCell {
    /// Games won in this set.
    pub games: i64,
    /// Tiebreak points won in this set. Omitted when the set had no tiebreak; absence and zero are different.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tiebreak: Option<i64>,
}

/// Shape the provider score string was parsed into. `two_side` is one aggregate per side (basketball `105-98`), `multi_set` is per-set columns (tennis `6-7(5-7), 6-0, 1-0`), `esports_series` is a maps/sets/format triplet (`000-000|2-0|Bo3`). Omitted when the score could not be parsed.
///
/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ScoreFormat {
    /// `two_side`
    #[serde(rename = "two_side")]
    TwoSide,
    /// `multi_set`
    #[serde(rename = "multi_set")]
    MultiSet,
    /// `esports_series`
    #[serde(rename = "esports_series")]
    EsportsSeries,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ScoreFormat {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::TwoSide => "two_side",
            Self::MultiSet => "multi_set",
            Self::EsportsSeries => "esports_series",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ScoreFormat {
    fn from(value: &str) -> Self {
        match value {
            "two_side" => Self::TwoSide,
            "multi_set" => Self::MultiSet,
            "esports_series" => Self::EsportsSeries,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ScoreFormat {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ScoreFormat {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SearchContentResponse {
    pub object: String,
    pub data: Vec<ContentSearchResult>,
    pub has_more: bool,
    /// Omitted because content search is a bounded one-page result.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Absent because content search is a bounded relevance result and does not run a count query.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SearchMarketsResponse {
    pub object: String,
    pub data: Vec<MarketSearchResult>,
    pub has_more: bool,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub next_cursor: Option<String>,
    /// Total matching rows when the read model exposes a count; the key is absent when it does not.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SearchMarketsStatus {
    /// `active`
    #[serde(rename = "active")]
    Active,
    /// `closed`
    #[serde(rename = "closed")]
    Closed,
    /// `all`
    #[serde(rename = "all")]
    All,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SearchMarketsStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Closed => "closed",
            Self::All => "all",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SearchMarketsStatus {
    fn from(value: &str) -> Self {
        match value {
            "active" => Self::Active,
            "closed" => Self::Closed,
            "all" => Self::All,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SearchMarketsStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SearchMarketsStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Sections {
    /// `entries`
    #[serde(rename = "entries")]
    Entries,
    /// `stats`
    #[serde(rename = "stats")]
    Stats,
    /// `monthly`
    #[serde(rename = "monthly")]
    Monthly,
    /// `year_totals`
    #[serde(rename = "year_totals")]
    YearTotals,
    /// `drawdown`
    #[serde(rename = "drawdown")]
    Drawdown,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Sections {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Entries => "entries",
            Self::Stats => "stats",
            Self::Monthly => "monthly",
            Self::YearTotals => "year_totals",
            Self::Drawdown => "drawdown",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Sections {
    fn from(value: &str) -> Self {
        match value {
            "entries" => Self::Entries,
            "stats" => Self::Stats,
            "monthly" => Self::Monthly,
            "year_totals" => Self::YearTotals,
            "drawdown" => Self::Drawdown,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Sections {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Sections {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ServingSide {
    /// `first`
    #[serde(rename = "first")]
    First,
    /// `second`
    #[serde(rename = "second")]
    Second,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl ServingSide {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::First => "first",
            Self::Second => "second",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for ServingSide {
    fn from(value: &str) -> Self {
        match value {
            "first" => Self::First,
            "second" => Self::Second,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for ServingSide {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for ServingSide {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Severity {
    /// `flag`
    #[serde(rename = "flag")]
    Flag,
    /// `watch`
    #[serde(rename = "watch")]
    Watch,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Severity {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Flag => "flag",
            Self::Watch => "watch",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Severity {
    fn from(value: &str) -> Self {
        match value {
            "flag" => Self::Flag,
            "watch" => Self::Watch,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Severity {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Severity {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// `sharp_money_flow_detected` data (Pro and Max): ranked-trader net flow on a market crossed the threshold. The deprecated spelling `smart_money_flow_detected` delivers the same object.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SharpMoneyFlowDetectedData {
    /// Polymarket condition id of the market.
    pub condition_id: String,
    /// Signed ranked-trader net flow in USD over `window`: positive is net into YES, negative net into NO.
    pub net_flow_usd: f64,
    /// Absolute value of `net_flow_usd`, the magnitude compared with the threshold.
    pub abs_net_flow_usd: f64,
    /// `yes` when `net_flow_usd` is 0 or more, else `no`.
    pub dominant_side: Side,
    /// Minimum trader grade included in the flow.
    pub grade_floor: Grade,
    /// Ranked-trader large fills that make up the flow.
    pub whale_trade_count: i64,
    /// Window the flow was aggregated over, for example `24h`.
    pub window: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Side {
    /// `yes`
    #[serde(rename = "yes")]
    Yes,
    /// `no`
    #[serde(rename = "no")]
    No,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Side {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Yes => "yes",
            Self::No => "no",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Side {
    fn from(value: &str) -> Self {
        match value {
            "yes" => Self::Yes,
            "no" => Self::No,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Side {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Side {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SmartMoneyFlowMarket {
    pub market: SmartMoneyFlowMarketMarket,
    /// Sharp-money flow aggregate for the market (canonical; smart_money is a deprecated byte-identical alias).
    pub sharp_money: SmartMoneyFlowMarketSharpMoney,
    /// Deprecated alias of sharp_money; byte-identical and retained for backward compatibility.
    pub smart_money: SmartMoneyFlowMarketSmartMoney,
    pub timeframe: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SmartMoneyFlowMarketMarket {
    pub id: String,
    pub condition_id: String,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub slug: Option<String>,
    #[serde(default)]
    pub category: Option<String>,
    /// Provider platform. Always polymarket, or null when the row carries no stored value.
    #[serde(default)]
    pub platform: Option<String>,
}

/// Sharp-money flow aggregate for the market (canonical; smart_money is a deprecated byte-identical alias).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SmartMoneyFlowMarketSharpMoney {
    pub net_flow_usd: f64,
    pub direction: Direction,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the net-flow direction outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value.
    pub large_trade_count: i64,
    pub whale_trade_count: i64,
    pub buy_volume_usd: f64,
    pub sell_volume_usd: f64,
}

/// Deprecated alias of sharp_money; byte-identical and retained for backward compatibility.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SmartMoneyFlowMarketSmartMoney {
    pub net_flow_usd: f64,
    pub direction: Direction,
    /// The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the net-flow direction outcome; null when unavailable (e.g. unsynced markets).
    #[serde(default)]
    pub token_id: Option<String>,
    /// Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value.
    pub large_trade_count: i64,
    pub whale_trade_count: i64,
    pub buy_volume_usd: f64,
    pub sell_volume_usd: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SnapshotCompleteness {
    /// complete only on a final body (snapshot.status final). partial for a live range and for a closed range whose body was read before final_after; reason says which. empty when the range has no whale activity.
    pub status: SnapshotCompletenessStatus,
    pub reason: String,
    pub expected_days: i64,
    /// Canonical key since #16304; covered_days_with_whale_activity is its deprecated spelling, emitted beside it with the same value.
    pub covered_days_with_large_trade_activity: i64,
    pub covered_days_with_whale_activity: i64,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SnapshotCompletenessStatus {
    /// `complete`
    #[serde(rename = "complete")]
    Complete,
    /// `partial`
    #[serde(rename = "partial")]
    Partial,
    /// `empty`
    #[serde(rename = "empty")]
    Empty,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SnapshotCompletenessStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Complete => "complete",
            Self::Partial => "partial",
            Self::Empty => "empty",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SnapshotCompletenessStatus {
    fn from(value: &str) -> Self {
        match value {
            "complete" => Self::Complete,
            "partial" => Self::Partial,
            "empty" => Self::Empty,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SnapshotCompletenessStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SnapshotCompletenessStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SnapshotState {
    /// Immutable content version for a durable report identity; 0 for an ephemeral explicit weekly from/to range.
    pub version: i64,
    /// durable for canonical daily, ISO-week, and monthly snapshot identities; ephemeral for explicit weekly from/to ranges, which are recomputed within a bounded 31-day window and never persisted.
    pub storage: Storage,
    /// final only for a body whose source read started at or after final_after (the UTC close of the range plus the whale-trade ingestion budget). rolling for a live range and for a closed range still inside that budget: such a body refreshes every five minutes, is rebuilt once after final_after, and is then frozen. Before 2026-09-22 a closed range read final from the calendar alone, even for a body built before the range ended (#16225).
    pub status: SnapshotStateStatus,
    pub generated_at: String,
    /// For a rolling body, the UTC date on which a final body can first be built (the date of final_after); null once final.
    #[serde(default)]
    pub mutable_until: Option<String>,
    /// Whether the source range has ended on the UTC calendar. Closing is not finality: a closed range is rolling until final_after.
    pub period_closed: bool,
    /// The instant a source read must start at or after to produce a final body: the range's UTC close plus 7,530 s, the whale-trade ingestion budget (p95 block lag gate plus the projection retry budget).
    pub final_after: String,
    /// When this body's source read started, the clock finality is judged on. null for a body stored before that clock was recorded.
    #[serde(default)]
    pub source_read_started_at: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SnapshotStateStatus {
    /// `final`
    #[serde(rename = "final")]
    Final,
    /// `rolling`
    #[serde(rename = "rolling")]
    Rolling,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SnapshotStateStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Final => "final",
            Self::Rolling => "rolling",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SnapshotStateStatus {
    fn from(value: &str) -> Self {
        match value {
            "final" => Self::Final,
            "rolling" => Self::Rolling,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SnapshotStateStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SnapshotStateStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Sort {
    /// `recent`
    #[serde(rename = "recent")]
    Recent,
    /// `market_volume_share`
    #[serde(rename = "market_volume_share")]
    MarketVolumeShare,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Sort {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Recent => "recent",
            Self::MarketVolumeShare => "market_volume_share",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Sort {
    fn from(value: &str) -> Self {
        match value {
            "recent" => Self::Recent,
            "market_volume_share" => Self::MarketVolumeShare,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Sort {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Sort {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Source {
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `upcoming`
    #[serde(rename = "upcoming")]
    Upcoming,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Source {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Live => "live",
            Self::Upcoming => "upcoming",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Source {
    fn from(value: &str) -> Self {
        match value {
            "live" => Self::Live,
            "upcoming" => Self::Upcoming,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Source {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Source {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SourceAvailability {
    /// `available`
    #[serde(rename = "available")]
    Available,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// `not_applicable`
    #[serde(rename = "not_applicable")]
    NotApplicable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SourceAvailability {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Available => "available",
            Self::Unavailable => "unavailable",
            Self::NotApplicable => "not_applicable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SourceAvailability {
    fn from(value: &str) -> Self {
        match value {
            "available" => Self::Available,
            "unavailable" => Self::Unavailable,
            "not_applicable" => Self::NotApplicable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SourceAvailability {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SourceAvailability {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SourceCoverage {
    /// `partial_whale_threshold_fills`
    #[serde(rename = "partial_whale_threshold_fills")]
    PartialWhaleThresholdFills,
    /// `graded_wallet_fills`
    #[serde(rename = "graded_wallet_fills")]
    GradedWalletFills,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SourceCoverage {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::PartialWhaleThresholdFills => "partial_whale_threshold_fills",
            Self::GradedWalletFills => "graded_wallet_fills",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SourceCoverage {
    fn from(value: &str) -> Self {
        match value {
            "partial_whale_threshold_fills" => Self::PartialWhaleThresholdFills,
            "graded_wallet_fills" => Self::GradedWalletFills,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SourceCoverage {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SourceCoverage {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SourceFreshness {
    /// `fresh`
    #[serde(rename = "fresh")]
    Fresh,
    /// `stale`
    #[serde(rename = "stale")]
    Stale,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// `not_applicable`
    #[serde(rename = "not_applicable")]
    NotApplicable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SourceFreshness {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Fresh => "fresh",
            Self::Stale => "stale",
            Self::Unknown => "unknown",
            Self::NotApplicable => "not_applicable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SourceFreshness {
    fn from(value: &str) -> Self {
        match value {
            "fresh" => Self::Fresh,
            "stale" => Self::Stale,
            "unknown" => Self::Unknown,
            "not_applicable" => Self::NotApplicable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SourceFreshness {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SourceFreshness {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SourceStatus {
    /// `ok`
    #[serde(rename = "ok")]
    Ok,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SourceStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Ok => "ok",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SourceStatus {
    fn from(value: &str) -> Self {
        match value {
            "ok" => Self::Ok,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SourceStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SourceStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum State {
    /// `scheduled`
    #[serde(rename = "scheduled")]
    Scheduled,
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `paused`
    #[serde(rename = "paused")]
    Paused,
    /// `ended`
    #[serde(rename = "ended")]
    Ended,
    /// `postponed`
    #[serde(rename = "postponed")]
    Postponed,
    /// `cancelled`
    #[serde(rename = "cancelled")]
    Cancelled,
    /// `suspended`
    #[serde(rename = "suspended")]
    Suspended,
    /// `delayed`
    #[serde(rename = "delayed")]
    Delayed,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl State {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Scheduled => "scheduled",
            Self::Live => "live",
            Self::Paused => "paused",
            Self::Ended => "ended",
            Self::Postponed => "postponed",
            Self::Cancelled => "cancelled",
            Self::Suspended => "suspended",
            Self::Delayed => "delayed",
            Self::Unknown => "unknown",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for State {
    fn from(value: &str) -> Self {
        match value {
            "scheduled" => Self::Scheduled,
            "live" => Self::Live,
            "paused" => Self::Paused,
            "ended" => Self::Ended,
            "postponed" => Self::Postponed,
            "cancelled" => Self::Cancelled,
            "suspended" => Self::Suspended,
            "delayed" => Self::Delayed,
            "unknown" => Self::Unknown,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for State {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for State {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Status {
    /// `live`
    #[serde(rename = "live")]
    Live,
    /// `insufficient`
    #[serde(rename = "insufficient")]
    Insufficient,
    /// `stale`
    #[serde(rename = "stale")]
    Stale,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// `degraded`
    #[serde(rename = "degraded")]
    Degraded,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Status {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Live => "live",
            Self::Insufficient => "insufficient",
            Self::Stale => "stale",
            Self::Unknown => "unknown",
            Self::Degraded => "degraded",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Status {
    fn from(value: &str) -> Self {
        match value {
            "live" => Self::Live,
            "insufficient" => Self::Insufficient,
            "stale" => Self::Stale,
            "unknown" => Self::Unknown,
            "degraded" => Self::Degraded,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Status {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Status {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Storage {
    /// `durable`
    #[serde(rename = "durable")]
    Durable,
    /// `ephemeral`
    #[serde(rename = "ephemeral")]
    Ephemeral,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Storage {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Durable => "durable",
            Self::Ephemeral => "ephemeral",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Storage {
    fn from(value: &str) -> Self {
        match value {
            "durable" => Self::Durable,
            "ephemeral" => Self::Ephemeral,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Storage {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Storage {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Strategy {
    /// `accumulator`
    #[serde(rename = "accumulator")]
    Accumulator,
    /// `algo_trader`
    #[serde(rename = "algo_trader")]
    AlgoTrader,
    /// `arbitrageur`
    #[serde(rename = "arbitrageur")]
    Arbitrageur,
    /// `category_focused`
    #[serde(rename = "category_focused")]
    CategoryFocused,
    /// `directional`
    #[serde(rename = "directional")]
    Directional,
    /// `diversified`
    #[serde(rename = "diversified")]
    Diversified,
    /// `event_driven`
    #[serde(rename = "event_driven")]
    EventDriven,
    /// `high_activity`
    #[serde(rename = "high_activity")]
    HighActivity,
    /// `market_maker`
    #[serde(rename = "market_maker")]
    MarketMaker,
    /// `mixed`
    #[serde(rename = "mixed")]
    Mixed,
    /// `momentum`
    #[serde(rename = "momentum")]
    Momentum,
    /// `scalper`
    #[serde(rename = "scalper")]
    Scalper,
    /// `speculator`
    #[serde(rename = "speculator")]
    Speculator,
    /// `swing_trader`
    #[serde(rename = "swing_trader")]
    SwingTrader,
    /// `two_sided`
    #[serde(rename = "two_sided")]
    TwoSided,
    /// `unclassified`
    #[serde(rename = "unclassified")]
    Unclassified,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Strategy {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Accumulator => "accumulator",
            Self::AlgoTrader => "algo_trader",
            Self::Arbitrageur => "arbitrageur",
            Self::CategoryFocused => "category_focused",
            Self::Directional => "directional",
            Self::Diversified => "diversified",
            Self::EventDriven => "event_driven",
            Self::HighActivity => "high_activity",
            Self::MarketMaker => "market_maker",
            Self::Mixed => "mixed",
            Self::Momentum => "momentum",
            Self::Scalper => "scalper",
            Self::Speculator => "speculator",
            Self::SwingTrader => "swing_trader",
            Self::TwoSided => "two_sided",
            Self::Unclassified => "unclassified",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Strategy {
    fn from(value: &str) -> Self {
        match value {
            "accumulator" => Self::Accumulator,
            "algo_trader" => Self::AlgoTrader,
            "arbitrageur" => Self::Arbitrageur,
            "category_focused" => Self::CategoryFocused,
            "directional" => Self::Directional,
            "diversified" => Self::Diversified,
            "event_driven" => Self::EventDriven,
            "high_activity" => Self::HighActivity,
            "market_maker" => Self::MarketMaker,
            "mixed" => Self::Mixed,
            "momentum" => Self::Momentum,
            "scalper" => Self::Scalper,
            "speculator" => Self::Speculator,
            "swing_trader" => Self::SwingTrader,
            "two_sided" => Self::TwoSided,
            "unclassified" => Self::Unclassified,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Strategy {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Strategy {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum StreakTier {
    /// `hot`
    #[serde(rename = "hot")]
    Hot,
    /// `rising`
    #[serde(rename = "rising")]
    Rising,
    /// `neutral`
    #[serde(rename = "neutral")]
    Neutral,
    /// `cooling`
    #[serde(rename = "cooling")]
    Cooling,
    /// `cold`
    #[serde(rename = "cold")]
    Cold,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl StreakTier {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Hot => "hot",
            Self::Rising => "rising",
            Self::Neutral => "neutral",
            Self::Cooling => "cooling",
            Self::Cold => "cold",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for StreakTier {
    fn from(value: &str) -> Self {
        match value {
            "hot" => Self::Hot,
            "rising" => Self::Rising,
            "neutral" => Self::Neutral,
            "cooling" => Self::Cooling,
            "cold" => Self::Cold,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for StreakTier {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for StreakTier {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SubmitWhaleDatasetBody {
    pub from: String,
    pub to: String,
    /// Raw provider condition id or mkt_-prefixed id.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub condition_id: Option<String>,
    /// USD minimum, normalized to cents like replay.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub min_size: Option<f64>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SuspicionTrack {
    /// `whale`
    #[serde(rename = "whale")]
    Whale,
    /// `fresh_conviction`
    #[serde(rename = "fresh_conviction")]
    FreshConviction,
    /// `sliced_position`
    #[serde(rename = "sliced_position")]
    SlicedPosition,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl SuspicionTrack {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Whale => "whale",
            Self::FreshConviction => "fresh_conviction",
            Self::SlicedPosition => "sliced_position",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for SuspicionTrack {
    fn from(value: &str) -> Self {
        match value {
            "whale" => Self::Whale,
            "fresh_conviction" => Self::FreshConviction,
            "sliced_position" => Self::SlicedPosition,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for SuspicionTrack {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SuspicionTrack {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SuspiciousTrade {
    /// Prefixed ID (rf_...).
    pub id: String,
    /// Stored score that met the live flag threshold.
    pub suspicion_score: f64,
    /// The live scorer persists one threshold class.
    pub severity: String,
    pub trader: SuspiciousTradeTrader,
    pub market: SuspiciousTradeMarket,
    pub scores: SuspiciousTradeScores,
    /// Stored whale_alerts.suspicion_signals JSON from the scorer.
    pub evidence: serde_json::Value,
    /// Stored trade timestamp.
    pub created_at: String,
}

/// `suspicious_trade_flagged` data (Pro and Max): a trade's suspicion score crossed the flag threshold for the first time. The deprecated spelling `insider_radar_flag_raised` delivers the same object.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SuspiciousTradeFlaggedData {
    /// Numeric id of the flagged trade, a JSON number. It is the `id` that `GET /api/v1/large-trades/{id}` accepts.
    pub trade_id: i64,
    /// Address of the wallet that made the trade.
    pub wallet: String,
    /// 0xinsider's numeric id for the wallet.
    pub trader_id: i64,
    /// Polymarket condition id of the market.
    pub condition_id: String,
    /// The suspicion score, 0 to 100, that crossed the threshold.
    pub suspicion_score: f64,
    /// The scoring track that raised the flag.
    pub track: SuspicionTrack,
    /// Outcome side the flagged fill took.
    pub side: Side,
    /// Share count of the flagged fill.
    pub size: f64,
    /// Fill price of the flagged trade.
    pub price: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SuspiciousTradeMarket {
    pub id: String,
    pub condition_id: String,
    /// Canonical market question when available.
    #[serde(default)]
    pub title: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SuspiciousTradeScores {
    /// Null because the live scorer does not record this component.
    #[serde(default)]
    pub timing: Option<f64>,
    /// Null because the live scorer does not record this component.
    #[serde(default)]
    pub edge: Option<f64>,
    /// Numeric evidence.size when recorded; otherwise null.
    #[serde(default)]
    pub size: Option<f64>,
    /// Numeric evidence.fresh when recorded; otherwise null.
    #[serde(default)]
    pub fresh_wallet: Option<f64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SuspiciousTradeTrader {
    pub id: String,
    pub address: String,
    #[serde(default)]
    pub username: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Sweep {
    /// `win`
    #[serde(rename = "win")]
    Win,
    /// `loss`
    #[serde(rename = "loss")]
    Loss,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Sweep {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Win => "win",
            Self::Loss => "loss",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Sweep {
    fn from(value: &str) -> Self {
        match value {
            "win" => Self::Win,
            "loss" => Self::Loss,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Sweep {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Sweep {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Optional current-game tennis facts from API-Tennis, aligned with live_score.scores display order. These facts have their own revision and expiry; Polymarket remains the source of sets, match status, period, and the outer live-score revision. New observations require corroborated identity, current set/games, and live state. Cached responses and replayed frames may still carry expired facts, so clients must enforce expires_at.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TennisPoints {
    pub source: String,
    /// API-Tennis match ID. This is not a Polymarket market or event ID.
    pub match_key: i64,
    /// API-Tennis player IDs in the same first/second order as live_score.scores. These are not Polymarket team IDs.
    pub player_keys: Vec<i64>,
    /// Current-game point values in first/second order. Read strings, including A for advantage and numeric tiebreak points. Missing points are not zero.
    pub points: Vec<String>,
    /// The serving player in live_score.scores display order. Omitted when API-Tennis does not identify the server.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub serving_side: Option<ServingSide>,
    /// Orders only the tennis_points group for the same match. Never compare this with live_score.source_revision.
    pub source_revision: i64,
    /// When 0xinsider observed these API-Tennis facts. This is not a timestamp from the court.
    pub observed_at: String,
    /// Stop displaying the point group at this instant, even if the enclosing score remains fresh. The group expires 30 seconds after observed_at.
    pub expires_at: String,
    /// Current set number. Display points only while this matches the enclosing scoreboard.
    pub set_number: i64,
    /// Current-set games in first/second order. Display points only while these match the enclosing scoreboard.
    pub games: Vec<i64>,
}

/// A provider-reported ATP/WTA singles rank with independent retrieval and expiry clocks. API-Tennis provides no ranking publication date. Retrieval time does not establish when the tour published the ranking.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TennisRanking {
    /// Provider-reported singles rank.
    pub rank: i64,
    /// The player ranking tour.
    pub tour: TennisRankingTour,
    /// The standings provider.
    pub source: String,
    /// Successful snapshot retrieval time in UTC, not ranking publication date.
    pub observed_at: String,
    /// UTC deadline after which clients must hide this rank, including when an older game or pick response remains cached.
    pub expires_at: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TennisRankingTour {
    /// `atp`
    #[serde(rename = "atp")]
    Atp,
    /// `wta`
    #[serde(rename = "wta")]
    Wta,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl TennisRankingTour {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Atp => "atp",
            Self::Wta => "wta",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for TennisRankingTour {
    fn from(value: &str) -> Self {
        match value {
            "atp" => Self::Atp,
            "wta" => Self::Wta,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for TennisRankingTour {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for TennisRankingTour {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Timeframe {
    /// `1h`
    #[serde(rename = "1h")]
    V1h,
    /// `4h`
    #[serde(rename = "4h")]
    V4h,
    /// `24h`
    #[serde(rename = "24h")]
    V24h,
    /// `7d`
    #[serde(rename = "7d")]
    V7d,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Timeframe {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::V1h => "1h",
            Self::V4h => "4h",
            Self::V24h => "24h",
            Self::V7d => "7d",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Timeframe {
    fn from(value: &str) -> Self {
        match value {
            "1h" => Self::V1h,
            "4h" => Self::V4h,
            "24h" => Self::V24h,
            "7d" => Self::V7d,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Timeframe {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Timeframe {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Tour {
    /// `atp`
    #[serde(rename = "atp")]
    Atp,
    /// `wta`
    #[serde(rename = "wta")]
    Wta,
    /// `itf`
    #[serde(rename = "itf")]
    Itf,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Tour {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Atp => "atp",
            Self::Wta => "wta",
            Self::Itf => "itf",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Tour {
    fn from(value: &str) -> Self {
        match value {
            "atp" => Self::Atp,
            "wta" => Self::Wta,
            "itf" => Self::Itf,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Tour {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Tour {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Trader {
    /// Prefixed ID (trd_...).
    pub id: String,
    pub address: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grade: Option<Grade>,
    /// Hot-streak tier (trailing-7d cross-sectional percentile); a separate axis from the all-time grade. Omitted when there is no recent activity.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub streak_tier: Option<StreakTier>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub score: Option<f64>,
    /// Optional forecast score on the documented display scale. Null when unavailable.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub forecast_score: Option<f64>,
    /// Optional measured forecast context. Missing values remain unavailable rather than being inferred.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub forecast_evidence: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub rank: Option<i64>,
    pub pnl: TraderPnlSummary,
    pub stats: TraderStats,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub strategy: Option<TraderStrategy>,
    /// Per-category rank context when expand=categories is requested. Values include available rank, category totals, performance and record counts; scaled_total_pnl is a legacy alias of total_pnl. Its measurement basis and update timing differ from the plain record returned by GET /api/v1/trader/{address}/categories, so the two need not agree. Use this for rank context and that route for the plain record. The inner key-set is intentionally unconstrained and may contain additional compatibility fields.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_strengths: Option<serde_json::Map<String, serde_json::Value>>,
    /// Curated advanced risk/performance metrics (expand=quant_metrics or expand[]=quant_metrics). Omitted unless expanded and backed by a computed row strictly under six hours old; a missing row, NULL computed_at, or age of exactly six hours or more is stale and omitted. Provider-input changes may intentionally lag inside the bounded six-hour window. When present, all listed fields are present (each is a number or null); null means insufficient trade history and must not be treated as 0. The fixed field shape is unchanged.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub quant_metrics: Option<TraderQuantMetrics>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_active: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub synced_at: Option<String>,
    /// synced, unknown, or pending.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sync_status: Option<String>,
    /// Data age and coverage for this trader body. Always present. Its six groups are sync (traders.last_synced, covering pnl.net_total, pnl.realized, stats.markets_traded, stats.win_rate, stats.daily_win_rate, last_active, synced_at and sync_status), ranking (trader_rankings.computed_at, covering grade, score, streak_tier, forecast_score and forecast_evidence), leaderboard_rank (leaderboard_rank_refresh_state.completed_at, the completion time of the latest fully completed global rank refresh, covering rank), volume (trader_usd_volume.observed_at, covering stats.total_volume) and positions (trader_position_snapshots.last_refreshed_at with traders.last_synced as fallback, covering pnl.unrealized, the open-position aggregate) and leaderboard_pnl (trader_profile_provider_snapshots.observed_at, covering pnl.total: unavailable when Polymarket's all-time leaderboard has no current observation ranking the wallet). The positions clock is the latest successful /positions snapshot when one exists, otherwise the last completed trader sync; it does not date closed or native accounting values. A rank or position value remains unknown or unavailable when its clock or value is absent. For an unknown wallet every group is unavailable. If the open-position read itself fails, positions is unavailable with a reason that says so, pnl.unrealized is absent, and the body is answered fresh (meta.cached false) and is not kept for later callers.
    pub data_quality: DataQuality,
    /// Field-level trust metadata. Present only when expand=trust or expand[]=trust is requested.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub trust: Option<TraderTrust>,
    /// Current evidence for observed and known categories (expand=categories or expand[]=categories). Omitted unless expanded. Includes insufficient, stale, unknown and degraded rows; absence of a category is not proof of skill. The global grade is unchanged.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_records: Option<Vec<CategorySkillV2>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category_skill_model: Option<CategorySkillModelReadiness>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderCategoryRecord {
    /// Canonical category bucket, for example Soccer, Esports, Tennis. Esports is one bucket, and the Esports record carries its per-game records in games.
    pub category: String,
    /// Markets in this category the wallet closed with a profit.
    pub wins: i64,
    /// Markets it closed with a profit or a loss. A market that resolved at exactly zero P&L is in neither count, so this is not the wallet's market count in the category.
    pub decided: i64,
    /// wins / decided in [0,1], truncated to four decimals. Null when status is not_enough_data.
    #[serde(default)]
    pub win_rate: Option<f64>,
    /// measured: decided cleared min_decided_for_win_rate and win_rate carries the rate. not_enough_data: the counts are real but the sample is under the floor, so no percent is published. A failed read is an error response, never a status value.
    pub status: TraderEsportsGameRecordStatus,
    /// The wallet's record per esports title, busiest first. Present only on the Esports record, and only when the wallet has a settled market in at least one title; absent on every other category and on an Esports record whose markets are all in series that are not games (skin-price indices, streamer props) or carry no series. Absent means no per-game record, the same rule as an absent category. Each entry's decided is a subset of the Esports record's, read in the same statement from the same daily rebuild.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub games: Option<Vec<TraderEsportsGameRecord>>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderCategoryRecords {
    /// Prefixed trader id (trd_<wallet>).
    pub id: String,
    /// Resolved wallet address, lowercased.
    pub address: String,
    /// Which sample the counts come from: every settled market in the category, at any position size. category_strengths on the trader endpoint reads the floored calibration sample instead, so the two differ in both directions: measured on production 2026-09-22 over the 122,497 wallet-category pairs with at least 20 decided markets on both bases, the floored rate was higher in 56.5% of pairs and lower in 34.5%, median +0.6 points, p10 -4.6, p90 +9.8, with 14.0% of pairs 10 points apart or more. Neither corrects the other.
    pub basis: String,
    /// Decided markets a category needs before win_rate is served. Published so a caller can apply its own sample rule to the raw counts.
    pub min_decided_for_win_rate: i64,
    /// When the served records were last rebuilt (RFC3339, Z): the newest stamp among every row served, game rows included, which the daily rebuild writes in one transaction. Null when the wallet has no record at all.
    #[serde(default)]
    pub computed_at: Option<String>,
    /// One entry per canonical category with at least one decided market, ordered by decided descending then category. A category with no decided market is omitted. The Esports entry carries its per-game records in games.
    pub records: Vec<TraderCategoryRecord>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderContext {
    pub trader: Trader,
    /// Aggregate position and P&L coverage for the trader. Counts all Polymarket markets, not only sports and esports. Omitted entirely (key absent, never null) when the trader is not in the local database or native net economics is unavailable. Realized fields remain numbers when present, including a genuine zero.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub position_summary: Option<TraderContextPositionSummary>,
    /// RFC3339 freshness of the OPEN-position-level data: when a position_summary is present this mirrors its as_of byte-for-byte (latest /positions snapshot, else last completed sync) -- the open-position freshness clock, since the snapshot advances only open positions; otherwise the trader's last completed sync, even if an unserved position snapshot exists. Null when the selected clock is unavailable; a missing breakdown does not establish position or accounting freshness.
    #[serde(default)]
    pub data_as_of: Option<String>,
    /// Human-readable statement of the point-in-time snapshot semantics (data_as_of is the open-position clock -- the latest /positions snapshot, else the last completed sync; the snapshot advances only open positions, so resolved counts and win rate can include settled markets recorded after the last full sync; native realized P&L follows its accounting snapshot -- not a live feed; re-fetch for fresher data).
    pub freshness_note: String,
}

/// Aggregate position and P&L coverage for the trader. Counts all Polymarket markets, not only sports and esports. Omitted entirely (key absent, never null) when the trader is not in the local database or native net economics is unavailable. Realized fields remain numbers when present, including a genuine zero.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderContextPositionSummary {
    /// Provider markets_traded count when known; null when the provider total is unavailable.
    #[serde(default)]
    pub markets_total: Option<i64>,
    /// Markets with locally synced position rows.
    pub markets_synced: i64,
    /// Synced markets that have resolved.
    pub markets_resolved: i64,
    /// Synced markets still open with residual value (open positions with current value > 0).
    pub markets_open: i64,
    /// markets_synced divided by markets_total when the provider total is known (capped at 1.0); 0.0-1.0. When markets_total is unknown or not positive (null, 0, or negative), this is 1.0 if any markets are synced (else 0.0), so cross-check markets_total before treating 1.0 as full coverage.
    pub sync_coverage: f64,
    /// Native net realized P&L (USD) including credited rebates, minus the stored realized component of open positions with positive current value. Rebates are credited to the account, not to a position, so every credited rebate stays in this figure. NUMERIC arithmetic precedes conversion to a JSON number.
    pub synced_realized_pnl: f64,
    /// Native net realized P&L (USD) including credited rebates, read directly from the accounting snapshot. Position sync_coverage is separate from this accounting basis.
    pub total_realized_pnl: f64,
    /// Mark-to-market unrealized P&L (USD) on open positions.
    pub unrealized_mtm: f64,
    /// Cost basis (USD) currently tied up in open positions.
    pub cost_basis_locked: f64,
    /// Win rate as a percentage (0-100): resolved_wins over resolved_decided. A resolved market that settled at exactly zero realized P&L (a void, a refund, a fully hedged position) is neither a win nor a loss and is not in the denominator, the same rule the leaderboard applies; null when no resolved market was decided. It is the rule of trader.stats.win_rate, read from the synced rows at request time; stats.win_rate is the stored figure the profile shows, refreshed by each sync and a few minutes after a closed-history write. context.md prints one Market win rate: this one when position_summary is present, else stats.win_rate.
    #[serde(default)]
    pub resolved_win_rate: Option<f64>,
    /// Resolved markets that settled at positive realized P&L: the win-rate numerator. Additive; null only on a summary cached before the field existed.
    #[serde(default)]
    pub resolved_wins: Option<i64>,
    /// Resolved markets that settled at a non-zero realized P&L: the win-rate denominator. At most markets_resolved; the difference is markets settled at exactly zero or with an unknown P&L. Additive; null only on a summary cached before the field existed.
    #[serde(default)]
    pub resolved_decided: Option<i64>,
    /// RFC3339 freshness of the served OPEN-position data: the trader's latest /positions snapshot, else the last completed sync. The snapshot advances ONLY open positions, so read this as the open-position freshness clock -- the resolved/closed aggregates on this same summary (markets_resolved, resolved_win_rate) advance only on a full sync. The value is the /positions snapshot instant when one exists, so it is typically at or just before the trader-level last sync on a normal sync, and can be AFTER it while the active-view loop refreshes open positions between full syncs. This clock does not establish native accounting freshness. Always present on the wire (serialized as JSON null when the trader has neither a snapshot nor a sync); never omitted.
    #[serde(default)]
    pub as_of: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderEsportsGameRecord {
    /// The game, by the same name every holder chip carries in category_win_rate_game: LoL, CS2, Dota 2, Valorant, Call of Duty, Honor of Kings, Mobile Legends: Bang Bang, Overwatch, Rainbow Six Siege, Rocket League or StarCraft II. Match a chip to this row by string equality.
    pub game: String,
    /// The Polymarket series slug the record is keyed on: league-of-legends, counter-strike, dota-2, valorant, call-of-duty, honor-of-kings, mobile-legends-bang-bang, overwatch, rainbow-six-siege, rocket-league or starcraft-2. The stable key; game is the label.
    pub series_slug: String,
    /// Markets in this game the wallet closed with a profit.
    pub wins: i64,
    /// Markets in this game it closed with a profit or a loss. A subset of the parent Esports record's decided: the two are read from the same daily rebuild.
    pub decided: i64,
    /// wins / decided in [0,1], truncated to four decimals. Null when status is not_enough_data.
    #[serde(default)]
    pub win_rate: Option<f64>,
    /// The same rule as the parent record: measured when decided cleared min_decided_for_win_rate, not_enough_data when the counts are real but the sample is under the floor. A chip on a market in this game shows this row's rate when it is measured and the Esports bucket's otherwise.
    pub status: TraderEsportsGameRecordStatus,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TraderEsportsGameRecordStatus {
    /// `measured`
    #[serde(rename = "measured")]
    Measured,
    /// `not_enough_data`
    #[serde(rename = "not_enough_data")]
    NotEnoughData,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl TraderEsportsGameRecordStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Measured => "measured",
            Self::NotEnoughData => "not_enough_data",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for TraderEsportsGameRecordStatus {
    fn from(value: &str) -> Self {
        match value {
            "measured" => Self::Measured,
            "not_enough_data" => Self::NotEnoughData,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for TraderEsportsGameRecordStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for TraderEsportsGameRecordStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportArtifactManifest {
    /// Version of the artifact manifest contract.
    pub manifest_version: String,
    /// Serialization used for the decompressed content.
    pub format: Format,
    /// Stable schema identifier for the selected serialization.
    pub schema_version: SchemaVersion,
    /// Sections represented by the artifact. JSON and NDJSON carry the full envelope and trades; CSV carries trade rows only.
    pub coverage: Coverage,
    pub generation: TraderExportGeneration,
    /// Number of trade rows written.
    pub row_count: i64,
    /// Exact byte count of the decompressed content stream clients receive.
    pub content_size_bytes: i64,
    /// Lowercase SHA-256 of the decompressed content bytes.
    pub content_sha256: String,
    /// Exact byte count of the gzip-compressed bytes stored by the object provider.
    pub compressed_size_bytes: i64,
    /// Lowercase SHA-256 of the stored gzip bytes; the multipart ETag is not used as this checksum.
    pub compressed_sha256: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportCategoryWatermark {
    pub source: String,
    pub coverage: String,
    #[serde(default)]
    pub publication_fence: Option<String>,
    #[serde(default)]
    pub data_as_of: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportGeneration {
    /// Opaque generation identity selected for the coherent read snapshot.
    pub id: String,
    pub selected_at: String,
    pub consistency: String,
    pub source_watermarks: TraderExportSourceWatermarks,
    /// The markets the file's trades and markets sections hold: sports and esports markets only (export_metadata.scope_note in a JSON or NDJSON file names the sections that still cover every market). Absent on a file written before 2026-10-22, which holds every market; a submit never reuses such a file.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub product_scope: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportJob {
    pub object: String,
    pub data: TraderExportJobData,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportJobData {
    pub job_id: i64,
    /// queued: accepted, not started. running: the worker is streaming rows. reconcile_required: the upload finished but the storage completion answer was lost; the hourly reconciler reads the object back and moves the job to ready or failed, and expires_at bounds the wait. ready: downloadable until expires_at. failed: terminal; error says why; submit a new export. expired: the retention window passed; the file is retired, the download route answers 410, submit a new export. cancel_requested: the owner cancelled a running job (POST /api/v1/trader/{address}/export/cancel); the worker stops at its next safe point and the job reads cancelled. cancelled: terminal; the owner cancelled the job and no file was published; submit a new export. A job that has not reached ready by expires_at reads failed with error 'export expired before completion'. failed, cancelled and expired rows stay readable for 48 hours, then the job answers 404.
    pub status: TraderExportJobDataStatus,
    pub format: Format,
    /// Trade rows the file holds: trades in the wallet's sports and esports markets, counted in the file's own read snapshot. Null until the worker has read the snapshot (queued, and early in running); a job accepted before 2026-10-22 can carry the earlier all-markets estimate until its file is read.
    #[serde(default)]
    pub total_trades: Option<i64>,
    /// Trade rows written so far; equals total_trades once the file is read.
    #[serde(default)]
    pub processed_trades: Option<i64>,
    #[serde(default)]
    pub file_size: Option<i64>,
    #[serde(default)]
    pub error: Option<String>,
    /// True when status never changes again (ready, failed, expired, cancelled). Stop polling.
    pub terminal: bool,
    /// What to do next: poll the status route after poll_after_s, follow the download route, or submit a new export. Published beside status so a status value added later does not strand a client.
    pub next_action: NextAction,
    /// Seconds to wait before polling again. Absent when terminal. 5 while queued, running or cancel_requested; 300 while reconcile_required, the cadence that state can change at.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub poll_after_s: Option<i64>,
    pub created_at: String,
    /// When the worker last claimed the job; null while queued.
    #[serde(default)]
    pub started_at: Option<String>,
    /// When the file became downloadable. null before ready, and on jobs finalized before this field existed.
    #[serde(default)]
    pub ready_at: Option<String>,
    #[serde(default)]
    pub failed_at: Option<String>,
    /// The retention window: 24 hours from submit. A ready file downloads until this instant; a job that has not reached ready by it fails. A reused job (200 on submit) keeps its original window.
    pub expires_at: String,
    /// When the job became expired; null until then.
    #[serde(default)]
    pub expired_at: Option<String>,
    /// What the file is a snapshot of: the trader's served-data clock (the latest position refresh, else the last completed sync) when the file was written; the same value as export_metadata.data_as_of inside the file. null until the file is written, or when the trader had neither. Read this, not ready_at, to decide whether a reused job is fresh enough; submit with fresh=true for a newer snapshot.
    #[serde(default)]
    pub data_as_of: Option<String>,
    /// When the owner asked to cancel the job; null otherwise. Set on every cancelled job, including one cancelled while queued. While status is cancel_requested this is the instant the worker was asked to stop.
    #[serde(default)]
    pub cancel_requested_at: Option<String>,
    /// When the job reached cancelled; null until then.
    #[serde(default)]
    pub cancelled_at: Option<String>,
    /// Worker claims so far.
    pub attempt: i64,
    /// The job fails when attempt reaches this.
    pub max_attempts: i64,
    /// Present only while status is ready: the stored object's identity, so a client can check the download it receives.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub artifact: Option<TraderExportJobDataArtifact>,
}

/// Present only while status is ready: the stored object's identity, so a client can check the download it receives.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportJobDataArtifact {
    /// Stable identity for this completed export artifact; unchanged when a temporary download URL is renewed.
    pub artifact_id: String,
    /// The storage ETag of the object.
    #[serde(default)]
    pub etag: Option<String>,
    /// Bytes on the wire (gzip); file_size is the decompressed size.
    #[serde(default)]
    pub compressed_size_bytes: Option<i64>,
    pub content_type: ContentType,
    pub content_encoding: String,
    /// Immutable manifest for artifacts generated with manifest support; null on historical artifacts written before this contract.
    #[serde(default)]
    pub manifest: Option<TraderExportArtifactManifest>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TraderExportJobDataStatus {
    /// `queued`
    #[serde(rename = "queued")]
    Queued,
    /// `running`
    #[serde(rename = "running")]
    Running,
    /// `ready`
    #[serde(rename = "ready")]
    Ready,
    /// `failed`
    #[serde(rename = "failed")]
    Failed,
    /// `reconcile_required`
    #[serde(rename = "reconcile_required")]
    ReconcileRequired,
    /// `expired`
    #[serde(rename = "expired")]
    Expired,
    /// `cancel_requested`
    #[serde(rename = "cancel_requested")]
    CancelRequested,
    /// `cancelled`
    #[serde(rename = "cancelled")]
    Cancelled,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl TraderExportJobDataStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Queued => "queued",
            Self::Running => "running",
            Self::Ready => "ready",
            Self::Failed => "failed",
            Self::ReconcileRequired => "reconcile_required",
            Self::Expired => "expired",
            Self::CancelRequested => "cancel_requested",
            Self::Cancelled => "cancelled",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for TraderExportJobDataStatus {
    fn from(value: &str) -> Self {
        match value {
            "queued" => Self::Queued,
            "running" => Self::Running,
            "ready" => Self::Ready,
            "failed" => Self::Failed,
            "reconcile_required" => Self::ReconcileRequired,
            "expired" => Self::Expired,
            "cancel_requested" => Self::CancelRequested,
            "cancelled" => Self::Cancelled,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for TraderExportJobDataStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for TraderExportJobDataStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportPnlWatermark {
    pub source: String,
    pub coverage: String,
    #[serde(default)]
    pub revision: Option<i64>,
    #[serde(default)]
    pub observed_at: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportPositionWatermark {
    pub source: String,
    pub coverage: String,
    #[serde(default)]
    pub generation: Option<i64>,
    #[serde(default)]
    pub data_as_of: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportSnapshot {
    pub address: String,
    /// The markets the export file's trades and markets sections hold: sports and esports markets only. counts.exported_markets, counts.estimated_trade_rows, counts.estimated_size_mb, reconciliation.exported_market_cost_basis and source_range.latest_trade_at and latest_market_activity_at describe those markets. The pnl dates, pnl_days, exported_activity_volume and completeness cover every market of the wallet.
    pub product_scope: String,
    pub generated_at: String,
    pub source_range: ExportSourceRange,
    pub completeness: ExportCompleteness,
    pub reconciliation: ExportVolumeReconciliation,
    pub counts: ExportCounts,
    pub large_export_policy: LargeExportPolicy,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportSourceWatermarks {
    pub positions: TraderExportPositionWatermark,
    pub pnl: TraderExportPnlWatermark,
    pub categories: TraderExportCategoryWatermark,
    pub trades: TraderExportTradeWatermark,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderExportTradeWatermark {
    pub source: String,
    /// sports_esports_rows: the file holds every stored trade in the wallet's sports and esports markets. all_matching_rows on a file written before 2026-10-22, which holds every market's trades.
    pub coverage: String,
    /// Trade rows the file holds, counted in the same read snapshot as the rows.
    pub rows: i64,
    #[serde(default)]
    pub first_activity_date: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderGradeAt {
    /// Prefixed trader id (trd_<wallet>).
    pub id: String,
    /// Resolved wallet address, lowercased.
    pub address: String,
    /// Requested event or decision time.
    pub as_of: String,
    /// graded has a proven grade; ungraded is a proven null grade; unknown has no valid historical observation.
    pub status: GradeAtTradeStatus,
    /// Grade only when status is graded; null otherwise.
    #[serde(default)]
    pub grade: Option<Grade>,
    /// First proven visibility instant for this trader. Null when no observation exists. Earlier times remain unknown.
    #[serde(default)]
    pub available_from: Option<String>,
    /// Proof row when status is graded or ungraded. Null when history is unknown.
    #[serde(default)]
    pub observation: Option<TraderGradeAtObservation>,
}

/// Proof row when status is graded or ungraded. Null when history is unknown.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderGradeAtObservation {
    /// Immutable grade_forward_history observation id.
    pub id: i64,
    /// Previous immutable observation id when retained. A later grade change supersedes that observation but never erases it; this link does not assert why the grade changed.
    #[serde(default)]
    pub previous_observation_id: Option<i64>,
    /// Lower bound: the grade writer had started the transition at this instant.
    pub observed_at: String,
    /// Upper bound: a later snapshot confirmed the observation was committed. This is not an exact commit timestamp.
    pub published_by: String,
    /// Writer-proven model family, such as grading. Null when unknown.
    #[serde(default)]
    pub model_version: Option<String>,
    /// Exact writer build SHA when recorded. Null on old and non-model observations.
    #[serde(default)]
    pub model_build_sha: Option<String>,
    /// Database-clock upper bound on when the grading pass read its cohort inputs. Not the event time or source freshness of every input; null when unknown.
    #[serde(default)]
    pub source_observed_by: Option<String>,
}

/// A trader's daily P&L object. `id` is always present. The five sections -- `entries`, `stats`, `monthly`, `year_totals`, `drawdown` -- are present unless the request's `sections` parameter excluded them, so a request that sends no `sections` always carries all five. An excluded section is absent from the object, never null and never an empty array.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnl {
    /// Prefixed trader ID (`trd_...`).
    pub id: String,
    /// Representation parameters applied to this body. Present only when the request sent `from`, `to` or `sections`; omitted otherwise, which is what keeps a no-parameter response identical to the one this route served before the parameters existed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub view: Option<TraderPnlView>,
    /// RFC3339 served-freshness clock for this trader's PnL history = traders.daily_pnl_recomputed_at, when the daily_pnl read model this response is served from was last rebuilt; null when it has never been recomputed for the trader. Always present, so read it as a value that can be null rather than a key that can be missing.
    #[serde(default)]
    pub freshness_at: Option<String>,
    /// Daily cumulative-P&L series (oldest-first). Present unless the request's `sections` excluded it, and clipped to `from`/`to` when either is set. cumulative_profit and total_pnl stay cumulative from the start of the stored history, so a clipped slice keeps the same economic meaning; view.anchor carries the point before the window.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub entries: Option<Vec<TraderPnlEntriesItem>>,
    /// Pre-derived period stats. Present unless the request's `sections` excluded it. Always the published all/90d/30d/7d windows over the full stored history; `from`/`to` never recompute them over the request's range.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub stats: Option<TraderPnlStats>,
    /// Per-month P&L aggregation. Present unless the request's `sections` excluded it. Whole months over the full stored history, never clipped to `from`/`to`, so a month is never a partial month.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub monthly: Option<Vec<TraderPnlMonthlyItem>>,
    /// Per-year P&L totals (ascending by year). Present unless the request's `sections` excluded it. Whole years over the full stored history, never clipped to `from`/`to`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub year_totals: Option<Vec<TraderPnlYearTotalsItem>>,
    /// Underwater (drawdown) series. Present unless the request's `sections` excluded it, and clipped to `from`/`to` when either is set. The running peak behind each point is the full-history peak, so a clipped slice is not rebased; view.anchor.drawdown carries the value at the point before the window.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub drawdown: Option<Vec<TraderPnlDrawdownItem>>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlDrawdownItem {
    pub date: String,
    pub cumulative_profit: f64,
    pub drawdown: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlEntriesItem {
    pub date: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub markets_traded: Option<i64>,
    /// Cash in USD this wallet traded on this UTC day, buys and sells, summed from the fills 0xinsider has stored for it. Not Polymarket's share count, and not the full-history stats.total_volume on GET /api/v1/trader/{address}. Omitted, with markets_traded, on a day above 20 times the wallet's median day.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total_volume: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cumulative_profit: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total_pnl: Option<f64>,
    pub daily_change: f64,
}

/// Lossless counterparts for trader P&L values. The object is omitted when no trusted native realized-P&L snapshot is available.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlExact {
    /// Native Polymarket realized P&L plus credited maker and taker rebates, with fees included, from the trusted matching `trader_trading_pnl.net_realized_pnl` snapshot.
    pub realized: ExactDecimal,
}

/// A wallet's sports and esports record (#27311): Polymarket's published realized P&L (pnl.realized plus any published pnl.correction) split into the part earned on sports and esports markets. Fees, refunds and rebates stay in, apportioned by cost. A wallet wholly in sports keeps the published figure exactly; one with no sports market gets 0. Refreshed after each wallet sync; as_of dates it.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlInScope {
    /// Names the split rule, currently sports_esports_split_v1. A new value means the rule changed; compare figures only within one basis.
    pub basis: String,
    /// Sports and esports realized P&L in USD, display-safe. null when the wallet has no published realized figure to split.
    #[serde(default)]
    pub realized_pnl: Option<f64>,
    /// Sports and esports markets the wallet has traded, any status.
    pub markets: i64,
    /// Of those, the markets that have resolved.
    pub markets_resolved: i64,
    /// Share of decided sports and esports markets the wallet won, 0 to 1. null with no decided market.
    #[serde(default)]
    pub win_rate: Option<f64>,
    /// The wallet's markets outside sports and esports, which 0xinsider no longer lists.
    pub markets_out_of_scope: i64,
    /// When the record behind these figures was computed.
    pub as_of: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlMonthlyItem {
    pub year: i64,
    pub month: i64,
    pub pnl: f64,
    pub markets_traded: i64,
}

/// Pre-derived period stats. Present unless the request's `sections` excluded it. Always the published all/90d/30d/7d windows over the full stored history; `from`/`to` never recompute them over the request's range.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlStats {
    pub all: TraderPnlStatsAll,
    pub d90: TraderPnlStatsD90,
    pub d30: TraderPnlStatsD30,
    pub d7: TraderPnlStatsD7,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlStatsAll {
    pub current: f64,
    pub change: f64,
    pub change_pct: f64,
    pub best_day: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub best_day_date: Option<String>,
    pub worst_day: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub worst_day_date: Option<String>,
    pub win_days: i64,
    pub loss_days: i64,
    pub avg_day: f64,
    pub rebase_anchor: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlStatsD30 {
    pub current: f64,
    pub change: f64,
    pub change_pct: f64,
    pub best_day: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub best_day_date: Option<String>,
    pub worst_day: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub worst_day_date: Option<String>,
    pub win_days: i64,
    pub loss_days: i64,
    pub avg_day: f64,
    pub rebase_anchor: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlStatsD7 {
    pub current: f64,
    pub change: f64,
    pub change_pct: f64,
    pub best_day: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub best_day_date: Option<String>,
    pub worst_day: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub worst_day_date: Option<String>,
    pub win_days: i64,
    pub loss_days: i64,
    pub avg_day: f64,
    pub rebase_anchor: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlStatsD90 {
    pub current: f64,
    pub change: f64,
    pub change_pct: f64,
    pub best_day: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub best_day_date: Option<String>,
    pub worst_day: f64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub worst_day_date: Option<String>,
    pub win_days: i64,
    pub loss_days: i64,
    pub avg_day: f64,
    pub rebase_anchor: f64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlSummary {
    /// Polymarket's all-time leaderboard P&L in USD, from Polymarket's latest observation of this wallet on its all-time leaderboard (dated by the leaderboard_pnl data_quality group). Omitted when that leaderboard has no current observation ranking the wallet; 0xinsider requests one, and never serves an older stored figure in its place. Kept for provider parity and back-compat. Not the profile's Total P&L and not realized plus unrealized: it can differ from net_total by a wide margin. Read net_total for the figure the 0xinsider profile shows.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total: Option<f64>,
    /// Polymarket's net total P&L in USD: native Polymarket position P&L, with fees already included, plus credited maker and taker rebates (trader_trading_pnl.net_total_pnl). Truncated toward zero to cents before conversion to a JSON number. Omitted when the wallet has no native accounting snapshot; pnl.total is never substituted. The 0xinsider profile's Total P&L is this figure unless pnl.correction is present, then pnl.correction.net_total.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub net_total: Option<f64>,
    /// The 0xinsider correction to Polymarket's P&L for neg-risk conversions. Present only when one is published; pnl.net_total and pnl.realized keep Polymarket's own figures, and correction.net_total and correction.realized add the amount to them.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub correction: Option<PnlCorrection>,
    /// true while 0xinsider is still checking some of the wallet's converted neg-risk markets (not yet measured, measured and not yet checked for transfers, or its latest reads keep failing), so the correction may change, or arrive where none is published yet. Omitted otherwise.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub correction_pending: Option<bool>,
    /// For pnl.realized, expand=trust marks a matching native accounting snapshot as computed: native Polymarket realized P&L plus credited maker and taker rebates, with fees already included. The exact numeric value is truncated toward zero to cents before conversion to a JSON number. Without a matching native accounting snapshot, pnl.realized is omitted and its trust metadata is unavailable. Raw total P&L is never substituted for realized P&L.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub realized: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unrealized: Option<f64>,
    /// DEPRECATED, never sent. The local pnl_7d rollup over-counted P&L (#5416 class) and is no longer emitted. Read the provider-native weekly window from GET /api/trader/{address}/profile-summary instead.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_7d: Option<f64>,
    /// DEPRECATED, never sent. The local pnl_30d rollup over-counted P&L (#5416 class) and is no longer emitted. Read the provider-native monthly window from GET /api/trader/{address}/profile-summary instead.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_30d: Option<f64>,
    /// Additive lossless counterpart. Omitted when the trusted native realized-P&L source is unavailable; existing numeric fields keep their display-safe v1 semantics.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<TraderPnlExact>,
    /// Additive (#27311): the wallet's sports and esports record, the figure the 0xinsider profile headlines. Omitted until 0xinsider has computed the wallet's record; absent means not computed yet, never zero. The other pnl fields stay Polymarket's wallet-wide figures.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub in_scope: Option<TraderPnlInScope>,
}

/// Representation parameters applied to this body. Present only when the request sent `from`, `to` or `sections`; omitted otherwise, which is what keeps a no-parameter response identical to the one this route served before the parameters existed.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlView {
    /// Inclusive UTC lower bound applied to the daily series; null when the request left the series unbounded below.
    #[serde(default)]
    pub from: Option<String>,
    /// Inclusive UTC upper bound applied to the daily series; null when the request left the series unbounded above.
    #[serde(default)]
    pub to: Option<String>,
    /// Sections this body carries, in the order the object publishes them, whatever order the query listed.
    pub sections: Vec<Sections>,
    /// Points in the full stored daily series, before the window. Compare with entries_in_window to tell a clipped chart from a wallet that really has that many days.
    pub entries_total: i64,
    /// Points of the daily series inside the window. Equal to entries_total when no bound narrowed it, and reported whether or not entries was among the requested sections.
    pub entries_in_window: i64,
    /// The last daily point strictly before `from`: the cumulative baseline the window was cut away from. null when the request set no lower bound, or when the window starts at or before the first stored point and the slice already begins at the start of the history. Cumulative values in `entries` and `drawdown` are never rebased to the window, so this is the figure to subtract for a window-relative change.
    #[serde(default)]
    pub anchor: Option<TraderPnlViewAnchor>,
}

/// The last daily point strictly before `from`: the cumulative baseline the window was cut away from. null when the request set no lower bound, or when the window starts at or before the first stored point and the slice already begins at the start of the history. Cumulative values in `entries` and `drawdown` are never rebased to the window, so this is the figure to subtract for a window-relative change.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlViewAnchor {
    pub date: String,
    /// Cumulative profit carried into the window; null when the stored point has none, the same nullability entries[].cumulative_profit has.
    #[serde(default)]
    pub cumulative_profit: Option<f64>,
    /// Cumulative total P&L carried into the window; null on the same terms.
    #[serde(default)]
    pub total_pnl: Option<f64>,
    /// Underwater value at the anchor date; null when that date has no drawdown point, which happens exactly when its cumulative_profit is null. The running peak behind the window is cumulative_profit minus drawdown (drawdown is zero or negative).
    #[serde(default)]
    pub drawdown: Option<f64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderPnlYearTotalsItem {
    pub year: i64,
    pub pnl: f64,
}

/// Curated advanced risk/performance metrics (expand=quant_metrics or expand[]=quant_metrics). Omitted unless expanded and backed by a computed row strictly under six hours old; a missing row, NULL computed_at, or age of exactly six hours or more is stale and omitted. Provider-input changes may intentionally lag inside the bounded six-hour window. When present, all listed fields are present (each is a number or null); null means insufficient trade history and must not be treated as 0. The fixed field shape is unchanged.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderQuantMetrics {
    /// Trader smart score on a 0..100 display scale; higher is stronger. Null when unavailable.
    #[serde(default)]
    pub smart_score: Option<f64>,
    /// Copyability score, 0-100. Same base as smart_score minus penalties for traits that make a strategy hard to replicate: -20 if fewer than 50 markets traded, -15 if positions are highly concentrated, -15 if position sizing exceeds about 2x Kelly, -10 if the largest loss on one settled market exceeds 30% of the capital the wallet deployed across all its positions, -10 if edge is inconsistent; result clamped to 0-100. Higher means easier to follow. null when insufficient history.
    #[serde(default)]
    pub copy_score: Option<f64>,
    /// Sharpe ratio over the trailing 30 days (risk-adjusted return; higher is better). Magnitude can be large for small samples. null when insufficient history.
    #[serde(default)]
    pub sharpe_30d: Option<f64>,
    /// Sharpe ratio over the trailing 7 days (risk-adjusted return; higher is better). null when insufficient history.
    #[serde(default)]
    pub sharpe_7d: Option<f64>,
    /// Gross profit divided by gross loss; greater than 1 is profitable. Capped at 1000 when there are effectively no losses. null when insufficient history.
    #[serde(default)]
    pub profit_factor: Option<f64>,
    /// Share of the trader's last 30 days with realized P&L that closed positive, 0-1 (higher is more consistent). A day with no realized P&L is not one of them, so the window can span months. null below 10 such days; null never means 0.
    #[serde(default)]
    pub edge_consistency: Option<f64>,
    /// Cross-sectional percentile rank of the trader's Sharpe ratio versus all traders, 0-100. null when insufficient history.
    #[serde(default)]
    pub sharpe_percentile: Option<f64>,
    /// Cross-sectional percentile rank of profit factor versus all traders, 0-100. null when insufficient history.
    #[serde(default)]
    pub pf_percentile: Option<f64>,
    /// Cross-sectional percentile rank of edge consistency versus all traders, 0-100. null when insufficient history.
    #[serde(default)]
    pub consistency_percentile: Option<f64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderStats {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub markets_traded: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub win_rate: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub daily_win_rate: Option<f64>,
    /// Full-history both-sides USD cash volume from Polymarket user-volume. Omitted without a verified observation; never leaderboard shares. Its observation time is published as the volume group in data_quality and as trust.total_volume.freshness.as_of, both trader_usd_volume.observed_at; synced_at is a different clock and is never a substitute for it.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub total_volume: Option<f64>,
    /// Additive lossless counterpart to `total_volume`. Omitted when the verified provider observation is unavailable.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<TraderStatsExact>,
}

/// Lossless counterparts for trader statistics. The object is omitted when the verified provider observation is unavailable.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderStatsExact {
    /// stats.total_volume as an exact decimal: full-history both-sides cash volume in USD, Polymarket user-volume `volume_usdc`, from the verified `trader_usd_volume` observation. Never Polymarket's share count.
    pub total_volume: ExactDecimal,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderStrategy {
    /// Observed trading style identifier. New rows use two_sided, category_focused, high_activity, diversified, mixed, or unclassified, counted over the wallet's sports and esports markets only. Historical identifiers remain readable during normal reclassification; style does not predict skill or intent.
    pub strategy_type: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub confidence: Option<f64>,
}

/// `trader_synced` data: a tracked wallet finished a sync pass and has a fresh grade. The deprecated spelling `whale_trader_synced` delivers the same object.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderSyncedData {
    /// 0xinsider's numeric id for the wallet.
    pub trader_id: i64,
    /// Proxy wallet address.
    pub wallet: String,
}

/// Field-level trust metadata returned only when GET /api/v1/trader/{address} includes expand=trust.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TraderTrust {
    pub total_pnl: TrustMetadata,
    pub realized_pnl: TrustMetadata,
    pub net_total_pnl: TrustMetadata,
    /// Present only with pnl.correction: a computed value owned by trader_pnl_corrections, dated by the newest measurement behind it.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pnl_correction: Option<TrustMetadata>,
    pub unrealized_pnl: TrustMetadata,
    pub markets_traded: TrustMetadata,
    pub win_rate: TrustMetadata,
    pub daily_win_rate: TrustMetadata,
    pub total_volume: TrustMetadata,
    pub grade: TrustMetadata,
    pub score: TrustMetadata,
    pub forecast_score: TrustMetadata,
    pub forecast_evidence: TrustMetadata,
    pub rank: TrustMetadata,
    pub streak_tier: TrustMetadata,
    pub strategy: TrustMetadata,
    pub category_strengths: TrustMetadata,
    pub quant_metrics: TrustMetadata,
    pub last_active: TrustMetadata,
    pub synced_at: TrustMetadata,
    pub sync_status: TrustMetadata,
    pub category_records: TrustMetadata,
    pub category_skill_model: TrustMetadata,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TrendingWallet {
    /// Prefixed trader ID (`trd_...`).
    pub id: String,
    pub address: String,
    /// 1-based rank within the full ranked set (stable across pages).
    pub rank: i64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    /// Official Polymarket avatar URL (profileImage).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub profile_image_url: Option<String>,
    /// Real provider platform; surfaced, never coerced. Polymarket only.
    pub platform: String,
    /// Polymarket weekly/monthly P&L for the wallet in USD, taken from Polymarket's canonical leaderboard (data-api.polymarket.com/v2/leaderboard?time_period=week|month&sort_by=PNL). This is the ranking axis and the rows are returned in Polymarket's by-PNL order; it is the provider's number, not a locally summed realized-leaf total.
    pub trending_pnl_usd: f64,
    /// Both-sides cash volume over the window in USD, from Polymarket GET /v2/user-volume (volume_usdc). Omitted when Polymarket served no volume for the wallet: an absent observation, never zero. Polymarket tracks volume in whole UTC days, so this window is the whole-day span covering the requested one, which is not the exact span trending_pnl_usd was scored over.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub window_volume_usd: Option<f64>,
    /// Both-sides traded volume over the window in SHARES, from the Polymarket leaderboard row, whose own schema states the figure is never USD. Omitted when the row carried none.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub window_volume_shares: Option<f64>,
    pub window_markets_traded: i64,
    /// Distinct in-window UTC trade days from our trades (0 if the winner is not in our DB).
    pub window_trade_days: i64,
    /// All-time trader grade; a separate axis from streak_tier. Led by realized profit (the money actually banked, about 95 percent of the grade), with forecasting calibration, risk-adjusted returns, and consistency as the tie-breaker and proven-trader guardrails: any grade above C requires verified net-positive realized profit, and the top grades also require a real resolved-market track record plus a survivable drawdown. Relative, so it drifts as the cohort moves. Omitted when the trader is Unranked (fewer than 5 markets, or too little verified record to cohort-rank).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grade: Option<Grade>,
    /// Hot-streak tier (trailing-7d cross-sectional percentile). Omitted when there is no recent activity.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub streak_tier: Option<StreakTier>,
    /// Polymarket's net total P&L for the wallet in USD: native Polymarket position P&L across all markets, fees included, plus credited maker and taker rebates (trader_trading_pnl.net_total_pnl). The 0xinsider profile's Total P&L is this figure unless pnl_correction is present, then pnl_correction.net_total. Context only: it does not affect the ranking, which follows trending_pnl_usd. Omitted when the wallet is not in the 0xinsider database or has no native accounting snapshot; the Polymarket leaderboard all-time figure is never substituted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub all_time_pnl_usd: Option<f64>,
    /// The 0xinsider correction to Polymarket's P&L for neg-risk conversions. Present only when one is published; all_time_pnl_usd keeps Polymarket's own figure and pnl_correction.net_total is the profile's Total P&L.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pnl_correction: Option<PnlCorrection>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub all_time_score: Option<f64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_synced: Option<String>,
    /// Shape-only daily P&L sparkline across the window, derived from Polymarket's documented user-pnl cumulative curve (GET /v2/user-pnl) converted to per-day deltas. It conveys the trend of the curve only and is NOT guaranteed to sum to trending_pnl_usd, which is the canonical leaderboard total.
    pub daily_pnl_series: Vec<TrendingWalletDailyPnlSeriesItem>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TrendingWalletDailyPnlSeriesItem {
    pub date: String,
    pub pnl_usd: f64,
}

/// Whether the described value or result set is complete for its stated contract.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TrustCompleteness {
    pub status: TrustCompletenessStatus,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub detail: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TrustCompletenessStatus {
    /// `complete`
    #[serde(rename = "complete")]
    Complete,
    /// `partial`
    #[serde(rename = "partial")]
    Partial,
    /// `not_computed`
    #[serde(rename = "not_computed")]
    NotComputed,
    /// `not_applicable`
    #[serde(rename = "not_applicable")]
    NotApplicable,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl TrustCompletenessStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Complete => "complete",
            Self::Partial => "partial",
            Self::NotComputed => "not_computed",
            Self::NotApplicable => "not_applicable",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for TrustCompletenessStatus {
    fn from(value: &str) -> Self {
        match value {
            "complete" => Self::Complete,
            "partial" => Self::Partial,
            "not_computed" => Self::NotComputed,
            "not_applicable" => Self::NotApplicable,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for TrustCompletenessStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for TrustCompletenessStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Freshness metadata for a trust-critical value. This is separate from transport cache fields in ResponseMeta.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TrustFreshness {
    pub status: TrustFreshnessStatus,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub as_of: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub max_age_s: Option<i64>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TrustFreshnessStatus {
    /// `fresh`
    #[serde(rename = "fresh")]
    Fresh,
    /// `refreshing`
    #[serde(rename = "refreshing")]
    Refreshing,
    /// `stale`
    #[serde(rename = "stale")]
    Stale,
    /// `not_live`
    #[serde(rename = "not_live")]
    NotLive,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl TrustFreshnessStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Fresh => "fresh",
            Self::Refreshing => "refreshing",
            Self::Stale => "stale",
            Self::NotLive => "not_live",
            Self::Unknown => "unknown",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for TrustFreshnessStatus {
    fn from(value: &str) -> Self {
        match value {
            "fresh" => Self::Fresh,
            "refreshing" => Self::Refreshing,
            "stale" => Self::Stale,
            "not_live" => Self::NotLive,
            "unknown" => Self::Unknown,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for TrustFreshnessStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for TrustFreshnessStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Shared source/freshness/reconciliation/completeness metadata for public API values that may be cached, stale, partial, computed, or provider-unavailable. Unavailable provider values must be represented with explicit metadata instead of fabricated zeros or empty arrays.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TrustMetadata {
    pub source: TrustSource,
    pub freshness: TrustFreshness,
    pub reconciliation: TrustReconciliation,
    pub completeness: TrustCompleteness,
}

/// How provider-owned facts were reconciled with stored/read-model values.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TrustReconciliation {
    pub status: TrustReconciliationStatus,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub detail: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TrustReconciliationStatus {
    /// `provider_backed`
    #[serde(rename = "provider_backed")]
    ProviderBacked,
    /// `db_mirror`
    #[serde(rename = "db_mirror")]
    DbMirror,
    /// `computed`
    #[serde(rename = "computed")]
    Computed,
    /// `partial`
    #[serde(rename = "partial")]
    Partial,
    /// `not_applicable`
    #[serde(rename = "not_applicable")]
    NotApplicable,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl TrustReconciliationStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::ProviderBacked => "provider_backed",
            Self::DbMirror => "db_mirror",
            Self::Computed => "computed",
            Self::Partial => "partial",
            Self::NotApplicable => "not_applicable",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for TrustReconciliationStatus {
    fn from(value: &str) -> Self {
        match value {
            "provider_backed" => Self::ProviderBacked,
            "db_mirror" => Self::DbMirror,
            "computed" => Self::Computed,
            "partial" => Self::Partial,
            "not_applicable" => Self::NotApplicable,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for TrustReconciliationStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for TrustReconciliationStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Source metadata for a trust-critical value. Providers and DB/read models own business truth; clients should not infer missing provider facts from titles, slugs, zeros, or empty arrays.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TrustSource {
    pub kind: TrustSourceKind,
    /// Provider, table/read-model, cache, or service that owns the value.
    pub owner: String,
    /// Provider field, DB column, or computed field name when applicable.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub field: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TrustSourceKind {
    /// `provider`
    #[serde(rename = "provider")]
    Provider,
    /// `database`
    #[serde(rename = "database")]
    Database,
    /// `cache`
    #[serde(rename = "cache")]
    Cache,
    /// `computed`
    #[serde(rename = "computed")]
    Computed,
    /// `client_input`
    #[serde(rename = "client_input")]
    ClientInput,
    /// `unavailable`
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl TrustSourceKind {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Provider => "provider",
            Self::Database => "database",
            Self::Cache => "cache",
            Self::Computed => "computed",
            Self::ClientInput => "client_input",
            Self::Unavailable => "unavailable",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for TrustSourceKind {
    fn from(value: &str) -> Self {
        match value {
            "provider" => Self::Provider,
            "database" => Self::Database,
            "cache" => Self::Cache,
            "computed" => Self::Computed,
            "client_input" => Self::ClientInput,
            "unavailable" => Self::Unavailable,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for TrustSourceKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for TrustSourceKind {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct UpdateWebhookRequest {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Replacement public HTTPS callback URL on the default port 443, validated and checked for uniqueness exactly like the create url. HTTPS scheme/host case, trailing DNS dots and port 443 normalize; path/query case is preserved. Changing it resets status to pending_verification and returns a new verification token; the new destination must pass the verification challenge before deliveries resume.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub event_types: Option<Vec<WebhookEventType>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub trade_filters: Option<LargeTradeSubscriptionFilters>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct UpdateWebhookResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Usage {
    pub object: String,
    pub data: UsageData,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct UsageData {
    pub rate_limit: UsageDataRateLimit,
    /// UTC-day usage count. Current V1 has no daily hard cap, so limit and remaining are null rather than synthesized.
    pub daily_usage: UsageDataDailyUsage,
    /// The monthly request quota (#16111): where the account stands against the requests the current Pro or Max plan includes per UTC calendar month. Reading it here spends nothing. null only when the month's count could not be read for this response.
    #[serde(default)]
    pub monthly_quota: Option<UsageDataMonthlyQuota>,
}

/// UTC-day usage count. Current V1 has no daily hard cap, so limit and remaining are null rather than synthesized.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct UsageDataDailyUsage {
    pub used: i64,
    #[serde(default)]
    pub limit: Option<i64>,
    #[serde(default)]
    pub remaining: Option<i64>,
    pub reset_at: i64,
    pub window_seconds: i64,
}

/// The monthly request quota (#16111): where the account stands against the requests the current Pro or Max plan includes per UTC calendar month. Reading it here spends nothing. null only when the month's count could not be read for this response.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct UsageDataMonthlyQuota {
    /// Admitted requests so far this UTC calendar month.
    pub used: i64,
    /// Requests the account's plan includes per UTC calendar month: 500,000 for Pro, 2,000,000 for Max.
    pub limit: i64,
    pub remaining: i64,
    /// Unix seconds: the first instant of the next UTC calendar month.
    pub reset_at: i64,
    /// Unix seconds: from when request limit + 1 is refused for an account the quota binds.
    pub enforced_from: i64,
    /// Whether requests over this account's ceiling are refused right now: false before enforced_from and for an admin account.
    pub binding: bool,
    /// Pay as you go is on: requests over the quota keep answering and bill on a monthly invoice, up to ceiling.
    pub pay_as_you_go: bool,
    /// The most requests this account is admitted in a UTC calendar month once enforcement has begun: limit, or four times limit with pay as you go on (2,000,000 for Pro). null for an admin account, which no number stops. Additive since 2026-09-22.
    #[serde(default)]
    pub ceiling: Option<i64>,
    /// Why pay as you go is unavailable, or null. usage_price_reconciliation_required: the account's usage subscription carries a historical price whose included requests differ from its plan's, so pay as you go stays off (pay_as_you_go false) until billing reconciles it. Always sent since 2026-10-17.
    #[serde(default)]
    pub unavailable_reason: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct UsageDataRateLimit {
    pub used: i64,
    /// The per-minute window's limit for the caller's plan: 100 requests on Pro, 200 on Max. The same number RateLimit-Limit reports on a counted request.
    pub limit: i64,
    pub remaining: i64,
    pub reset_at: i64,
    pub window_seconds: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct VerifyWebhookRequest {
    /// The one-time token returned on create or on a url change. It is necessary but not sufficient: the destination must also answer the signed webhook.verification challenge with a 2xx.
    pub verification_token: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct VerifyWebhookResponse {
    pub object: String,
    pub data: WebhookEndpoint,
    pub meta: ResponseMeta,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum View {
    /// `board`
    #[serde(rename = "board")]
    Board,
    /// `signals`
    #[serde(rename = "signals")]
    Signals,
    /// `observations`
    #[serde(rename = "observations")]
    Observations,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl View {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Board => "board",
            Self::Signals => "signals",
            Self::Observations => "observations",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for View {
    fn from(value: &str) -> Self {
        match value {
            "board" => Self::Board,
            "signals" => Self::Signals,
            "observations" => Self::Observations,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for View {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for View {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// `wallet_grade_changed` data (Pro and Max): a tracked wallet's grade moved on a re-grade.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WalletGradeChangedData {
    /// Lowercased proxy wallet address.
    pub wallet: String,
    /// 0xinsider's numeric id for the wallet.
    pub trader_id: i64,
    /// The grade before the move. Never equal to `new_grade`.
    pub old_grade: Grade,
    pub new_grade: Grade,
    /// `upgrade` when `new_grade` is better than `old_grade`, else `downgrade`.
    pub direction: WalletGradeChangedDataDirection,
    /// Cohort skill index that drove the grade, 0 to 1.
    pub skill_index: f64,
    /// Final 0 to 100 score banded into the new grade.
    pub final_score: f64,
    /// The ranking date of the re-grade.
    pub date: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WalletGradeChangedDataDirection {
    /// `upgrade`
    #[serde(rename = "upgrade")]
    Upgrade,
    /// `downgrade`
    #[serde(rename = "downgrade")]
    Downgrade,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl WalletGradeChangedDataDirection {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Upgrade => "upgrade",
            Self::Downgrade => "downgrade",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for WalletGradeChangedDataDirection {
    fn from(value: &str) -> Self {
        match value {
            "upgrade" => Self::Upgrade,
            "downgrade" => Self::Downgrade,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for WalletGradeChangedDataDirection {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for WalletGradeChangedDataDirection {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// Owner-scoped view of one webhook delivery attempt. Deliberately omits the request body and the endpoint signing secret: a delivery log never re-exposes the payload or any secret material.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookDelivery {
    pub id: i64,
    pub object: String,
    /// Stable event id for this delivery; identical across retries of the same logical event.
    pub event_id: String,
    pub event_type: WebhookEventType,
    /// Delivery lifecycle state (e.g. pending, delivered, dead_letter).
    pub status: String,
    /// Number of delivery attempts made so far.
    pub attempt_count: i64,
    /// HTTP status code of the most recent delivery attempt. Omitted until a response (or transport error) has been recorded.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_response_status: Option<i64>,
    /// Short description of the most recent delivery failure. Omitted when the last attempt succeeded or none has failed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub last_error: Option<String>,
    /// When the delivery was first accepted by the destination. Omitted until a delivery succeeds.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub delivered_at: Option<String>,
    /// When the next delivery attempt is due, for a delivery whose status is pending or retry. null while an attempt is in flight (processing) and once the delivery is terminal (delivered or dead_letter).
    #[serde(default)]
    pub next_attempt_at: Option<String>,
    /// Why next_attempt_at was scheduled: receiver_retry_after for an accepted Retry-After on a 408, 429, or 5xx response; transient_failure for a network or ordinary transient retry; permanent_or_auth_failure for another non-2xx response; manual_redelivery or configuration_changed for those queue actions. null while an attempt is in flight or once the delivery is terminal.
    #[serde(default)]
    pub retry_schedule_reason: Option<RetryScheduleReason>,
    pub created_at: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookEndpoint {
    pub id: i64,
    pub object: String,
    pub name: String,
    pub url: String,
    pub event_types: Vec<WebhookEventType>,
    pub trade_filters: LargeTradeSubscriptionFilters,
    pub status: WebhookStatus,
    #[serde(default)]
    pub verified_at: Option<String>,
    pub verification_token_expires_at: String,
    pub failure_count: i64,
    pub created_at: String,
    pub updated_at: String,
    pub retry_policy: WebhookRetryPolicy,
    pub secret_rotation: WebhookSecretRotation,
    /// Returned only on create, immediate rotate-secret, staged rotate-secret/prepare, or staged rotate-secret/activate. Never returned by list, get, update, delete, verify, or retire.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub signing_secret: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub verification: Option<WebhookVerification>,
}

/// Self-describing entry in the webhook event catalog: the event type a subscriber lists in event_types, when it fires, the data payload shape, and whether it currently fires (active) or is reserved (dormant, subscribable but not yet delivered). Pro-only event types (large_trades_inserted, whale_trades_inserted, wallet_grade_changed, suspicious_trade_flagged, insider_radar_flag_raised, sharp_money_flow_detected, smart_money_flow_detected) only deliver to API keys on an active Pro subscription. Export lifecycle event types (export_job_ready, export_job_failed, export_job_expired, export_job_cancelled) are owner-scoped to the API-key account that created the export and contain no download URL; use the authorized export status/download routes. Some entries are two spellings of one event: large_trades_inserted and whale_trades_inserted, trader_synced and whale_trader_synced, suspicious_trade_flagged and insider_radar_flag_raised, sharp_money_flow_detected and smart_money_flow_detected. Either spelling subscribes, and an endpoint receives deliveries under the spelling it registered.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookEventDescriptor {
    pub id: WebhookEventType,
    /// One-line description of when the event fires.
    pub description: String,
    /// Short description of the data payload object's shape.
    pub payload_shape: String,
    /// active: the event has a firing producer callsite. dormant: advertised and subscribable, but does not yet enqueue any delivery.
    pub status: WebhookEventDescriptorStatus,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WebhookEventDescriptorStatus {
    /// `active`
    #[serde(rename = "active")]
    Active,
    /// `dormant`
    #[serde(rename = "dormant")]
    Dormant,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl WebhookEventDescriptorStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Dormant => "dormant",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for WebhookEventDescriptorStatus {
    fn from(value: &str) -> Self {
        match value {
            "active" => Self::Active,
            "dormant" => Self::Dormant,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for WebhookEventDescriptorStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for WebhookEventDescriptorStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WebhookEventType {
    /// `large_trade_inserted_v2`
    #[serde(rename = "large_trade_inserted_v2")]
    LargeTradeInsertedV2,
    /// `large_trades_inserted`
    #[serde(rename = "large_trades_inserted")]
    LargeTradesInserted,
    /// `whale_trades_inserted`
    #[serde(rename = "whale_trades_inserted")]
    WhaleTradesInserted,
    /// `live_sports_updated`
    #[serde(rename = "live_sports_updated")]
    LiveSportsUpdated,
    /// `trader_synced`
    #[serde(rename = "trader_synced")]
    TraderSynced,
    /// `whale_trader_synced`
    #[serde(rename = "whale_trader_synced")]
    WhaleTraderSynced,
    /// `large_positions_updated`
    #[serde(rename = "large_positions_updated")]
    LargePositionsUpdated,
    /// `wallet_grade_changed`
    #[serde(rename = "wallet_grade_changed")]
    WalletGradeChanged,
    /// `suspicious_trade_flagged`
    #[serde(rename = "suspicious_trade_flagged")]
    SuspiciousTradeFlagged,
    /// `insider_radar_flag_raised`
    #[serde(rename = "insider_radar_flag_raised")]
    InsiderRadarFlagRaised,
    /// `sharp_money_flow_detected`
    #[serde(rename = "sharp_money_flow_detected")]
    SharpMoneyFlowDetected,
    /// `smart_money_flow_detected`
    #[serde(rename = "smart_money_flow_detected")]
    SmartMoneyFlowDetected,
    /// `export_job_ready`
    #[serde(rename = "export_job_ready")]
    ExportJobReady,
    /// `export_job_failed`
    #[serde(rename = "export_job_failed")]
    ExportJobFailed,
    /// `export_job_expired`
    #[serde(rename = "export_job_expired")]
    ExportJobExpired,
    /// `export_job_cancelled`
    #[serde(rename = "export_job_cancelled")]
    ExportJobCancelled,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl WebhookEventType {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::LargeTradeInsertedV2 => "large_trade_inserted_v2",
            Self::LargeTradesInserted => "large_trades_inserted",
            Self::WhaleTradesInserted => "whale_trades_inserted",
            Self::LiveSportsUpdated => "live_sports_updated",
            Self::TraderSynced => "trader_synced",
            Self::WhaleTraderSynced => "whale_trader_synced",
            Self::LargePositionsUpdated => "large_positions_updated",
            Self::WalletGradeChanged => "wallet_grade_changed",
            Self::SuspiciousTradeFlagged => "suspicious_trade_flagged",
            Self::InsiderRadarFlagRaised => "insider_radar_flag_raised",
            Self::SharpMoneyFlowDetected => "sharp_money_flow_detected",
            Self::SmartMoneyFlowDetected => "smart_money_flow_detected",
            Self::ExportJobReady => "export_job_ready",
            Self::ExportJobFailed => "export_job_failed",
            Self::ExportJobExpired => "export_job_expired",
            Self::ExportJobCancelled => "export_job_cancelled",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for WebhookEventType {
    fn from(value: &str) -> Self {
        match value {
            "large_trade_inserted_v2" => Self::LargeTradeInsertedV2,
            "large_trades_inserted" => Self::LargeTradesInserted,
            "whale_trades_inserted" => Self::WhaleTradesInserted,
            "live_sports_updated" => Self::LiveSportsUpdated,
            "trader_synced" => Self::TraderSynced,
            "whale_trader_synced" => Self::WhaleTraderSynced,
            "large_positions_updated" => Self::LargePositionsUpdated,
            "wallet_grade_changed" => Self::WalletGradeChanged,
            "suspicious_trade_flagged" => Self::SuspiciousTradeFlagged,
            "insider_radar_flag_raised" => Self::InsiderRadarFlagRaised,
            "sharp_money_flow_detected" => Self::SharpMoneyFlowDetected,
            "smart_money_flow_detected" => Self::SmartMoneyFlowDetected,
            "export_job_ready" => Self::ExportJobReady,
            "export_job_failed" => Self::ExportJobFailed,
            "export_job_expired" => Self::ExportJobExpired,
            "export_job_cancelled" => Self::ExportJobCancelled,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for WebhookEventType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for WebhookEventType {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookRetryPolicy {
    pub max_attempts: i64,
    pub terminal_status: String,
    /// Total wait from a delivery's first failed attempt to its last retry: 60, 120, 240, 480, 960, 1920 and 3600 seconds. A delivery still failing after that is dead_letter.
    pub retry_horizon_seconds: i64,
    /// Consecutive failed attempts, across all of this endpoint's deliveries, after which the endpoint is disabled and its queued deliveries are dead-lettered. Any successful attempt resets the count.
    pub disable_after_consecutive_failures: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookSecretRotation {
    /// idle when no staged rotation exists, pending after prepare, and overlap after activate while both signing secrets are accepted.
    pub status: WebhookSecretRotationStatus,
    /// When the previous signing secret stops being emitted and accepted. null outside the overlap phase.
    #[serde(default)]
    pub overlap_expires_at: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WebhookSecretRotationStatus {
    /// `idle`
    #[serde(rename = "idle")]
    Idle,
    /// `pending`
    #[serde(rename = "pending")]
    Pending,
    /// `overlap`
    #[serde(rename = "overlap")]
    Overlap,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl WebhookSecretRotationStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Idle => "idle",
            Self::Pending => "pending",
            Self::Overlap => "overlap",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for WebhookSecretRotationStatus {
    fn from(value: &str) -> Self {
        match value {
            "idle" => Self::Idle,
            "pending" => Self::Pending,
            "overlap" => Self::Overlap,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for WebhookSecretRotationStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for WebhookSecretRotationStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WebhookStatus {
    /// `pending_verification`
    #[serde(rename = "pending_verification")]
    PendingVerification,
    /// `active`
    #[serde(rename = "active")]
    Active,
    /// `disabled`
    #[serde(rename = "disabled")]
    Disabled,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl WebhookStatus {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::PendingVerification => "pending_verification",
            Self::Active => "active",
            Self::Disabled => "disabled",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for WebhookStatus {
    fn from(value: &str) -> Self {
        match value {
            "pending_verification" => Self::PendingVerification,
            "active" => Self::Active,
            "disabled" => Self::Disabled,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for WebhookStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for WebhookStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookVerification {
    /// One-time verification token returned only on create or URL change. Pass it to POST /api/v1/webhooks/{id}/verify, which activates the endpoint only when the destination also answers the signed webhook.verification challenge with a 2xx.
    pub token: String,
    pub expires_at: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookVerificationAttempt {
    pub id: String,
    pub object: String,
    pub webhook_id: i64,
    /// queued/running are pending consent. verified means the same endpoint revision answered 2xx and activated atomically. failed/cancelled/expired are terminal and do not restart on polling or replay.
    pub state: WebhookVerificationAttemptState,
    /// Sanitized last observation. Null before an observation; queued retries may retain their previous failure outcome.
    #[serde(default)]
    pub outcome: Option<WebhookVerificationAttemptOutcome>,
    pub attempt_count: i64,
    pub max_attempts: i64,
    /// Earlier of the verification-token deadline and 15 minutes after admission. Activation is forbidden at or after this instant.
    pub expires_at: String,
    /// Scheduled retry/admission time while queued; null while running or terminal.
    #[serde(default)]
    pub next_attempt_at: Option<String>,
    /// Actual receiver HTTP status, when one arrived. No receiver response body or resolved address is returned.
    #[serde(default)]
    pub last_response_status: Option<i64>,
    #[serde(default)]
    pub started_at: Option<String>,
    #[serde(default)]
    pub completed_at: Option<String>,
    pub created_at: String,
    pub updated_at: String,
    /// Relative authorized API path for this attempt. Uses the same bearer credential as admission.
    pub status_url: String,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WebhookVerificationAttemptOutcome {
    /// `verified`
    #[serde(rename = "verified")]
    Verified,
    /// `target_rejected`
    #[serde(rename = "target_rejected")]
    TargetRejected,
    /// `challenge_timeout`
    #[serde(rename = "challenge_timeout")]
    ChallengeTimeout,
    /// `transport_failed`
    #[serde(rename = "transport_failed")]
    TransportFailed,
    /// `receiver_rejected`
    #[serde(rename = "receiver_rejected")]
    ReceiverRejected,
    /// `token_expired`
    #[serde(rename = "token_expired")]
    TokenExpired,
    /// `endpoint_changed`
    #[serde(rename = "endpoint_changed")]
    EndpointChanged,
    /// `owner_revoked`
    #[serde(rename = "owner_revoked")]
    OwnerRevoked,
    /// `attempts_exhausted`
    #[serde(rename = "attempts_exhausted")]
    AttemptsExhausted,
    /// `internal_error`
    #[serde(rename = "internal_error")]
    InternalError,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl WebhookVerificationAttemptOutcome {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Verified => "verified",
            Self::TargetRejected => "target_rejected",
            Self::ChallengeTimeout => "challenge_timeout",
            Self::TransportFailed => "transport_failed",
            Self::ReceiverRejected => "receiver_rejected",
            Self::TokenExpired => "token_expired",
            Self::EndpointChanged => "endpoint_changed",
            Self::OwnerRevoked => "owner_revoked",
            Self::AttemptsExhausted => "attempts_exhausted",
            Self::InternalError => "internal_error",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for WebhookVerificationAttemptOutcome {
    fn from(value: &str) -> Self {
        match value {
            "verified" => Self::Verified,
            "target_rejected" => Self::TargetRejected,
            "challenge_timeout" => Self::ChallengeTimeout,
            "transport_failed" => Self::TransportFailed,
            "receiver_rejected" => Self::ReceiverRejected,
            "token_expired" => Self::TokenExpired,
            "endpoint_changed" => Self::EndpointChanged,
            "owner_revoked" => Self::OwnerRevoked,
            "attempts_exhausted" => Self::AttemptsExhausted,
            "internal_error" => Self::InternalError,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for WebhookVerificationAttemptOutcome {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for WebhookVerificationAttemptOutcome {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WebhookVerificationAttemptState {
    /// `queued`
    #[serde(rename = "queued")]
    Queued,
    /// `running`
    #[serde(rename = "running")]
    Running,
    /// `verified`
    #[serde(rename = "verified")]
    Verified,
    /// `failed`
    #[serde(rename = "failed")]
    Failed,
    /// `cancelled`
    #[serde(rename = "cancelled")]
    Cancelled,
    /// `expired`
    #[serde(rename = "expired")]
    Expired,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl WebhookVerificationAttemptState {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Queued => "queued",
            Self::Running => "running",
            Self::Verified => "verified",
            Self::Failed => "failed",
            Self::Cancelled => "cancelled",
            Self::Expired => "expired",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for WebhookVerificationAttemptState {
    fn from(value: &str) -> Self {
        match value {
            "queued" => Self::Queued,
            "running" => Self::Running,
            "verified" => Self::Verified,
            "failed" => Self::Failed,
            "cancelled" => Self::Cancelled,
            "expired" => Self::Expired,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for WebhookVerificationAttemptState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for WebhookVerificationAttemptState {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhaleDatasetArtifactManifest {
    /// Version of the artifact manifest contract.
    pub manifest_version: String,
    pub format: String,
    pub schema_version: String,
    pub coverage: String,
    pub generation: WhaleDatasetGeneration,
    /// Number of trade rows written.
    pub row_count: i64,
    /// Exact byte count of the decompressed content stream clients receive.
    pub content_size_bytes: i64,
    /// Lowercase SHA-256 of the decompressed content bytes.
    pub content_sha256: String,
    /// Exact byte count of the gzip-compressed bytes stored by the object provider.
    pub compressed_size_bytes: i64,
    /// Lowercase SHA-256 of the stored gzip bytes; the multipart ETag is not used as this checksum.
    pub compressed_sha256: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhaleDatasetContinuation {
    pub path: String,
    /// Opaque commit-safe replay cursor; replay the same condition_id and min_size.
    pub cursor: String,
    /// Writer floor included by the replay cursor. It can precede the snapshot horizon to include arrivals after the finite window end.
    pub from_commit_xid: String,
    #[serde(default)]
    pub condition_id: Option<String>,
    /// Normalized USD threshold; pass it to the replay query.
    #[serde(default)]
    pub min_size: Option<String>,
    pub deduplication_identity: String,
    pub time_window_applies_to_deltas: bool,
    pub delivery: String,
}

/// Normalized immutable request; [from, to), maximum 31 days; min_size rounded to cents like durable replay.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhaleDatasetFilters {
    pub from: String,
    pub to: String,
    #[serde(default)]
    pub condition_id: Option<String>,
    #[serde(default)]
    pub min_size_cents: Option<i64>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhaleDatasetGeneration {
    pub dataset_schema_version: String,
    pub id: String,
    pub selected_at: String,
    pub consistency: String,
    pub filters: WhaleDatasetFilters,
    /// All snapshot rows have a writer xid strictly below this closed visibility horizon. Decimal string preserves integer precision.
    pub commit_horizon_xid: String,
    pub continuation: WhaleDatasetContinuation,
    pub source: String,
    /// Best-effort detected whale alerts only; not all provider fills. No trader or market enrichment.
    pub coverage: String,
    pub expires_at: String,
    pub extraction_elapsed_ms: i64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhaleDatasetJob {
    pub object: String,
    pub data: WhaleDatasetJobData,
    pub meta: ResponseMeta,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhaleDatasetJobData {
    pub job_id: i64,
    /// queued: accepted, not started. running: the worker is streaming rows. reconcile_required: the upload finished but the storage completion answer was lost; the hourly reconciler reads the object back and moves the job to ready or failed, and expires_at bounds the wait. ready: downloadable until expires_at. failed: terminal; error says why; submit a new export. expired: the retention window passed; the file is retired, the download route answers 410, submit a new export. cancel_requested: the owner cancelled a running job (POST /api/v1/trader/{address}/export/cancel); the worker stops at its next safe point and the job reads cancelled. cancelled: terminal; the owner cancelled the job and no file was published; submit a new export. A job that has not reached ready by expires_at reads failed with error 'export expired before completion'. failed, cancelled and expired rows stay readable for 48 hours, then the job answers 404.
    pub status: TraderExportJobDataStatus,
    pub format: String,
    #[serde(default)]
    pub total_trades: Option<i64>,
    #[serde(default)]
    pub processed_trades: Option<i64>,
    #[serde(default)]
    pub file_size: Option<i64>,
    #[serde(default)]
    pub error: Option<String>,
    /// True when status never changes again (ready, failed, expired, cancelled). Stop polling.
    pub terminal: bool,
    /// What to do next: poll the status route after poll_after_s, follow the download route, or submit a new export. Published beside status so a status value added later does not strand a client.
    pub next_action: NextAction,
    /// Seconds to wait before polling again. Absent when terminal. 5 while queued, running or cancel_requested; 300 while reconcile_required, the cadence that state can change at.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub poll_after_s: Option<i64>,
    pub created_at: String,
    /// When the worker last claimed the job; null while queued.
    #[serde(default)]
    pub started_at: Option<String>,
    /// When the file became downloadable. null before ready, and on jobs finalized before this field existed.
    #[serde(default)]
    pub ready_at: Option<String>,
    #[serde(default)]
    pub failed_at: Option<String>,
    /// The retention window: 24 hours from submit. A ready file downloads until this instant; a job that has not reached ready by it fails. A reused job (200 on submit) keeps its original window.
    pub expires_at: String,
    /// When the job became expired; null until then.
    #[serde(default)]
    pub expired_at: Option<String>,
    /// Snapshot selection clock, null until the artifact is written; not provider completeness.
    #[serde(default)]
    pub data_as_of: Option<String>,
    /// When the owner asked to cancel the job; null otherwise. Set on every cancelled job, including one cancelled while queued. While status is cancel_requested this is the instant the worker was asked to stop.
    #[serde(default)]
    pub cancel_requested_at: Option<String>,
    /// When the job reached cancelled; null until then.
    #[serde(default)]
    pub cancelled_at: Option<String>,
    /// Worker claims so far.
    pub attempt: i64,
    /// The job fails when attempt reaches this.
    pub max_attempts: i64,
    /// Present only while status is ready: the stored object's identity, so a client can check the download it receives.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub artifact: Option<WhaleDatasetJobDataArtifact>,
    pub filters: WhaleDatasetFilters,
}

/// Present only while status is ready: the stored object's identity, so a client can check the download it receives.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhaleDatasetJobDataArtifact {
    /// Stable identity for this completed export artifact; unchanged when a temporary download URL is renewed.
    pub artifact_id: String,
    /// The storage ETag of the object.
    #[serde(default)]
    pub etag: Option<String>,
    /// Bytes on the wire (gzip); file_size is the decompressed size.
    #[serde(default)]
    pub compressed_size_bytes: Option<i64>,
    pub content_type: String,
    pub content_encoding: String,
    /// Immutable source, window, replay handoff, count and hashes of both content and gzip bytes.
    #[serde(default)]
    pub manifest: Option<WhaleDatasetArtifactManifest>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhaleDatasetTrade {
    /// wt_<whale_alert_id>; deduplication identity shared with expanded replay.
    pub id: String,
    /// Decimal whale-alert ID.
    pub sequence: String,
    /// trd_<local trader ID>.
    pub trader_id: String,
    pub condition_id: String,
    pub platform: String,
    pub traded_at: String,
    pub side: LargeTradeInsertedV2DataSide,
    /// Provider outcome index, null before the canonical outcome trust boundary.
    #[serde(default)]
    pub outcome_index: Option<i64>,
    /// Exact stored NUMERIC price; decimal string.
    pub price: String,
    /// Exact stored NUMERIC USD notional; decimal string.
    pub size_usd: String,
    /// Writer transaction ID, decimal string.
    pub inserted_xid: String,
    /// Stored source trade identity.
    pub trade_event_id: String,
    #[serde(default)]
    pub source_trade_ingested_at: Option<String>,
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Window {
    /// `24h`
    #[serde(rename = "24h")]
    V24h,
    /// `7d`
    #[serde(rename = "7d")]
    V7d,
    /// `all`
    #[serde(rename = "all")]
    All,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl Window {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::V24h => "24h",
            Self::V7d => "7d",
            Self::All => "all",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for Window {
    fn from(value: &str) -> Self {
        match value {
            "24h" => Self::V24h,
            "7d" => Self::V7d,
            "all" => Self::All,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for Window {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for Window {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

/// A value this release does not know is kept in `Other`, so a new value never fails a response.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WithdrawalReason {
    /// `provider_game_cancelled`
    #[serde(rename = "provider_game_cancelled")]
    ProviderGameCancelled,
    /// `published_after_kickoff`
    #[serde(rename = "published_after_kickoff")]
    PublishedAfterKickoff,
    /// A value this release does not know, kept as sent.
    #[serde(untagged)]
    Other(String),
}

impl WithdrawalReason {
    /// The value as the API spells it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::ProviderGameCancelled => "provider_game_cancelled",
            Self::PublishedAfterKickoff => "published_after_kickoff",
            Self::Other(value) => value,
        }
    }
}

impl From<&str> for WithdrawalReason {
    fn from(value: &str) -> Self {
        match value {
            "provider_game_cancelled" => Self::ProviderGameCancelled,
            "published_after_kickoff" => Self::PublishedAfterKickoff,
            other => Self::Other(other.to_owned()),
        }
    }
}

impl std::fmt::Display for WithdrawalReason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for WithdrawalReason {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}