ccxt-pro 4.5.78

CCXT – CryptoCurrency eXchange Trading Library (Rust) – pro (WebSocket / watch*) exchanges
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
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code

#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
use crate::pro::*;


pub struct NadoCore {
    pub parent: crate::exchanges::nado::NadoCore,
}

impl NadoCore {
    pub fn new(config: Option<crate::Value>) -> Self {
        let mut s = Self { parent: crate::exchanges::nado::NadoCore::new(config) };
        s.init();
        s
    }

    pub fn init(&mut self) {
        let described = NadoCore::describe(self);
        self.initialize_properties(described);
        <Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
    }

    /// Compatibility no-op. The old pointer-based dispatch needed a post-move
    /// `bind()`; static trait dispatch (review #1) needs no binding, so this
    /// just exists so callers that still call it keep compiling.
    #[inline]
    pub fn bind(&mut self) {}
}

impl crate::exchange::DerivedExchange for NadoCore {
    fn nonce(&self, ) -> crate::Value {
        crate::exchange::DerivedExchange::nonce(&self.parent)
    }
    fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_ticker(&self.parent, ticker, market)
    }
    fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_trade(&self.parent, trade, market)
    }
    fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_order(&self.parent, order, market)
    }
    fn parse_market(&self, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_market(&self.parent, market)
    }
    fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_ohlcv(&self.parent, ohlcv, market)
    }
    fn parse_order_book(&self, ob: crate::Value, symbol: crate::Value, ts: crate::Value, bk: crate::Value, ak: crate::Value, pk: crate::Value, ak2: crate::Value, ck: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_order_book(&self.parent, ob, symbol, ts, bk, ak, pk, ak2, ck)
    }
    fn parse_balance(&self, response: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_balance(&self.parent, response)
    }
    fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_position(&self.parent, position, market)
    }
    fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_funding_rate(&self.parent, rate, market)
    }
    fn parse_deposit(&self, tx: crate::Value, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_deposit(&self.parent, tx, currency)
    }
    fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_deposit_address(&self.parent, depositAddress, currency)
    }
    fn parse_last_price(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_last_price(&self.parent, entry, market)
    }
    fn parse_withdrawal(&self, tx: crate::Value, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_withdrawal(&self.parent, tx, currency)
    }
    fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_ledger_entry(&self.parent, entry, currency)
    }
    fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_transfer(&self.parent, transfer, currency)
    }
    fn parse_currency(&self, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_currency(&self.parent, currency)
    }
    fn parse_bid_ask(&self, bidask: crate::Value, price_key: crate::Value, amount_key: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_bid_ask(&self.parent, bidask, price_key, amount_key, market)
    }
    fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_open_interest(&self.parent, interest, market)
    }
    fn parse_liquidation(&self, liquidation: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_liquidation(&self.parent, liquidation, market)
    }
    fn parse_funding_rate_history(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_funding_rate_history(&self.parent, entry, market)
    }
    fn parse_margin_modification(&self, data: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_margin_modification(&self.parent, data, market)
    }
    fn parse_account(&self, account: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_account(&self.parent, account)
    }
    fn parse_my_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_my_trade(&self.parent, trade, market)
    }
    fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_transaction(&self.parent, transaction, currency)
    }
    fn parse_borrow_interest(&self, info: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_borrow_interest(&self.parent, info, market)
    }
    fn parse_adl_rank(&self, info: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_adl_rank(&self.parent, info, market)
    }
    fn parse_income(&self, info: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_income(&self.parent, info, market)
    }
    fn parse_greeks(&self, greeks: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_greeks(&self.parent, greeks, market)
    }
    fn parse_margin_mode(&self, margin_mode: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_margin_mode(&self.parent, margin_mode, market)
    }
    fn parse_conversion(&self, conversion: crate::Value, from_currency: crate::Value, to_currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_conversion(&self.parent, conversion, from_currency, to_currency)
    }
    fn parse_borrow_rate(&self, info: crate::Value, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_borrow_rate(&self.parent, info, currency)
    }
    fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_leverage(&self.parent, leverage, market)
    }
    fn parse_market_leverage_tiers(&self, info: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_market_leverage_tiers(&self.parent, info, market)
    }
    fn parse_deposit_withdraw_fee(&self, fee: crate::Value, currency: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_deposit_withdraw_fee(&self.parent, fee, currency)
    }
    fn parse_prediction_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_prediction_trade(&self.parent, trade, market)
    }
    fn parse_prediction_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_prediction_order(&self.parent, order, market)
    }
    fn parse_prediction_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::parse_prediction_position(&self.parent, position, market)
    }
    fn create_expired_option_market(&self, symbol: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::create_expired_option_market(&self.parent, symbol)
    }
    fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::sign(&self.parent, path, api, method, params, headers, body)
    }
    fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
        crate::exchange::DerivedExchange::handle_errors(&self.parent, code, reason, url, method, headers, body, response, request_headers, request_body)
    }
}

impl crate::exchange_generated::ExchangeBase for NadoCore {
    fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
        -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
    {
        Box::pin(async move {
            match method {
                "authenticate" => self.authenticate(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "create_order_ws" => self.create_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
                "create_public_subscription_request" => self.create_public_subscription_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
                "edit_order_ws" => self.edit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
                "handle_error_message" => self.handle_error_message(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
                "handle_message" => { self.handle_message(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
                "handle_pong" => self.handle_pong(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
                "parse_ws_all_bids_asks" => self.parse_ws_all_bids_asks(args.get(0).cloned().unwrap_or(crate::Value::Null)),
                "parse_ws_bid_ask" => self.parse_ws_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
                "parse_ws_my_trade" => self.parse_ws_my_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
                "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
                "parse_ws_position" => self.parse_ws_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
                "parse_ws_timestamp" => self.parse_ws_timestamp(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
                "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
                "ping" => self.ping(args.get(0).cloned().unwrap_or(crate::Value::Null)),
                "request_id" => self.request_id(),
                "sign_stream_authentication" => self.sign_stream_authentication(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null)),
                "un_watch_bids_asks" => self.un_watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_my_trades" => self.un_watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_ohlcv_for_symbols" => self.un_watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_order_book_for_symbols" => self.un_watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_orders" => self.un_watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_positions" => self.un_watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_private" => self.un_watch_private(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_public" => self.un_watch_public(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_public_multiple" => self.un_watch_public_multiple(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_tickers" => self.un_watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "un_watch_trades_for_symbols" => self.un_watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_bids_asks" => self.watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_execute_request" => self.watch_execute_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)).await,
                "watch_my_trades" => self.watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_order_book_for_symbols" => self.watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_orders" => self.watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_positions" => self.watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_private" => self.watch_private(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_public" => self.watch_public(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_public_multiple" => self.watch_public_multiple(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_tickers" => self.watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
                // Go-style inheritance: an un-overridden method dispatches to the parent core.
                _ => crate::exchange_generated::ExchangeBase::call_dynamic(&mut self.parent, method, args).await,
            }
        })
    }
}
impl NadoCore {
    /// Synchronous WS handler dispatch — routes a handler-name string (from the
    /// venue's handle_message dispatch table) to the real handler method.
    #[allow(dead_code, unreachable_patterns, clippy::all)]
    pub fn dispatch_ws_handler(&mut self, __name: &crate::Value, args: &[crate::Value]) -> crate::Value {
        let __n = match __name { crate::Value::Str(s) => s.as_str(), _ => return crate::Value::Null };
        match __n {
            "authenticate" => { crate::exchange_stubs::enqueue_spawn("authenticate", args.to_vec()); crate::Value::Null },
            "cancel_all_orders_ws" => { crate::exchange_stubs::enqueue_spawn("cancel_all_orders_ws", args.to_vec()); crate::Value::Null },
            "cancel_order_ws" => { crate::exchange_stubs::enqueue_spawn("cancel_order_ws", args.to_vec()); crate::Value::Null },
            "cancel_orders_ws" => { crate::exchange_stubs::enqueue_spawn("cancel_orders_ws", args.to_vec()); crate::Value::Null },
            "create_order_ws" => { crate::exchange_stubs::enqueue_spawn("create_order_ws", args.to_vec()); crate::Value::Null },
            "create_public_subscription_request" => self.create_public_subscription_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
            "edit_order_ws" => { crate::exchange_stubs::enqueue_spawn("edit_order_ws", args.to_vec()); crate::Value::Null },
            "handle_all_bids_asks" => { self.handle_all_bids_asks(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_authentication" => { self.handle_authentication(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_bid_ask" => { self.handle_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_delta" => { self.handle_delta(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_error_message" => self.handle_error_message(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
            "handle_execute_response" => { self.handle_execute_response(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_message" => { self.handle_message(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_my_trade" => { self.handle_my_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_ohlcv" => { self.handle_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_order" => { self.handle_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_order_book" => { self.handle_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_pong" => self.handle_pong(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
            "handle_position" => { self.handle_position(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_subscription" => { self.handle_subscription(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_trade" => { self.handle_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_unsubscription" => { self.handle_unsubscription(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "handle_unsubscription_cache" => { self.handle_unsubscription_cache(args.get(0).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
            "parse_ws_all_bids_asks" => self.parse_ws_all_bids_asks(args.get(0).cloned().unwrap_or(crate::Value::Null)),
            "parse_ws_bid_ask" => self.parse_ws_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
            "parse_ws_my_trade" => self.parse_ws_my_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
            "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
            "parse_ws_position" => self.parse_ws_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
            "parse_ws_timestamp" => self.parse_ws_timestamp(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
            "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
            "ping" => self.ping(args.get(0).cloned().unwrap_or(crate::Value::Null)),
            "request_id" => self.request_id(),
            "sign_stream_authentication" => self.sign_stream_authentication(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null)),
            "un_watch_bids_asks" => { crate::exchange_stubs::enqueue_spawn("un_watch_bids_asks", args.to_vec()); crate::Value::Null },
            "un_watch_my_trades" => { crate::exchange_stubs::enqueue_spawn("un_watch_my_trades", args.to_vec()); crate::Value::Null },
            "un_watch_ohlcv" => { crate::exchange_stubs::enqueue_spawn("un_watch_ohlcv", args.to_vec()); crate::Value::Null },
            "un_watch_ohlcv_for_symbols" => { crate::exchange_stubs::enqueue_spawn("un_watch_ohlcv_for_symbols", args.to_vec()); crate::Value::Null },
            "un_watch_order_book" => { crate::exchange_stubs::enqueue_spawn("un_watch_order_book", args.to_vec()); crate::Value::Null },
            "un_watch_order_book_for_symbols" => { crate::exchange_stubs::enqueue_spawn("un_watch_order_book_for_symbols", args.to_vec()); crate::Value::Null },
            "un_watch_orders" => { crate::exchange_stubs::enqueue_spawn("un_watch_orders", args.to_vec()); crate::Value::Null },
            "un_watch_positions" => { crate::exchange_stubs::enqueue_spawn("un_watch_positions", args.to_vec()); crate::Value::Null },
            "un_watch_private" => { crate::exchange_stubs::enqueue_spawn("un_watch_private", args.to_vec()); crate::Value::Null },
            "un_watch_public" => { crate::exchange_stubs::enqueue_spawn("un_watch_public", args.to_vec()); crate::Value::Null },
            "un_watch_public_multiple" => { crate::exchange_stubs::enqueue_spawn("un_watch_public_multiple", args.to_vec()); crate::Value::Null },
            "un_watch_ticker" => { crate::exchange_stubs::enqueue_spawn("un_watch_ticker", args.to_vec()); crate::Value::Null },
            "un_watch_tickers" => { crate::exchange_stubs::enqueue_spawn("un_watch_tickers", args.to_vec()); crate::Value::Null },
            "un_watch_trades" => { crate::exchange_stubs::enqueue_spawn("un_watch_trades", args.to_vec()); crate::Value::Null },
            "un_watch_trades_for_symbols" => { crate::exchange_stubs::enqueue_spawn("un_watch_trades_for_symbols", args.to_vec()); crate::Value::Null },
            "watch_bids_asks" => { crate::exchange_stubs::enqueue_spawn("watch_bids_asks", args.to_vec()); crate::Value::Null },
            "watch_execute_request" => { crate::exchange_stubs::enqueue_spawn("watch_execute_request", args.to_vec()); crate::Value::Null },
            "watch_my_trades" => { crate::exchange_stubs::enqueue_spawn("watch_my_trades", args.to_vec()); crate::Value::Null },
            "watch_ohlcv" => { crate::exchange_stubs::enqueue_spawn("watch_ohlcv", args.to_vec()); crate::Value::Null },
            "watch_ohlcv_for_symbols" => { crate::exchange_stubs::enqueue_spawn("watch_ohlcv_for_symbols", args.to_vec()); crate::Value::Null },
            "watch_order_book" => { crate::exchange_stubs::enqueue_spawn("watch_order_book", args.to_vec()); crate::Value::Null },
            "watch_order_book_for_symbols" => { crate::exchange_stubs::enqueue_spawn("watch_order_book_for_symbols", args.to_vec()); crate::Value::Null },
            "watch_orders" => { crate::exchange_stubs::enqueue_spawn("watch_orders", args.to_vec()); crate::Value::Null },
            "watch_positions" => { crate::exchange_stubs::enqueue_spawn("watch_positions", args.to_vec()); crate::Value::Null },
            "watch_private" => { crate::exchange_stubs::enqueue_spawn("watch_private", args.to_vec()); crate::Value::Null },
            "watch_public" => { crate::exchange_stubs::enqueue_spawn("watch_public", args.to_vec()); crate::Value::Null },
            "watch_public_multiple" => { crate::exchange_stubs::enqueue_spawn("watch_public_multiple", args.to_vec()); crate::Value::Null },
            "watch_ticker" => { crate::exchange_stubs::enqueue_spawn("watch_ticker", args.to_vec()); crate::Value::Null },
            "watch_tickers" => { crate::exchange_stubs::enqueue_spawn("watch_tickers", args.to_vec()); crate::Value::Null },
            "watch_trades" => { crate::exchange_stubs::enqueue_spawn("watch_trades", args.to_vec()); crate::Value::Null },
            "watch_trades_for_symbols" => { crate::exchange_stubs::enqueue_spawn("watch_trades_for_symbols", args.to_vec()); crate::Value::Null },
            _ => crate::Value::Null,
        }
    }
}

impl std::ops::Deref for NadoCore {
    type Target = crate::exchange::Exchange;
    fn deref(&self) -> &crate::exchange::Exchange { std::ops::Deref::deref(&self.parent) }
}

impl std::ops::DerefMut for NadoCore {
    fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { std::ops::DerefMut::deref_mut(&mut self.parent) }
}

impl NadoCore {
    pub fn describe(&self) -> Value {
        return self.deep_extend(self.parent.describe(), &[Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("has".to_string(), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("ws".to_string(), Value::Bool(true));
        m.insert("cancelAllOrdersWs".to_string(), Value::Bool(true));
        m.insert("cancelOrderWs".to_string(), Value::Bool(true));
        m.insert("cancelOrdersWs".to_string(), Value::Bool(true));
        m.insert("createOrderWs".to_string(), Value::Bool(true));
        m.insert("editOrderWs".to_string(), Value::Bool(true));
        m.insert("watchBalance".to_string(), Value::Bool(false));
        m.insert("watchBidsAsks".to_string(), Value::Bool(true));
        m.insert("watchFundingRate".to_string(), Value::Bool(false));
        m.insert("watchFundingRates".to_string(), Value::Bool(false));
        m.insert("watchLiquidations".to_string(), Value::Bool(false));
        m.insert("watchLiquidationsForSymbols".to_string(), Value::Bool(false));
        m.insert("watchMyTrades".to_string(), Value::Bool(true));
        m.insert("unWatchBidsAsks".to_string(), Value::Bool(true));
        m.insert("unWatchMyTrades".to_string(), Value::Bool(true));
        m.insert("unWatchOHLCV".to_string(), Value::Bool(true));
        m.insert("unWatchOHLCVForSymbols".to_string(), Value::Bool(true));
        m.insert("unWatchOrderBook".to_string(), Value::Bool(true));
        m.insert("unWatchOrderBookForSymbols".to_string(), Value::Bool(true));
        m.insert("unWatchOrders".to_string(), Value::Bool(true));
        m.insert("unWatchPositions".to_string(), Value::Bool(true));
        m.insert("unWatchTicker".to_string(), Value::Bool(true));
        m.insert("unWatchTickers".to_string(), Value::Bool(true));
        m.insert("unWatchTrades".to_string(), Value::Bool(true));
        m.insert("unWatchTradesForSymbols".to_string(), Value::Bool(true));
        m.insert("watchOHLCV".to_string(), Value::Bool(true));
        m.insert("watchOHLCVForSymbols".to_string(), Value::Bool(true));
        m.insert("watchOrderBook".to_string(), Value::Bool(true));
        m.insert("watchOrderBookForSymbols".to_string(), Value::Bool(true));
        m.insert("watchOrders".to_string(), Value::Bool(true));
        m.insert("watchPositions".to_string(), Value::Bool(true));
        m.insert("watchTicker".to_string(), Value::Bool(true));
        m.insert("watchTickers".to_string(), Value::Bool(true));
        m.insert("watchTrades".to_string(), Value::Bool(true));
        m.insert("watchTradesForSymbols".to_string(), Value::Bool(true));
    m
}));
        m.insert("streaming".to_string(), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("ping".to_string(), Value::Str("ping".to_string()).clone());
        m.insert("keepAlive".to_string(), Value::Int(30000));
    m
}));
        m.insert("options".to_string(), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("tradesLimit".to_string(), Value::Int(1000));
        m.insert("requestId".to_string(), Value::Int(0));
    m
}));
        m.insert("urls".to_string(), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("api".to_string(), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("ws".to_string(), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("gateway".to_string(), Value::Str("wss://gateway.prod.nado.xyz/ws/v2".to_string()));
        m.insert("subscriptions".to_string(), Value::Str("wss://gateway.prod.nado.xyz/v1/subscribe".to_string()));
    m
}));
    m
}));
        m.insert("test".to_string(), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("ws".to_string(), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("gateway".to_string(), Value::Str("wss://gateway.test.nado.xyz/ws/v2".to_string()));
        m.insert("subscriptions".to_string(), Value::Str("wss://gateway.test.nado.xyz/v1/subscribe".to_string()));
    m
}));
    m
}));
    m
}));
    m
})]);

    Value::Null
}

    pub fn request_id(&mut self) -> Value {
        let mut requestId: Value = self.sum(&[self.safe_integer_k(self.options.clone(), "requestId", &[Value::Int(0)]), Value::Int(1)]);
        add_element_to_object(&mut self.options, &Value::Str("requestId".to_string()), requestId.clone());
        return requestId;

    Value::Null
}

/*
 * @method
 * @name nado#watchTrades
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description watches information on multiple trades made in a market
 * @param {string} symbol unified symbol of the market to fetch trades for
 * @param {int} [since] timestamp in ms of the earliest trade to fetch
 * @param {int} [limit] the maximum number of trades to fetch
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
 */
    pub async fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
        let mut since = get_arg(optional_args, 0, Value::Null);
        let mut limit = get_arg(optional_args, 1, Value::Null);
        let mut params = get_arg(optional_args, 2, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        let mut market: Value = self.market(symbol.clone());
        let mut messageHash: Value = add(&Value::Str("trade:".to_string()), &get_value(&market, &Value::Str("symbol".to_string())));
        let mut trades: Value = self.watch_public(Value::Str("trade".to_string()), market.clone(), messageHash.clone(), &[params.clone()]).await;
        if is_true(&self.newUpdates) {
            limit = trades.get_limit(get_value(&market, &Value::Str("symbol".to_string())), limit.clone());
        }
        return self.filter_by_since_limit(trades.clone(), &[since.clone(), limit.clone(), Value::Str("timestamp".to_string()), Value::Bool(true)]);

    Value::Null
}

/*
 * @method
 * @name nado#unWatchTrades
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches information on multiple trades made in a market
 * @param {string} symbol unified symbol of the market to unwatch trades for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        return self.un_watch_trades_for_symbols(Value::List(vec![symbol.clone()]), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchTradesForSymbols
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description get the list of most recent trades for a list of symbols
 * @param {string[]} symbols unified symbols of the markets to fetch trades for
 * @param {int} [since] timestamp in ms of the earliest trade to fetch
 * @param {int} [limit] the maximum number of trades to fetch
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
 */
    pub async fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> Value {
        let mut since = get_arg(optional_args, 0, Value::Null);
        let mut limit = get_arg(optional_args, 1, Value::Null);
        let mut params = get_arg(optional_args, 2, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        let mut symbolsLength: Value = get_array_length(&symbols);
        if is_equal(&symbolsLength, &Value::Int(0)) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" watchTradesForSymbols() requires a non-empty array of symbols".to_string()))));
        }
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
        let mut markets: Value = Value::List(vec![]);
        let mut messageHashes: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_501: bool = true;
            while { if !__for_first_501 { i = add(&i, &Value::Int(1)); } __for_first_501 = false; is_less_than(&i, &get_array_length(&symbols)) } {
            let mut market: Value = self.market(get_value(&symbols, &i));
            append_to_array(&mut markets, market.clone());
            append_to_array(&mut messageHashes, add(&Value::Str("trade:".to_string()), &get_value(&market, &Value::Str("symbol".to_string()))));
        }
        }
        let mut trades: Value = self.watch_public_multiple(Value::Str("trade".to_string()), markets.clone(), messageHashes.clone(), &[params.clone()]).await;
        if is_true(&self.newUpdates) {
            let mut first: Value = self.safe_dict(trades.clone(), Value::Int(0), &[]);
            let mut tradeSymbol: Value = self.safe_string_k(first.clone(), "symbol", &[]);
            limit = trades.get_limit(tradeSymbol.clone(), limit.clone());
        }
        return self.filter_by_since_limit(trades.clone(), &[since.clone(), limit.clone(), Value::Str("timestamp".to_string()), Value::Bool(true)]);

    Value::Null
}

/*
 * @method
 * @name nado#unWatchTradesForSymbols
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches information on multiple trades made in a list of markets
 * @param {string[]} symbols unified symbols of the markets to unwatch trades for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        let mut symbolsLength: Value = get_array_length(&symbols);
        if is_equal(&symbolsLength, &Value::Int(0)) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" unWatchTradesForSymbols() requires a non-empty array of symbols".to_string()))));
        }
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
        let mut markets: Value = Value::List(vec![]);
        let mut messageHashes: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_502: bool = true;
            while { if !__for_first_502 { i = add(&i, &Value::Int(1)); } __for_first_502 = false; is_less_than(&i, &get_array_length(&symbols)) } {
            let mut market: Value = self.market(get_value(&symbols, &i));
            append_to_array(&mut markets, market.clone());
            append_to_array(&mut messageHashes, add(&Value::Str("trade:".to_string()), &get_value(&market, &Value::Str("symbol".to_string()))));
        }
        }
        return self.un_watch_public_multiple(Value::Str("trade".to_string()), markets.clone(), messageHashes.clone(), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchOrderBook
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
 * @param {string} symbol unified symbol of the market to fetch the order book for
 * @param {int} [limit] the maximum amount of order book entries to return
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {OrderBook} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
 */
    pub async fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
        let mut limit = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        let mut market: Value = self.market(symbol.clone());
        let mut messageHash: Value = add(&Value::Str("orderbook:".to_string()), &get_value(&market, &Value::Str("symbol".to_string())));
        if !is_true(&(Value::Bool(in_op(&self.orderbooks, &get_value(&market, &Value::Str("symbol".to_string())))))) {
            let mut snapshot: Value = self.fetch_order_book(symbol.clone(), &[limit.clone()]).await;
            { let __be_tmp = self.order_book(&[snapshot.clone(), limit.clone()]); add_element_to_object(&mut self.orderbooks, &get_value(&market, &Value::Str("symbol".to_string())), __be_tmp); };
        }
        let mut orderbook: Value = self.watch_public(Value::Str("book_depth".to_string()), market.clone(), messageHash.clone(), &[params.clone()]).await;
        return orderbook.limit();

    Value::Null
}

/*
 * @method
 * @name nado#unWatchOrderBook
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
 * @param {string} symbol unified symbol of the market to unwatch the order book for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        return self.un_watch_order_book_for_symbols(Value::List(vec![symbol.clone()]), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchOrderBookForSymbols
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for a list of symbols
 * @param {string[]} symbols unified symbols of the markets to fetch the order book for
 * @param {int} [limit] the maximum amount of order book entries to return
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {OrderBook} an [order book structure]{@link https://docs.ccxt.com/#/?id=order-book-structure}
 */
    pub async fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> Value {
        let mut limit = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        let mut symbolsLength: Value = get_array_length(&symbols);
        if is_equal(&symbolsLength, &Value::Int(0)) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" watchOrderBookForSymbols() requires a non-empty array of symbols".to_string()))));
        }
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
        let mut markets: Value = Value::List(vec![]);
        let mut messageHashes: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_503: bool = true;
            while { if !__for_first_503 { i = add(&i, &Value::Int(1)); } __for_first_503 = false; is_less_than(&i, &get_array_length(&symbols)) } {
            let mut symbol: Value = get_value(&symbols, &i);
            let mut symbol: Value = get_value(&symbols, &i);
            let mut market: Value = self.market(symbol.clone());
            let mut messageHash: Value = add(&Value::Str("orderbook:".to_string()), &get_value(&market, &Value::Str("symbol".to_string())));
            append_to_array(&mut markets, market.clone());
            append_to_array(&mut messageHashes, messageHash.clone());
            if !is_true(&(Value::Bool(in_op(&self.orderbooks, &get_value(&market, &Value::Str("symbol".to_string())))))) {
                let mut snapshot: Value = self.fetch_order_book(symbol.clone(), &[limit.clone()]).await;
                { let __be_tmp = self.order_book(&[snapshot.clone(), limit.clone()]); add_element_to_object(&mut self.orderbooks, &get_value(&market, &Value::Str("symbol".to_string())), __be_tmp); };
            }
        }
        }
        let mut orderbook: Value = self.watch_public_multiple(Value::Str("book_depth".to_string()), markets.clone(), messageHashes.clone(), &[params.clone()]).await;
        return orderbook.limit();

    Value::Null
}

/*
 * @method
 * @name nado#unWatchOrderBookForSymbols
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for a list of symbols
 * @param {string[]} symbols unified symbols of the markets to unwatch the order book for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        let mut symbolsLength: Value = get_array_length(&symbols);
        if is_equal(&symbolsLength, &Value::Int(0)) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" unWatchOrderBookForSymbols() requires a non-empty array of symbols".to_string()))));
        }
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
        let mut markets: Value = Value::List(vec![]);
        let mut messageHashes: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_504: bool = true;
            while { if !__for_first_504 { i = add(&i, &Value::Int(1)); } __for_first_504 = false; is_less_than(&i, &get_array_length(&symbols)) } {
            let mut market: Value = self.market(get_value(&symbols, &i));
            append_to_array(&mut markets, market.clone());
            append_to_array(&mut messageHashes, add(&Value::Str("orderbook:".to_string()), &get_value(&market, &Value::Str("symbol".to_string()))));
        }
        }
        return self.un_watch_public_multiple(Value::Str("book_depth".to_string()), markets.clone(), messageHashes.clone(), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchOHLCV
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
 * @param {string} symbol unified symbol of the market to fetch OHLCV data for
 * @param {string} timeframe the length of time each candle represents
 * @param {int} [since] timestamp in ms of the earliest candle to fetch
 * @param {int} [limit] the maximum amount of candles to fetch
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
 */
    pub async fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
        let mut since = get_arg(optional_args, 1, Value::Null);
        let mut limit = get_arg(optional_args, 2, Value::Null);
        let mut params = get_arg(optional_args, 3, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        let mut market: Value = self.market(symbol.clone());
        let mut messageHash: Value = add(&add(&add(&Value::Str("ohlcv:".to_string()), &timeframe), &Value::Str(":".to_string())), &get_value(&market, &Value::Str("symbol".to_string())));
        let mut request: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("granularity".to_string(), self.safe_integer(self.timeframes.clone(), timeframe.clone(), &[self.parse_timeframe(timeframe.clone())]));
            m
        });
        let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
        let mut result: Value = self.watch_public(Value::Str("latest_candlestick".to_string()), market.clone(), messageHash.clone(), &[__ws_arg_0]).await;
        let mut stored: Value = get_value(&result, &Value::Int(2));
        if is_true(&self.newUpdates) {
            limit = stored.get_limit(get_value(&market, &Value::Str("symbol".to_string())), limit.clone());
        }
        return self.filter_by_since_limit(stored.clone(), &[since.clone(), limit.clone(), Value::Int(0), Value::Bool(true)]);

    Value::Null
}

/*
 * @method
 * @name nado#watchOHLCVForSymbols
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of multiple markets
 * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to watch OHLCV data for, example [['BTC/USDT0:USDT0', '1m'], ['ETH/USDT0:USDT0', '5m']]
 * @param {int} [since] timestamp in ms of the earliest candle to fetch
 * @param {int} [limit] the maximum amount of candles to fetch
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} A dictionary of {@link https://docs.ccxt.com/#/?id=ohlcv-structure OHLCV} structures indexed by market symbols
 */
    pub async fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> Value {
        let mut since = get_arg(optional_args, 0, Value::Null);
        let mut limit = get_arg(optional_args, 1, Value::Null);
        let mut params = get_arg(optional_args, 2, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut symbolsLength: Value = get_array_length(&symbolsAndTimeframes);
        if is_equal(&symbolsLength, &Value::Int(0)) || !is_true(&Value::Bool(is_array(&get_value(&symbolsAndTimeframes, &Value::Int(0))))) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" watchOHLCVForSymbols() requires a an array of symbols and timeframes, like  [['BTC/USDT0:USDT0', '1m'], ['ETH/USDT0:USDT0', '5m']]".to_string()))));
        }
        self.load_markets(&[]).await;
        let mut markets: Value = Value::List(vec![]);
        let mut messageHashes: Value = Value::List(vec![]);
        let mut subscriptionParams: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_505: bool = true;
            while { if !__for_first_505 { i = add(&i, &Value::Int(1)); } __for_first_505 = false; is_less_than(&i, &get_array_length(&symbolsAndTimeframes)) } {
            let mut symbolAndTimeframe: Value = get_value(&symbolsAndTimeframes, &i);
            let mut symbolAndTimeframe: Value = get_value(&symbolsAndTimeframes, &i);
            let mut marketSymbol: Value = self.safe_string(symbolAndTimeframe.clone(), Value::Int(0), &[]);
            let mut timeframe: Value = self.safe_string(symbolAndTimeframe.clone(), Value::Int(1), &[Value::Str("1m".to_string())]);
            let mut market: Value = self.market(marketSymbol.clone());
            append_to_array(&mut markets, market.clone());
            append_to_array(&mut messageHashes, add(&add(&add(&Value::Str("ohlcv:".to_string()), &timeframe), &Value::Str(":".to_string())), &get_value(&market, &Value::Str("symbol".to_string()))));
            let __ws_arg_1 = self.safe_integer(self.timeframes.clone(), timeframe.clone(), &[self.parse_timeframe(timeframe.clone())]);
            append_to_array(&mut subscriptionParams, self.extend(Value::Map({
                let mut m = indexmap::IndexMap::new();
                    m.insert("granularity".to_string(), __ws_arg_1);
                m
            }), &[params.clone()]));
        }
        }
        let mut resultSymbolresultTimeframestoredVariable = self.watch_public_multiple(Value::Str("latest_candlestick".to_string()), markets.clone(), messageHashes.clone(), &[params.clone(), subscriptionParams.clone()]).await;
        let mut resultSymbol: Value = get_value(&resultSymbolresultTimeframestoredVariable, &Value::Int(0));
        let mut resultTimeframe: Value = get_value(&resultSymbolresultTimeframestoredVariable, &Value::Int(1));
        let mut stored: Value = get_value(&resultSymbolresultTimeframestoredVariable, &Value::Int(2));
        if is_true(&self.newUpdates) {
            limit = stored.get_limit(resultSymbol.clone(), limit.clone());
        }
        let mut filtered: Value = self.filter_by_since_limit(stored.clone(), &[since.clone(), limit.clone(), Value::Int(0), Value::Bool(true)]);
        return self.create_ohlcv_object(resultSymbol.clone(), resultTimeframe.clone(), filtered.clone());

    Value::Null
}

/*
 * @method
 * @name nado#unWatchOHLCV
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
 * @param {string} symbol unified symbol of the market to unwatch OHLCV data for
 * @param {string} timeframe the length of time each candle represents
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        return self.un_watch_ohlcv_for_symbols(Value::List(vec![Value::List(vec![symbol.clone(), timeframe.clone()])]), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#unWatchOHLCVForSymbols
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of multiple markets
 * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to unwatch OHLCV data for, example [['BTC/USDT0:USDT0', '1m'], ['ETH/USDT0:USDT0', '5m']]
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut symbolsLength: Value = get_array_length(&symbolsAndTimeframes);
        if is_equal(&symbolsLength, &Value::Int(0)) || !is_true(&Value::Bool(is_array(&get_value(&symbolsAndTimeframes, &Value::Int(0))))) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" unWatchOHLCVForSymbols() requires a an array of symbols and timeframes, like  [['BTC/USDT0:USDT0', '1m'], ['ETH/USDT0:USDT0', '5m']]".to_string()))));
        }
        self.load_markets(&[]).await;
        let mut markets: Value = Value::List(vec![]);
        let mut messageHashes: Value = Value::List(vec![]);
        let mut subscriptionParams: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_506: bool = true;
            while { if !__for_first_506 { i = add(&i, &Value::Int(1)); } __for_first_506 = false; is_less_than(&i, &get_array_length(&symbolsAndTimeframes)) } {
            let mut symbolAndTimeframe: Value = get_value(&symbolsAndTimeframes, &i);
            let mut symbolAndTimeframe: Value = get_value(&symbolsAndTimeframes, &i);
            let mut marketSymbol: Value = self.safe_string(symbolAndTimeframe.clone(), Value::Int(0), &[]);
            let mut timeframe: Value = self.safe_string(symbolAndTimeframe.clone(), Value::Int(1), &[Value::Str("1m".to_string())]);
            let mut market: Value = self.market(marketSymbol.clone());
            append_to_array(&mut markets, market.clone());
            append_to_array(&mut messageHashes, add(&add(&add(&Value::Str("ohlcv:".to_string()), &timeframe), &Value::Str(":".to_string())), &get_value(&market, &Value::Str("symbol".to_string()))));
            let __ws_arg_2 = self.safe_integer(self.timeframes.clone(), timeframe.clone(), &[self.parse_timeframe(timeframe.clone())]);
            append_to_array(&mut subscriptionParams, self.extend(Value::Map({
                let mut m = indexmap::IndexMap::new();
                    m.insert("granularity".to_string(), __ws_arg_2);
                m
            }), &[params.clone()]));
        }
        }
        return self.un_watch_public_multiple(Value::Str("latest_candlestick".to_string()), markets.clone(), messageHashes.clone(), &[params.clone(), subscriptionParams.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchTicker
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description watches a price ticker with the best bid and ask for a specific market
 * @param {string} symbol unified symbol of the market to fetch the ticker for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
 */
    pub async fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        symbol = self.symbol(symbol.clone());
        let mut tickers: Value = self.watch_tickers(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
        return get_value(&tickers, &symbol);

    Value::Null
}

/*
 * @method
 * @name nado#unWatchTicker
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches a price ticker with the best bid and ask for a specific market
 * @param {string} symbol unified symbol of the market to unwatch the ticker for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        return self.un_watch_tickers(&[Value::List(vec![symbol.clone()]), params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchTickers
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description watches price tickers with the best bid and ask for all markets of a specific list
 * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
 */
    pub async fn watch_tickers(&mut self, optional_args: &[Value]) -> Value {
        let mut symbols = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
        let mut market: Value = Value::Null;
        let mut messageHash: Value = Value::Str("ticker".to_string());
        let mut streamType: Value = Value::Str("all_bbo".to_string());
        if !is_equal(&symbols, &Value::Null) {
            let mut symbolsLength: Value = get_array_length(&symbols);
            if is_equal(&symbolsLength, &Value::Int(1)) {
                market = self.market(get_value(&symbols, &Value::Int(0)));
                messageHash = add(&Value::Str("ticker:".to_string()), &get_value(&market, &Value::Str("symbol".to_string())));
                streamType = Value::Str("best_bid_offer".to_string());
            }
        }
        let mut ticker: Value = self.watch_public(streamType.clone(), market.clone(), messageHash.clone(), &[params.clone()]).await;
        if is_true(&self.newUpdates) {
            if is_equal(&messageHash, &Value::Str("ticker".to_string())) {
                return self.filter_by_array(ticker.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
            }
            let mut tickers: Value = Value::Map({
                let mut m = indexmap::IndexMap::new();
                m
            });
            add_element_to_object(&mut tickers, &get_value(&ticker, &Value::Str("symbol".to_string())), ticker.clone());
            return tickers;
        }
        return self.filter_by_array(self.tickers.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);

    Value::Null
}

/*
 * @method
 * @name nado#unWatchTickers
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches price tickers with the best bid and ask for all markets of a specific list
 * @param {string[]} [symbols] unified symbols of the markets to unwatch the ticker for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_tickers(&mut self, optional_args: &[Value]) -> Value {
        let mut symbols = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
        let mut market: Value = Value::Null;
        let mut messageHash: Value = Value::Str("ticker".to_string());
        let mut streamType: Value = Value::Str("all_bbo".to_string());
        if !is_equal(&symbols, &Value::Null) {
            let mut symbolsLength: Value = get_array_length(&symbols);
            if is_equal(&symbolsLength, &Value::Int(1)) {
                market = self.market(get_value(&symbols, &Value::Int(0)));
                messageHash = add(&Value::Str("ticker:".to_string()), &get_value(&market, &Value::Str("symbol".to_string())));
                streamType = Value::Str("best_bid_offer".to_string());
            }
        }
        return self.un_watch_public(streamType.clone(), market.clone(), messageHash.clone(), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchBidsAsks
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description watches best bid & ask for symbols
 * @param {string[]} symbols unified symbols of the markets to fetch the bids and asks for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
 */
    pub async fn watch_bids_asks(&mut self, optional_args: &[Value]) -> Value {
        let mut symbols = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
        let mut market: Value = Value::Null;
        let mut messageHash: Value = Value::Str("bidask".to_string());
        let mut streamType: Value = Value::Str("all_bbo".to_string());
        if !is_equal(&symbols, &Value::Null) {
            let mut symbolsLength: Value = get_array_length(&symbols);
            if is_equal(&symbolsLength, &Value::Int(1)) {
                market = self.market(get_value(&symbols, &Value::Int(0)));
                messageHash = add(&Value::Str("bidask:".to_string()), &get_value(&market, &Value::Str("symbol".to_string())));
                streamType = Value::Str("best_bid_offer".to_string());
            }
        }
        let mut ticker: Value = self.watch_public(streamType.clone(), market.clone(), messageHash.clone(), &[params.clone()]).await;
        if is_true(&self.newUpdates) {
            if is_equal(&messageHash, &Value::Str("bidask".to_string())) {
                return self.filter_by_array(ticker.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
            }
            let mut tickers: Value = Value::Map({
                let mut m = indexmap::IndexMap::new();
                m
            });
            add_element_to_object(&mut tickers, &get_value(&ticker, &Value::Str("symbol".to_string())), ticker.clone());
            return tickers;
        }
        return self.filter_by_array(self.bidsasks.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);

    Value::Null
}

/*
 * @method
 * @name nado#unWatchBidsAsks
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches best bid & ask for symbols
 * @param {string[]} symbols unified symbols of the markets to unwatch the bids and asks for
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> Value {
        let mut symbols = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.load_markets(&[]).await;
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
        let mut market: Value = Value::Null;
        let mut messageHash: Value = Value::Str("bidask".to_string());
        let mut streamType: Value = Value::Str("all_bbo".to_string());
        if !is_equal(&symbols, &Value::Null) {
            let mut symbolsLength: Value = get_array_length(&symbols);
            if is_equal(&symbolsLength, &Value::Int(1)) {
                market = self.market(get_value(&symbols, &Value::Int(0)));
                messageHash = add(&Value::Str("bidask:".to_string()), &get_value(&market, &Value::Str("symbol".to_string())));
                streamType = Value::Str("best_bid_offer".to_string());
            }
        }
        return self.un_watch_public(streamType.clone(), market.clone(), messageHash.clone(), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchOrders
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/authentication
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/events
 * @description watches information on multiple orders made by the user
 * @param {string} symbol unified market symbol of the market orders were made in
 * @param {int} [since] the earliest time in ms to fetch orders for
 * @param {int} [limit] the maximum number of order structures to retrieve
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
 */
    pub async fn watch_orders(&mut self, optional_args: &[Value]) -> Value {
        let mut symbol = get_arg(optional_args, 0, Value::Null);
        let mut since = get_arg(optional_args, 1, Value::Null);
        let mut limit = get_arg(optional_args, 2, Value::Null);
        let mut params = get_arg(optional_args, 3, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let __ws_arg_3 = self.extend(Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}), &[params.clone()]);
        self.authenticate(&[__ws_arg_3]).await;
        let mut market: Value = Value::Null;
        let mut messageHash: Value = Value::Str("orders".to_string());
        let mut productId: Value = Value::Null;
        if !is_equal(&symbol, &Value::Null) {
            market = self.market(symbol.clone());
            symbol = get_value(&market, &Value::Str("symbol".to_string()));
            messageHash = add(&messageHash, &add(&Value::Str(":".to_string()), &symbol));
            productId = self.parse_to_int(get_value(&market, &Value::Str("id".to_string())));
        }
        let mut subaccount: Value = Value::Null;
        { let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("watchOrders".to_string()), Value::Str("subaccount".to_string()), &[Value::Str("default".to_string())]); subaccount = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
        let mut sender: Value = self.parent.create_subaccount(self.walletAddress.clone(), &[subaccount.clone()]);
        let mut stream: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("type".to_string(), Value::Str("order_update".to_string()));
                m.insert("subaccount".to_string(), sender.clone());
                m.insert("product_id".to_string(), productId.clone());
            m
        });
        let mut orders: Value = self.watch_private(Value::Str("order_update".to_string()), stream.clone(), messageHash.clone(), &[params.clone()]).await;
        if is_true(&self.newUpdates) {
            limit = orders.get_limit(symbol.clone(), limit.clone());
        }
        return self.filter_by_symbol_since_limit(orders.clone(), &[symbol.clone(), since.clone(), limit.clone(), Value::Bool(true)]);

    Value::Null
}

/*
 * @method
 * @name nado#unWatchOrders
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/authentication
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches information on multiple orders made by the user
 * @param {string} symbol unified market symbol of the market orders were made in
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_orders(&mut self, optional_args: &[Value]) -> Value {
        let mut symbol = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let __ws_arg_4 = self.extend(Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}), &[params.clone()]);
        self.authenticate(&[__ws_arg_4]).await;
        let mut market: Value = Value::Null;
        let mut messageHash: Value = Value::Str("orders".to_string());
        let mut productId: Value = Value::Null;
        if !is_equal(&symbol, &Value::Null) {
            market = self.market(symbol.clone());
            symbol = get_value(&market, &Value::Str("symbol".to_string()));
            messageHash = add(&messageHash, &add(&Value::Str(":".to_string()), &symbol));
            productId = self.parse_to_int(get_value(&market, &Value::Str("id".to_string())));
        }
        let mut subaccount: Value = Value::Null;
        { let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("unWatchOrders".to_string()), Value::Str("subaccount".to_string()), &[Value::Str("default".to_string())]); subaccount = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
        let mut sender: Value = self.parent.create_subaccount(self.walletAddress.clone(), &[subaccount.clone()]);
        let mut stream: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("type".to_string(), Value::Str("order_update".to_string()));
                m.insert("subaccount".to_string(), sender.clone());
                m.insert("product_id".to_string(), productId.clone());
            m
        });
        return self.un_watch_private(stream.clone(), messageHash.clone(), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchMyTrades
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/authentication
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/events
 * @description watches information on multiple trades made by the user
 * @param {string} symbol unified market symbol of the market orders were made in
 * @param {int} [since] the earliest time in ms to fetch trades for
 * @param {int} [limit] the maximum number of trade structures to retrieve
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
 */
    pub async fn watch_my_trades(&mut self, optional_args: &[Value]) -> Value {
        let mut symbol = get_arg(optional_args, 0, Value::Null);
        let mut since = get_arg(optional_args, 1, Value::Null);
        let mut limit = get_arg(optional_args, 2, Value::Null);
        let mut params = get_arg(optional_args, 3, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let __ws_arg_5 = self.extend(Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}), &[params.clone()]);
        self.authenticate(&[__ws_arg_5]).await;
        let mut market: Value = Value::Null;
        let mut messageHash: Value = Value::Str("myTrades".to_string());
        let mut productId: Value = Value::Null;
        if !is_equal(&symbol, &Value::Null) {
            market = self.market(symbol.clone());
            symbol = get_value(&market, &Value::Str("symbol".to_string()));
            messageHash = add(&messageHash, &add(&Value::Str(":".to_string()), &symbol));
            productId = self.parse_to_int(get_value(&market, &Value::Str("id".to_string())));
        }
        let mut subaccount: Value = Value::Null;
        { let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("watchMyTrades".to_string()), Value::Str("subaccount".to_string()), &[Value::Str("default".to_string())]); subaccount = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
        let mut sender: Value = self.parent.create_subaccount(self.walletAddress.clone(), &[subaccount.clone()]);
        let mut stream: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("type".to_string(), Value::Str("fill".to_string()));
                m.insert("subaccount".to_string(), sender.clone());
                m.insert("product_id".to_string(), productId.clone());
            m
        });
        let mut trades: Value = self.watch_private(Value::Str("fill".to_string()), stream.clone(), messageHash.clone(), &[params.clone()]).await;
        if is_true(&self.newUpdates) {
            limit = trades.get_limit(symbol.clone(), limit.clone());
        }
        return self.filter_by_symbol_since_limit(trades.clone(), &[symbol.clone(), since.clone(), limit.clone(), Value::Bool(true)]);

    Value::Null
}

/*
 * @method
 * @name nado#unWatchMyTrades
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/authentication
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches information on multiple trades made by the user
 * @param {string} symbol unified market symbol of the market orders were made in
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> Value {
        let mut symbol = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let __ws_arg_6 = self.extend(Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}), &[params.clone()]);
        self.authenticate(&[__ws_arg_6]).await;
        let mut market: Value = Value::Null;
        let mut messageHash: Value = Value::Str("myTrades".to_string());
        let mut productId: Value = Value::Null;
        if !is_equal(&symbol, &Value::Null) {
            market = self.market(symbol.clone());
            symbol = get_value(&market, &Value::Str("symbol".to_string()));
            messageHash = add(&messageHash, &add(&Value::Str(":".to_string()), &symbol));
            productId = self.parse_to_int(get_value(&market, &Value::Str("id".to_string())));
        }
        let mut subaccount: Value = Value::Null;
        { let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("unWatchMyTrades".to_string()), Value::Str("subaccount".to_string()), &[Value::Str("default".to_string())]); subaccount = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
        let mut sender: Value = self.parent.create_subaccount(self.walletAddress.clone(), &[subaccount.clone()]);
        let mut stream: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("type".to_string(), Value::Str("fill".to_string()));
                m.insert("subaccount".to_string(), sender.clone());
                m.insert("product_id".to_string(), productId.clone());
            m
        });
        return self.un_watch_private(stream.clone(), messageHash.clone(), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#watchPositions
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/authentication
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/events
 * @description watches information on user positions
 * @param {string[]} [symbols] unified market symbols
 * @param {int} [since] the earliest time in ms to fetch positions for
 * @param {int} [limit] the maximum number of position structures to retrieve
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
 */
    pub async fn watch_positions(&mut self, optional_args: &[Value]) -> Value {
        let mut symbols = get_arg(optional_args, 0, Value::Null);
        let mut since = get_arg(optional_args, 1, Value::Null);
        let mut limit = get_arg(optional_args, 2, Value::Null);
        let mut params = get_arg(optional_args, 3, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let __ws_arg_7 = self.extend(Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}), &[params.clone()]);
        self.authenticate(&[__ws_arg_7]).await;
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
        let mut messageHash: Value = Value::Str("positions".to_string());
        let mut productId: Value = Value::Null;
        if !is_equal(&symbols, &Value::Null) {
            let mut symbolsLength: Value = get_array_length(&symbols);
            if is_equal(&symbolsLength, &Value::Int(1)) {
                let mut market: Value = self.market(get_value(&symbols, &Value::Int(0)));
                messageHash = add(&messageHash, &add(&Value::Str(":".to_string()), &get_value(&market, &Value::Str("symbol".to_string()))));
                productId = self.parse_to_int(get_value(&market, &Value::Str("id".to_string())));
            }
        }
        let mut subaccount: Value = Value::Null;
        { let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("watchPositions".to_string()), Value::Str("subaccount".to_string()), &[Value::Str("default".to_string())]); subaccount = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
        let mut sender: Value = self.parent.create_subaccount(self.walletAddress.clone(), &[subaccount.clone()]);
        let mut stream: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("type".to_string(), Value::Str("position_change".to_string()));
                m.insert("subaccount".to_string(), sender.clone());
                m.insert("product_id".to_string(), productId.clone());
            m
        });
        let mut positions: Value = self.watch_private(Value::Str("position_change".to_string()), stream.clone(), messageHash.clone(), &[params.clone()]).await;
        if is_true(&self.newUpdates) {
            return positions;
        }
        return self.filter_by_symbols_since_limit(self.positions.clone(), &[symbols.clone(), since.clone(), limit.clone(), Value::Bool(true)]);

    Value::Null
}

/*
 * @method
 * @name nado#unWatchPositions
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/authentication
 * @see https://docs.nado.xyz/developer-resources/api/subscriptions/streams
 * @description unWatches information on user positions
 * @param {string[]} [symbols] unified market symbols
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @returns {object} the exchange response
 */
    pub async fn un_watch_positions(&mut self, optional_args: &[Value]) -> Value {
        let mut symbols = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let __ws_arg_8 = self.extend(Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}), &[params.clone()]);
        self.authenticate(&[__ws_arg_8]).await;
        symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
        let mut messageHash: Value = Value::Str("positions".to_string());
        let mut productId: Value = Value::Null;
        if !is_equal(&symbols, &Value::Null) {
            let mut symbolsLength: Value = get_array_length(&symbols);
            if is_equal(&symbolsLength, &Value::Int(1)) {
                let mut market: Value = self.market(get_value(&symbols, &Value::Int(0)));
                messageHash = add(&messageHash, &add(&Value::Str(":".to_string()), &get_value(&market, &Value::Str("symbol".to_string()))));
                productId = self.parse_to_int(get_value(&market, &Value::Str("id".to_string())));
            }
        }
        let mut subaccount: Value = Value::Null;
        { let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("unWatchPositions".to_string()), Value::Str("subaccount".to_string()), &[Value::Str("default".to_string())]); subaccount = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
        let mut sender: Value = self.parent.create_subaccount(self.walletAddress.clone(), &[subaccount.clone()]);
        let mut stream: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("type".to_string(), Value::Str("position_change".to_string()));
                m.insert("subaccount".to_string(), sender.clone());
                m.insert("product_id".to_string(), productId.clone());
            m
        });
        return self.un_watch_private(stream.clone(), messageHash.clone(), &[params.clone()]).await;

    Value::Null
}

/*
 * @method
 * @name nado#createOrderWs
 * @description create a trade order over the v2 gateway WebSocket
 * @see https://docs.nado.xyz/developer-resources/api/gateway/websocket-v2
 * @see https://docs.nado.xyz/developer-resources/api/gateway/executes/place-order
 * @param {string} symbol unified symbol of the market to create an order in
 * @param {string} type must be 'limit'
 * @param {string} side 'buy' or 'sell'
 * @param {float} amount how much of currency you want to trade in units of base currency
 * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @param {string} [params.subaccount] the 12-byte subaccount identifier, defaults to 'default'
 * @param {string|int} [params.expiration] order expiration timestamp in seconds, defaults to 4294967295
 * @param {string|int} [params.appendix] pre-encoded order appendix
 * @param {boolean} [params.reduceOnly] true if the order should only reduce position
 * @param {boolean} [params.postOnly] true to create a post-only order
 * @param {string} [params.timeInForce] 'GTC', 'IOC', 'FOK', or 'PO'
 * @param {boolean} [params.spotLeverage] whether leverage should be used for spot, defaults to true, exchange-specific alias params.spot_leverage
 * @param {int} [params.id] client-provided request id used to correlate the out-of-order v2 response, autogenerated when omitted
 * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
 */
    pub async fn create_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
        let mut price = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let mut market: Value = self.market(symbol.clone());
        let __ws_arg_9 = self.request_id();
        params = self.extend(Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("id".to_string(), __ws_arg_9);
            m
        }), &[params.clone()]);
        let mut requestIdString: Value = self.safe_string_k(params.clone(), "id", &[]);
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" ws execute requires params.id".to_string()))));
        }
        let mut request: Value = self.parent.create_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
        let mut placeOrder: Value = self.safe_dict_k(request.clone(), "place_order", &[Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        })]);
        if is_true(&Value::Bool(in_op(&placeOrder, &Value::Str("trigger".to_string())))) {
            panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWs() does not support trigger orders, use createOrder() instead".to_string()))));
        }
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires params.id".to_string()))));
        }
        let mut response: Value = self.watch_execute_request(requestIdString.clone(), request.clone()).await;
        let __ws_arg_10 = self.extend(Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("place_order".to_string(), placeOrder.clone());
    m
}), &[response.clone()]);
        return self.parse_order(__ws_arg_10, &[market.clone()]);

    Value::Null
}

/*
 * @method
 * @name nado#editOrderWs
 * @description edit a trade order over the v2 gateway WebSocket
 * @see https://docs.nado.xyz/developer-resources/api/gateway/websocket-v2
 * @see https://docs.nado.xyz/developer-resources/api/gateway/executes/cancel-and-place
 * @param {string} id order id
 * @param {string} symbol unified symbol of the market to edit an order in
 * @param {string} type must be 'limit'
 * @param {string} side 'buy' or 'sell'
 * @param {float} amount how much of currency you want to trade in units of base currency
 * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @param {string} [params.subaccount] the 12-byte subaccount identifier, defaults to 'default'
 * @param {string|int} [params.expiration] order expiration timestamp in seconds, defaults to 4294967295
 * @param {string|int} [params.appendix] pre-encoded order appendix
 * @param {boolean} [params.reduceOnly] true if the order should only reduce position
 * @param {boolean} [params.postOnly] true to create a post-only order
 * @param {string} [params.timeInForce] 'GTC', 'IOC', 'FOK', or 'PO'
 * @param {boolean} [params.spotLeverage] whether leverage should be used for spot, defaults to true, exchange-specific alias params.spot_leverage
 * @param {boolean} [params.placeRequiresUnfilled] when true, aborts the new order if the canceled order had partial fills or the cancel failed, exchange-specific alias params.place_requires_unfilled, defaults to true
 * @param {int} [params.id] client-provided request id used to correlate the out-of-order v2 response, autogenerated when omitted
 * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
 */
    pub async fn edit_order_ws(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
        let mut amount = get_arg(optional_args, 0, Value::Null);
        let mut price = get_arg(optional_args, 1, Value::Null);
        let mut params = get_arg(optional_args, 2, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let mut market: Value = self.market(symbol.clone());
        // for cancel_and_place the request id is echoed from the nested place_order object
        let __ws_arg_11 = self.request_id();
        params = self.extend(Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("id".to_string(), __ws_arg_11);
            m
        }), &[params.clone()]);
        let mut requestIdString: Value = self.safe_string_k(params.clone(), "id", &[]);
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" ws execute requires params.id".to_string()))));
        }
        let mut request: Value = self.parent.edit_order_request(id.clone(), symbol.clone(), type_var.clone(), side.clone(), &[amount.clone(), price.clone(), params.clone()]).await;
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires params.id".to_string()))));
        }
        let mut response: Value = self.watch_execute_request(requestIdString.clone(), request.clone()).await;
        //
        //     {
        //         "status": "success",
        //         "signature": "0x...",
        //         "data": {
        //             "digest": "0x..."
        //         },
        //         "request_type": "execute_cancel_and_place",
        //         "id": 100
        //     }
        //
        let mut cancelAndPlace: Value = self.safe_dict_k(request.clone(), "cancel_and_place", &[Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        })]);
        let mut placeOrder: Value = self.safe_dict_k(cancelAndPlace.clone(), "place_order", &[Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        })]);
        let __ws_arg_12 = self.extend(Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("place_order".to_string(), placeOrder.clone());
    m
}), &[response.clone()]);
        return self.parse_order(__ws_arg_12, &[market.clone()]);

    Value::Null
}

/*
 * @method
 * @name nado#cancelOrderWs
 * @description cancels an open order over the v2 gateway WebSocket
 * @see https://docs.nado.xyz/developer-resources/api/gateway/websocket-v2
 * @see https://docs.nado.xyz/developer-resources/api/gateway/executes/cancel-orders
 * @param {string} id order id
 * @param {string} symbol unified symbol of the market the order was made in
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @param {string} [params.subaccount] the 12-byte subaccount identifier, defaults to 'default'
 * @param {string} [params.requiredUnfilledAmount] cancel only if the order's absolute remaining unfilled amount matches this amount, exchange-specific raw x18 alias params.required_unfilled_amount
 * @param {int} [params.id] client-provided request id used to correlate the out-of-order v2 response, autogenerated when omitted
 * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
 */
    pub async fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
        let mut symbol = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut orders: Value = self.cancel_orders_ws(Value::List(vec![id.clone()]), &[symbol.clone(), params.clone()]).await;
        return self.safe_dict(orders.clone(), Value::Int(0), &[]);

    Value::Null
}

/*
 * @method
 * @name nado#cancelOrdersWs
 * @description cancel multiple orders over the v2 gateway WebSocket
 * @see https://docs.nado.xyz/developer-resources/api/gateway/websocket-v2
 * @see https://docs.nado.xyz/developer-resources/api/gateway/executes/cancel-orders
 * @param {string[]} ids order ids
 * @param {string} symbol unified market symbol
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @param {string} [params.subaccount] the 12-byte subaccount identifier, defaults to 'default'
 * @param {string} [params.requiredUnfilledAmount] cancel only if the order's absolute remaining unfilled amount matches this amount, exchange-specific raw x18 alias params.required_unfilled_amount
 * @param {int} [params.id] client-provided request id used to correlate the out-of-order v2 response, autogenerated when omitted
 * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
 */
    pub async fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
        let mut symbol = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        if is_equal(&symbol, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrdersWs() requires a symbol argument".to_string()))));
        }
        self.load_markets(&[]).await;
        let mut market: Value = self.market(symbol.clone());
        let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[]);
        if is_equal(&trigger, &Value::Bool(true)) {
            panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrdersWs() does not support trigger orders, use cancelOrders() instead".to_string()))));
        }
        let __ws_arg_13 = self.request_id();
        params = self.extend(Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("id".to_string(), __ws_arg_13);
            m
        }), &[params.clone()]);
        let mut requestIdString: Value = self.safe_string_k(params.clone(), "id", &[]);
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" ws execute requires params.id".to_string()))));
        }
        let mut request: Value = self.parent.cancel_orders_request(ids.clone(), &[symbol.clone(), params.clone()]).await;
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires params.id".to_string()))));
        }
        let mut response: Value = self.watch_execute_request(requestIdString.clone(), request.clone()).await;
        //
        //     {
        //         "status": "success",
        //         "signature": "0x...",
        //         "data": {
        //             "cancelled_orders": []
        //         },
        //         "request_type": "execute_cancel_orders",
        //         "id": 100
        //     }
        //
        let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        })]);
        let mut cancelledOrders: Value = self.safe_list_k(data.clone(), "cancelled_orders", &[Value::List(vec![])]);
        let mut result: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_507: bool = true;
            while { if !__for_first_507 { i = add(&i, &Value::Int(1)); } __for_first_507 = false; is_less_than(&i, &get_array_length(&cancelledOrders)) } {
            let __ws_arg_14 = self.extend(Value::Map({
                let mut m = indexmap::IndexMap::new();
                    m.insert("status".to_string(), Value::Str("canceled".to_string()));
                m
            }), &[get_value(&cancelledOrders, &i)]);
            append_to_array(&mut result, self.parse_order(__ws_arg_14, &[market.clone()]));
        }
        }
        return result;

    Value::Null
}

/*
 * @method
 * @name nado#cancelAllOrdersWs
 * @description cancel all open orders over the v2 gateway WebSocket
 * @see https://docs.nado.xyz/developer-resources/api/gateway/websocket-v2
 * @see https://docs.nado.xyz/developer-resources/api/gateway/executes/cancel-product-orders
 * @param {string} [symbol] unified market symbol, when undefined all orders for all products are canceled
 * @param {object} [params] extra parameters specific to the exchange API endpoint
 * @param {string} [params.subaccount] the 12-byte subaccount identifier, defaults to 'default'
 * @param {int} [params.id] client-provided request id used to correlate the out-of-order v2 response, autogenerated when omitted
 * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
 */
    pub async fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> Value {
        let mut symbol = get_arg(optional_args, 0, Value::Null);
        let mut params = get_arg(optional_args, 1, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        self.load_markets(&[]).await;
        let mut market: Value = Value::Null;
        if !is_equal(&symbol, &Value::Null) {
            market = self.market(symbol.clone());
        }
        let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[]);
        if is_equal(&trigger, &Value::Bool(true)) {
            panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrdersWs() does not support trigger orders, use cancelAllOrders() instead".to_string()))));
        }
        let __ws_arg_15 = self.request_id();
        params = self.extend(Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("id".to_string(), __ws_arg_15);
            m
        }), &[params.clone()]);
        let mut requestIdString: Value = self.safe_string_k(params.clone(), "id", &[]);
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" ws execute requires params.id".to_string()))));
        }
        let mut request: Value = self.parent.cancel_all_orders_request(&[symbol.clone(), params.clone()]).await;
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires params.id".to_string()))));
        }
        let mut response: Value = self.watch_execute_request(requestIdString.clone(), request.clone()).await;
        let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        })]);
        let mut cancelledOrders: Value = self.safe_list_k(data.clone(), "cancelled_orders", &[Value::List(vec![])]);
        let mut result: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_508: bool = true;
            while { if !__for_first_508 { i = add(&i, &Value::Int(1)); } __for_first_508 = false; is_less_than(&i, &get_array_length(&cancelledOrders)) } {
            let __ws_arg_16 = self.extend(Value::Map({
                let mut m = indexmap::IndexMap::new();
                    m.insert("status".to_string(), Value::Str("canceled".to_string()));
                m
            }), &[get_value(&cancelledOrders, &i)]);
            append_to_array(&mut result, self.parse_order(__ws_arg_16, &[market.clone()]));
        }
        }
        return result;

    Value::Null
}

    pub async fn watch_execute_request(&mut self, mut requestIdString: Value, mut request: Value) -> Value {
        // the v2 gateway dispatches requests concurrently, so responses arrive
        // in completion order, not send order — every execute carries a unique
        // request id and its response is correlated by the echoed id
        if is_equal(&requestIdString, &Value::Null) {
            panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" watchExecuteRequest() requires requestIdString".to_string()))));
        }
        let mut url: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("gateway".to_string()));
        let mut messageHash: Value = add(&Value::Str("execute:".to_string()), &requestIdString);
        return self.watch(url.clone(), messageHash.clone(), &[request.clone(), messageHash.clone()]).await;

    Value::Null
}

    pub async fn watch_public(&mut self, mut streamType: Value, mut market: Value, mut messageHash: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut url: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("subscriptions".to_string()));
        let mut stream: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("type".to_string(), streamType.clone());
            m
        });
        if !is_equal(&market, &Value::Null) {
            add_element_to_object(&mut stream, &Value::Str("product_id".to_string()), self.parse_to_int(get_value(&market, &Value::Str("id".to_string()))));
        }
        let mut request: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("method".to_string(), Value::Str("subscribe".to_string()));
                m.insert("stream".to_string(), self.deep_extend(stream.clone(), &[params.clone()]));
                m.insert("id".to_string(), self.request_id());
            m
        });
        let mut subscribeHash: Value = add(&Value::Str("subscribe:".to_string()), &self.json(get_value(&request, &Value::Str("stream".to_string()))));
        let mut subscription: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("streamType".to_string(), streamType.clone());
                m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
            m
        });
        let mut client: Value = self.client(&[url.clone()]);
        let mut clientSubscription: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), subscribeHash.clone(), &[]);
        if is_equal(&clientSubscription, &Value::Null) {
            let mut id: Value = self.safe_string_k(request.clone(), "id", &[]);
            add_element_to_object(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("subscription:".to_string()), &id), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("subscribeHash".to_string(), subscribeHash.clone());
    m
}));
            self.watch_multiple(url.clone(), Value::List(vec![subscribeHash.clone()]), &[request.clone(), Value::List(vec![subscribeHash.clone()]), subscription.clone()]).await;
        }
        return self.watch(url.clone(), messageHash.clone(), &[]).await;

    Value::Null
}

    pub async fn watch_private(&mut self, mut streamType: Value, mut stream: Value, mut messageHash: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut url: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("subscriptions".to_string()));
        let mut client: Value = self.client(&[url.clone()]);
        let mut clientSubscription: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), messageHash.clone(), &[]);
        if !is_equal(&clientSubscription, &Value::Null) {
            return self.watch(url.clone(), messageHash.clone(), &[]).await;
        }
        let mut id: Value = self.request_id();
        let mut subscribeHash: Value = add(&Value::Str("subscribe:".to_string()), &messageHash);
        let mut request: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("method".to_string(), Value::Str("subscribe".to_string()));
                m.insert("stream".to_string(), self.deep_extend(stream.clone(), &[params.clone()]));
                m.insert("id".to_string(), id.clone());
            m
        });
        let mut subscription: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("streamType".to_string(), streamType.clone());
            m
        });
        add_element_to_object(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("subscription:".to_string()), &self.number_to_string(id.clone())), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("subscribeHash".to_string(), subscribeHash.clone());
    m
}));
        self.watch_multiple(url.clone(), Value::List(vec![subscribeHash.clone()]), &[request.clone(), Value::List(vec![messageHash.clone()]), subscription.clone()]).await;
        return self.watch(url.clone(), messageHash.clone(), &[]).await;

    Value::Null
}

    pub async fn un_watch_private(&mut self, mut stream: Value, mut messageHash: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut url: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("subscriptions".to_string()));
        let mut id: Value = self.request_id();
        let mut unsubscribeHash: Value = add(&Value::Str("unsubscribe:".to_string()), &messageHash);
        let mut request: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("method".to_string(), Value::Str("unsubscribe".to_string()));
                m.insert("stream".to_string(), self.deep_extend(stream.clone(), &[params.clone()]));
                m.insert("id".to_string(), id.clone());
            m
        });
        let mut subscription: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("id".to_string(), id.clone());
                m.insert("messageHash".to_string(), messageHash.clone());
            m
        });
        let mut client: Value = self.client(&[url.clone()]);
        add_element_to_object(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("unsubscription:".to_string()), &self.number_to_string(id.clone())), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("messageHash".to_string(), messageHash.clone());
        m.insert("unsubscribeHash".to_string(), unsubscribeHash.clone());
    m
}));
        return self.watch(url.clone(), unsubscribeHash.clone(), &[request.clone(), unsubscribeHash.clone(), subscription.clone()]).await;

    Value::Null
}

    pub async fn authenticate(&mut self, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        self.check_required_credentials(&[]);
        let mut url: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("subscriptions".to_string()));
        let mut client: Value = self.client(&[url.clone()]);
        let mut messageHash: Value = Value::Str("authenticated".to_string());
        let mut authenticated: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), messageHash.clone(), &[]);
        if !is_equal(&authenticated, &Value::Null) {
            let mut future: Value = self.safe_value(get_value(&client, &Value::Str("futures".to_string())), messageHash.clone(), &[]);
            if !is_equal(&future, &Value::Null) {
                return crate::exchange_stubs::ws_await_flight(&future).await;
            }
            return authenticated;
        }
        let mut recvWindow: Value = Value::Null;
        { let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("authenticate".to_string()), Value::Str("recvWindow".to_string()), &[Value::Int(5000)]); recvWindow = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
        let mut subaccount: Value = Value::Null;
        { let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("authenticate".to_string()), Value::Str("subaccount".to_string()), &[Value::Str("default".to_string())]); subaccount = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
        let mut id: Value = self.request_id();
        let mut sender: Value = self.parent.create_subaccount(self.walletAddress.clone(), &[subaccount.clone()]);
        let mut expiration: Value = self.sum(&[self.milliseconds(), recvWindow.clone()]);
        let mut tx: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("sender".to_string(), sender.clone());
                m.insert("expiration".to_string(), self.number_to_string(expiration.clone()));
            m
        });
        let mut contracts: Value = self.parent.query_contracts(&[]).await;
        let mut chainId: Value = self.safe_string_k(contracts.clone(), "chain_id", &[]);
        let mut endpointAddress: Value = self.safe_string_k(contracts.clone(), "endpoint_addr", &[]);
        if is_equal(&endpointAddress, &Value::Null) {
            panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" authenticate() requires endpoint_addr from contracts query".to_string()))));
        }
        let mut signature: Value = self.sign_stream_authentication(tx.clone(), chainId.clone(), endpointAddress.clone());
        let mut request: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("method".to_string(), Value::Str("authenticate".to_string()));
                m.insert("id".to_string(), id.clone());
                m.insert("tx".to_string(), tx.clone());
                m.insert("signature".to_string(), signature.clone());
            m
        });
        add_element_to_object(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("authentication:".to_string()), &self.number_to_string(id.clone())), messageHash.clone());
        let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
        return self.watch(url.clone(), messageHash.clone(), &[__ws_arg_17, messageHash.clone()]).await;

    Value::Null
}

    pub fn sign_stream_authentication(&self, mut tx: Value, mut chainId: Value, mut endpointAddress: Value) -> Value {
        let mut domain: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("name".to_string(), Value::Str("Nado".to_string()));
                m.insert("version".to_string(), Value::Str("0.0.1".to_string()));
                m.insert("chainId".to_string(), chainId.clone());
                m.insert("verifyingContract".to_string(), endpointAddress.clone());
            m
        });
        let mut messageTypes: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("StreamAuthentication".to_string(), Value::List(vec![Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("name".to_string(), Value::Str("sender".to_string()));
        m.insert("type".to_string(), Value::Str("bytes32".to_string()));
    m
}), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("name".to_string(), Value::Str("expiration".to_string()));
        m.insert("type".to_string(), Value::Str("uint64".to_string()));
    m
})]));
            m
        });
        let mut encoded: Value = self.eth_encode_structured_data(domain.clone(), messageTypes.clone(), tx.clone());
        let mut hash: Value = add(&Value::Str("0x".to_string()), &self.hash(encoded.clone(), Value::Str("keccak".to_string()), &[Value::Str("hex".to_string())]));
        return self.parent.sign_hash(hash.clone(), self.privateKey.clone());

    Value::Null
}

    pub fn create_public_subscription_request(&self, mut method: Value, mut streamType: Value, optional_args: &[Value]) -> Value {
        let mut market = get_arg(optional_args, 0, Value::Null);
        let mut id = get_arg(optional_args, 1, Value::Null);
        let mut params = get_arg(optional_args, 2, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut stream: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("type".to_string(), streamType.clone());
            m
        });
        if !is_equal(&market, &Value::Null) {
            add_element_to_object(&mut stream, &Value::Str("product_id".to_string()), self.parse_to_int(get_value(&market, &Value::Str("id".to_string()))));
        }
        return Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("method".to_string(), method.clone());
        m.insert("stream".to_string(), self.deep_extend(stream.clone(), &[params.clone()]));
        m.insert("id".to_string(), id.clone());
    m
});

    Value::Null
}

    pub async fn watch_public_multiple(&mut self, mut streamType: Value, mut markets: Value, mut messageHashes: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut subscriptionParams = get_arg(optional_args, 1, Value::Null);
        let mut url: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("subscriptions".to_string()));
        let mut client: Value = self.client(&[url.clone()]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_509: bool = true;
            while { if !__for_first_509 { i = add(&i, &Value::Int(1)); } __for_first_509 = false; is_less_than(&i, &get_array_length(&messageHashes)) } {
            let mut messageHash: Value = get_value(&messageHashes, &i);
            let mut messageHash: Value = get_value(&messageHashes, &i);
            let mut clientSubscription: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), messageHash.clone(), &[]);
            if is_equal(&clientSubscription, &Value::Null) {
                let mut market: Value = get_value(&markets, &i);
                let mut market: Value = get_value(&markets, &i);
                let mut id: Value = self.request_id();
                let mut requestParams: Value = ternary(is_true(&(is_equal(&subscriptionParams, &Value::Null))), params.clone(), get_value(&subscriptionParams, &i));
                let mut request: Value = self.create_public_subscription_request(Value::Str("subscribe".to_string()), streamType.clone(), &[market.clone(), id.clone(), requestParams.clone()]);
                let mut subscribeHash: Value = add(&Value::Str("subscribe:".to_string()), &self.json(get_value(&request, &Value::Str("stream".to_string()))));
                let mut streamSubscription: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), subscribeHash.clone(), &[]);
                if is_equal(&streamSubscription, &Value::Null) {
                    let mut subscription: Value = Value::Map({
                        let mut m = indexmap::IndexMap::new();
                            m.insert("streamType".to_string(), streamType.clone());
                            m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
                        m
                    });
                    add_element_to_object(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("subscription:".to_string()), &self.number_to_string(id.clone())), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("subscribeHash".to_string(), subscribeHash.clone());
    m
}));
                    self.watch_multiple(url.clone(), Value::List(vec![subscribeHash.clone()]), &[request.clone(), Value::List(vec![subscribeHash.clone()]), subscription.clone()]).await;
                }
            }
        }
        }
        return self.watch_multiple(url.clone(), messageHashes.clone(), &[Value::Null, messageHashes.clone()]).await;

    Value::Null
}

    pub async fn un_watch_public(&mut self, mut streamType: Value, mut market: Value, mut messageHash: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut url: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("subscriptions".to_string()));
        let mut id: Value = self.request_id();
        let mut request: Value = self.create_public_subscription_request(Value::Str("unsubscribe".to_string()), streamType.clone(), &[market.clone(), id.clone(), params.clone()]);
        let mut subscription: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("id".to_string(), id.clone());
                m.insert("messageHash".to_string(), messageHash.clone());
            m
        });
        let mut unsubscribeHash: Value = add(&Value::Str("unsubscribe:".to_string()), &messageHash);
        let mut client: Value = self.client(&[url.clone()]);
        add_element_to_object(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("unsubscription:".to_string()), &self.number_to_string(id.clone())), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("messageHash".to_string(), messageHash.clone());
        m.insert("unsubscribeHash".to_string(), unsubscribeHash.clone());
    m
}));
        return self.watch(url.clone(), unsubscribeHash.clone(), &[request.clone(), unsubscribeHash.clone(), subscription.clone()]).await;

    Value::Null
}

    pub async fn un_watch_public_multiple(&mut self, mut streamType: Value, mut markets: Value, mut messageHashes: Value, optional_args: &[Value]) -> Value {
        let mut params = get_arg(optional_args, 0, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        let mut subscriptionParams = get_arg(optional_args, 1, Value::Null);
        let mut url: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("subscriptions".to_string()));
        let mut client: Value = self.client(&[url.clone()]);
        let mut results: Value = Value::List(vec![]);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_510: bool = true;
            while { if !__for_first_510 { i = add(&i, &Value::Int(1)); } __for_first_510 = false; is_less_than(&i, &get_array_length(&messageHashes)) } {
            let mut messageHash: Value = get_value(&messageHashes, &i);
            let mut messageHash: Value = get_value(&messageHashes, &i);
            let mut id: Value = self.request_id();
            let mut unsubscribeHash: Value = add(&Value::Str("unsubscribe:".to_string()), &messageHash);
            let mut requestParams: Value = ternary(is_true(&(is_equal(&subscriptionParams, &Value::Null))), params.clone(), get_value(&subscriptionParams, &i));
            let mut request: Value = self.create_public_subscription_request(Value::Str("unsubscribe".to_string()), streamType.clone(), &[get_value(&markets, &i), id.clone(), requestParams.clone()]);
            let mut subscription: Value = Value::Map({
                let mut m = indexmap::IndexMap::new();
                    m.insert("id".to_string(), id.clone());
                    m.insert("messageHash".to_string(), messageHash.clone());
                m
            });
            add_element_to_object(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("unsubscription:".to_string()), &self.number_to_string(id.clone())), Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("messageHash".to_string(), messageHash.clone());
        m.insert("unsubscribeHash".to_string(), unsubscribeHash.clone());
    m
}));
            append_to_array(&mut results, self.watch_multiple(url.clone(), Value::List(vec![unsubscribeHash.clone()]), &[request.clone(), Value::List(vec![unsubscribeHash.clone()]), subscription.clone()]).await);
        }
        }
        return results;

    Value::Null
}

    pub fn parse_ws_timestamp(&self, mut message: Value, mut key: Value) -> Value {
        let mut value: Value = self.safe_string(message.clone(), key.clone(), &[]);
        if is_equal(&value, &Value::Null) {
            return Value::Null;
        }
        let mut length: Value = get_array_length(&value);
        if is_greater_than(&length, &Value::Int(13)) {
            return self.parse_to_int(slice(&value, &Value::Int(0), &subtract(&length, &Value::Int(6))));
        }
        return self.safe_integer(message.clone(), key.clone(), &[]);

    Value::Null
}

    pub fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
        let mut market = get_arg(optional_args, 0, Value::Null);
        //
        //     {
        //         "type": "trade",
        //         "timestamp": "1676151190656903000",
        //         "product_id": 1,
        //         "price": "25000000000000000000000",
        //         "taker_qty": "1000000000000000000",
        //         "maker_qty": "1000000000000000000",
        //         "is_taker_buyer": true
        //     }
        //
        let mut marketId: Value = self.safe_string_k(trade.clone(), "product_id", &[]);
        market = self.safe_market(&[marketId.clone(), market.clone()]);
        let mut timestamp: Value = self.parse_ws_timestamp(trade.clone(), Value::Str("timestamp".to_string()));
        let mut isTakerBuyer: Value = self.safe_bool_k(trade.clone(), "is_taker_buyer", &[]);
        let mut side: Value = Value::Null;
        if !is_equal(&isTakerBuyer, &Value::Null) {
            side = ternary(is_true(&isTakerBuyer), Value::Str("buy".to_string()), Value::Str("sell".to_string()));
        }
        return self.safe_trade(Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("info".to_string(), trade.clone());
        m.insert("id".to_string(), Value::Null);
        m.insert("timestamp".to_string(), timestamp.clone());
        m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
        m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
        m.insert("order".to_string(), Value::Null);
        m.insert("type".to_string(), Value::Null);
        m.insert("side".to_string(), side.clone());
        m.insert("takerOrMaker".to_string(), Value::Str("taker".to_string()));
        m.insert("price".to_string(), self.parent.parse_x18(self.safe_string_k(trade.clone(), "price", &[])));
        m.insert("amount".to_string(), self.parent.parse_x18(self.safe_string_k(trade.clone(), "taker_qty", &[])));
        m.insert("cost".to_string(), Value::Null);
        m.insert("fee".to_string(), Value::Null);
    m
}), &[market.clone()]);

    Value::Null
}

    pub fn parse_ws_my_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
        let mut market = get_arg(optional_args, 0, Value::Null);
        //
        //     {
        //         "type": "fill",
        //         "timestamp": "1695081920633151000",
        //         "product_id": 1,
        //         "subaccount": "0x...",
        //         "order_digest": "0x...",
        //         "appendix": "1",
        //         "filled_qty": "18000000000000000",
        //         "remaining_qty": "82000000000000000",
        //         "original_qty": "100000000000000000",
        //         "price": "25000000000000000000000",
        //         "is_taker": true,
        //         "is_bid": true,
        //         "fee": "4500000000000000",
        //         "submission_idx": 1,
        //         "id": 100
        //     }
        //
        let mut marketId: Value = self.safe_string_k(trade.clone(), "product_id", &[]);
        market = self.safe_market(&[marketId.clone(), market.clone()]);
        let mut timestamp: Value = self.parse_ws_timestamp(trade.clone(), Value::Str("timestamp".to_string()));
        let mut isBid: Value = self.safe_bool_k(trade.clone(), "is_bid", &[]);
        let mut side: Value = Value::Null;
        if !is_equal(&isBid, &Value::Null) {
            side = ternary(is_true(&isBid), Value::Str("buy".to_string()), Value::Str("sell".to_string()));
        }
        let mut isTaker: Value = self.safe_bool_k(trade.clone(), "is_taker", &[]);
        let mut takerOrMaker: Value = Value::Null;
        if !is_equal(&isTaker, &Value::Null) {
            takerOrMaker = ternary(is_true(&isTaker), Value::Str("taker".to_string()), Value::Str("maker".to_string()));
        }
        let mut feeCost: Value = self.parent.parse_x18(self.safe_string_k(trade.clone(), "fee", &[]));
        let mut fee: Value = Value::Null;
        if !is_equal(&feeCost, &Value::Null) {
            fee = Value::Map({
                let mut m = indexmap::IndexMap::new();
                    m.insert("cost".to_string(), feeCost.clone());
                    m.insert("currency".to_string(), get_value(&market, &Value::Str("quote".to_string())));
                m
            });
        }
        return self.safe_trade(Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("info".to_string(), trade.clone());
        m.insert("id".to_string(), self.safe_string2(trade.clone(), Value::Str("id".to_string()), Value::Str("submission_idx".to_string()), &[]));
        m.insert("timestamp".to_string(), timestamp.clone());
        m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
        m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
        m.insert("order".to_string(), self.safe_string_k(trade.clone(), "order_digest", &[]));
        m.insert("type".to_string(), Value::Null);
        m.insert("side".to_string(), side.clone());
        m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
        m.insert("price".to_string(), self.parent.parse_x18(self.safe_string_k(trade.clone(), "price", &[])));
        m.insert("amount".to_string(), self.parent.parse_x18(self.safe_string_k(trade.clone(), "filled_qty", &[])));
        m.insert("cost".to_string(), Value::Null);
        m.insert("fee".to_string(), fee.clone());
    m
}), &[market.clone()]);

    Value::Null
}

    pub fn handle_trade(&mut self, mut client: Value, mut message: Value) {
        let mut marketId: Value = self.safe_string_k(message.clone(), "product_id", &[]);
        let mut market: Value = self.safe_market(&[marketId.clone()]);
        let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
        let mut messageHash: Value = add(&Value::Str("trade:".to_string()), &symbol);
        let mut trades: Value = self.safe_value(self.trades.clone(), symbol.clone(), &[]);
        if is_equal(&trades, &Value::Null) {
            let mut limit: Value = self.safe_integer_k(self.options.clone(), "tradesLimit", &[Value::Int(1000)]);
            trades = ArrayCache::new(limit.clone());
            add_element_to_object(&mut self.trades, &symbol, trades.clone());
        }
        let mut trade: Value = self.parse_ws_trade(message.clone(), &[market.clone()]);
        trades.append(trade.clone());
        client.resolve(&[trades.clone(), messageHash.clone()]);
}

    pub fn handle_my_trade(&mut self, mut client: Value, mut message: Value) {
        let mut trade: Value = self.parse_ws_my_trade(message.clone(), &[]);
        if is_equal(&self.myTrades, &Value::Null) {
            let mut limit: Value = self.safe_integer_k(self.options.clone(), "tradesLimit", &[Value::Int(1000)]);
            self.myTrades = ArrayCacheBySymbolById::new(limit.clone());
        }
        let mut trades: Value = self.myTrades.clone();
        trades.append(trade.clone());
        let mut symbol: Value = get_value(&trade, &Value::Str("symbol".to_string()));
        client.resolve(&[trades.clone(), Value::Str("myTrades".to_string())]);
        client.resolve(&[trades.clone(), add(&Value::Str("myTrades:".to_string()), &symbol)]);
}

    pub fn handle_ohlcv(&mut self, mut client: Value, mut message: Value) {
        //
        //     {
        //         "type": "latest_candlestick",
        //         "timestamp": "1782179760",
        //         "product_id": 2,
        //         "granularity": 60,
        //         "open_x18": "64148000000000000000000",
        //         "high_x18": "64148000000000000000000",
        //         "low_x18": "64148000000000000000000",
        //         "close_x18": "64148000000000000000000",
        //         "volume": "24250000000000000"
        //     }
        //
        let mut marketId: Value = self.safe_string_k(message.clone(), "product_id", &[]);
        let mut market: Value = self.safe_market(&[marketId.clone()]);
        let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
        let mut granularity: Value = self.safe_integer_k(message.clone(), "granularity", &[]);
        let mut timeframe: Value = self.find_timeframe(granularity.clone(), &[]);
        if is_equal(&timeframe, &Value::Null) {
            return;
        }
        if !is_true(&(Value::Bool(in_op(&self.ohlcvs, &symbol)))) {
            add_element_to_object(&mut self.ohlcvs, &symbol, Value::Map({
    let mut m = indexmap::IndexMap::new();
    m
}));
        }
        let mut stored: Value = self.safe_value(get_value(&self.ohlcvs, &symbol), timeframe.clone(), &[]);
        if is_equal(&stored, &Value::Null) {
            let mut limit: Value = self.safe_integer_k(self.options.clone(), "OHLCVLimit", &[Value::Int(1000)]);
            stored = ArrayCacheByTimestamp::new(limit.clone());
            add_element_to_object(get_value_mut(unsafe { crate::runtime::coerce_value_to_mut(&self.ohlcvs) }, &symbol), &timeframe, stored.clone());
        }
        let mut parsed: Value = self.parse_ohlcv(message.clone(), &[market.clone()]);
        stored.append(parsed.clone());
        let mut messageHash: Value = add(&add(&add(&Value::Str("ohlcv:".to_string()), &timeframe), &Value::Str(":".to_string())), &symbol);
        client.resolve(&[Value::List(vec![symbol.clone(), timeframe.clone(), stored.clone()]), messageHash.clone()]);
}

    pub fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
        let mut market = get_arg(optional_args, 0, Value::Null);
        //
        //     {
        //         "type": "order_update",
        //         "timestamp": "1695081920633151000",
        //         "product_id": 1,
        //         "digest": "0xf7712b63ccf70358db8f201e9bf33977423e7a63f6a16f6dab180bdd580f7c6c",
        //         "amount": "82000000000000000",
        //         "reason": "filled",
        //         "filled_qty": "18000000000000000",
        //         "filled_price": "25000000000000000000000",
        //         "id": 100
        //     }
        //
        let mut marketId: Value = self.safe_string_k(order.clone(), "product_id", &[]);
        market = self.safe_market(&[marketId.clone(), market.clone()]);
        let mut timestamp: Value = self.parse_ws_timestamp(order.clone(), Value::Str("timestamp".to_string()));
        let mut id: Value = self.safe_string_k(order.clone(), "digest", &[]);
        let mut amountString: Value = self.safe_string_k(order.clone(), "amount", &[]);
        let mut remaining: Value = Value::Null;
        if !is_equal(&amountString, &Value::Null) {
            remaining = self.parent.parse_x18(amountString.clone());
        }
        let mut filled: Value = self.parent.parse_x18(self.safe_string_k(order.clone(), "filled_qty", &[]));
        let mut average: Value = self.parent.parse_x18(self.safe_string_k(order.clone(), "filled_price", &[]));
        let mut reason: Value = self.safe_string_k(order.clone(), "reason", &[]);
        let mut status: Value = Value::Null;
        if is_equal(&reason, &Value::Str("placed".to_string())) {
            status = Value::Str("open".to_string());
        }  else if is_equal(&reason, &Value::Str("filled".to_string())) {
            status = Value::Str("open".to_string());
            if is_true(&(!is_equal(&amountString, &Value::Null))) && is_true(&crate::precise::Precise::stringEq(&amountString, &Value::Str("0".to_string()))) {
                status = Value::Str("closed".to_string());
            }
        }  else if is_equal(&reason, &Value::Str("cancelled".to_string())) {
            status = Value::Str("canceled".to_string());
        }
        return self.safe_order(Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("info".to_string(), order.clone());
        m.insert("id".to_string(), id.clone());
        m.insert("clientOrderId".to_string(), Value::Null);
        m.insert("timestamp".to_string(), timestamp.clone());
        m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
        m.insert("lastTradeTimestamp".to_string(), ternary(is_true(&(is_equal(&filled, &Value::Null))), Value::Null, timestamp.clone()));
        m.insert("lastUpdateTimestamp".to_string(), timestamp.clone());
        m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
        m.insert("type".to_string(), Value::Null);
        m.insert("timeInForce".to_string(), Value::Null);
        m.insert("postOnly".to_string(), Value::Null);
        m.insert("side".to_string(), Value::Null);
        m.insert("price".to_string(), Value::Null);
        m.insert("stopPrice".to_string(), Value::Null);
        m.insert("triggerPrice".to_string(), Value::Null);
        m.insert("amount".to_string(), Value::Null);
        m.insert("cost".to_string(), Value::Null);
        m.insert("average".to_string(), average.clone());
        m.insert("filled".to_string(), filled.clone());
        m.insert("remaining".to_string(), remaining.clone());
        m.insert("status".to_string(), status.clone());
        m.insert("fee".to_string(), Value::Null);
        m.insert("trades".to_string(), Value::Null);
    m
}), &[market.clone()]);

    Value::Null
}

    pub fn handle_order(&mut self, mut client: Value, mut message: Value) {
        let mut order: Value = self.parse_ws_order(message.clone(), &[]);
        if is_equal(&self.orders, &Value::Null) {
            let mut limit: Value = self.safe_integer_k(self.options.clone(), "ordersLimit", &[Value::Int(1000)]);
            self.orders = ArrayCacheBySymbolById::new(limit.clone());
        }
        let mut orders: Value = self.orders.clone();
        orders.append(order.clone());
        let mut symbol: Value = get_value(&order, &Value::Str("symbol".to_string()));
        client.resolve(&[orders.clone(), Value::Str("orders".to_string())]);
        client.resolve(&[orders.clone(), add(&Value::Str("orders:".to_string()), &symbol)]);
}

    pub fn parse_ws_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
        let mut market = get_arg(optional_args, 0, Value::Null);
        //
        //     {
        //         "type": "position_change",
        //         "timestamp": "1695081920633151000",
        //         "product_id": 2,
        //         "subaccount": "0x15f43d1f2dee81424afd891943262aa90f22cc2a64656661756c740000000000",
        //         "isolated": false,
        //         "amount": "100000000000000000",
        //         "v_quote_amount": "-3033500000000000000000",
        //         "reason": "match_orders"
        //     }
        //
        let mut marketId: Value = self.safe_string_k(position.clone(), "product_id", &[]);
        market = self.safe_market(&[marketId.clone(), market.clone()]);
        let mut timestamp: Value = self.parse_ws_timestamp(position.clone(), Value::Str("timestamp".to_string()));
        let mut amountString: Value = self.safe_string_k(position.clone(), "amount", &[]);
        let mut vQuoteAmount: Value = self.safe_string_k(position.clone(), "v_quote_amount", &[]);
        let mut side: Value = Value::Null;
        let mut contracts: Value = Value::Null;
        let mut entryPrice: Value = Value::Null;
        if !is_equal(&amountString, &Value::Null) {
            if is_true(&crate::precise::Precise::stringGt(&amountString, &Value::Str("0".to_string()))) {
                side = Value::Str("long".to_string());
            }  else if is_true(&crate::precise::Precise::stringLt(&amountString, &Value::Str("0".to_string()))) {
                side = Value::Str("short".to_string());
            }
            let mut absoluteAmount: Value = crate::precise::Precise::stringAbs(&amountString);
            contracts = self.parent.parse_x18(absoluteAmount.clone());
            if is_true(&(!is_equal(&vQuoteAmount, &Value::Null))) && !is_true(&crate::precise::Precise::stringEquals(&absoluteAmount, &Value::Str("0".to_string()))) {
                entryPrice = self.parse_number(crate::precise::Precise::stringDiv(&crate::precise::Precise::stringAbs(&vQuoteAmount), &absoluteAmount), &[]);
            }
        }
        return self.safe_position(Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("info".to_string(), position.clone());
        m.insert("id".to_string(), Value::Null);
        m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
        m.insert("timestamp".to_string(), timestamp.clone());
        m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
        m.insert("isolated".to_string(), self.safe_bool_k(position.clone(), "isolated", &[]));
        m.insert("hedged".to_string(), Value::Bool(false));
        m.insert("side".to_string(), side.clone());
        m.insert("contracts".to_string(), contracts.clone());
        m.insert("contractSize".to_string(), self.safe_number_k(market.clone(), "contractSize", &[]));
        m.insert("entryPrice".to_string(), entryPrice.clone());
        m.insert("markPrice".to_string(), Value::Null);
        m.insert("notional".to_string(), Value::Null);
        m.insert("leverage".to_string(), Value::Null);
        m.insert("collateral".to_string(), Value::Null);
        m.insert("initialMargin".to_string(), Value::Null);
        m.insert("initialMarginPercentage".to_string(), Value::Null);
        m.insert("maintenanceMargin".to_string(), Value::Null);
        m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
        m.insert("unrealizedPnl".to_string(), Value::Null);
        m.insert("liquidationPrice".to_string(), Value::Null);
        m.insert("marginMode".to_string(), Value::Null);
        m.insert("marginRatio".to_string(), Value::Null);
        m.insert("percentage".to_string(), Value::Null);
    m
}));

    Value::Null
}

    pub fn handle_position(&mut self, mut client: Value, mut message: Value) {
        let mut marketId: Value = self.safe_string_k(message.clone(), "product_id", &[]);
        let mut market: Value = self.safe_market(&[marketId.clone()]);
        if !is_true(&self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)])) {
            return;
        }
        let mut position: Value = self.parse_ws_position(message.clone(), &[market.clone()]);
        if is_equal(&self.positions, &Value::Null) {
            self.positions = ArrayCacheBySymbolBySide::new(Value::Null);
        }
        let mut positions: Value = self.positions.clone();
        let mut side: Value = self.safe_string_k(position.clone(), "side", &[]);
        if is_equal(&side, &Value::Null) {
            let mut longPosition: Value = self.extend(Value::Map({
                let mut m = indexmap::IndexMap::new();
                m
            }), &[position.clone()]);
            add_element_to_object(&mut longPosition, &Value::Str("side".to_string()), Value::Str("long".to_string()));
            positions.append(longPosition.clone());
            let mut shortPosition: Value = self.extend(Value::Map({
                let mut m = indexmap::IndexMap::new();
                m
            }), &[position.clone()]);
            add_element_to_object(&mut shortPosition, &Value::Str("side".to_string()), Value::Str("short".to_string()));
            positions.append(shortPosition.clone());
        }  else {
            positions.append(position.clone());
        }
        let mut symbol: Value = get_value(&position, &Value::Str("symbol".to_string()));
        client.resolve(&[positions.clone(), Value::Str("positions".to_string())]);
        client.resolve(&[positions.clone(), add(&Value::Str("positions:".to_string()), &symbol)]);
}

    pub fn parse_ws_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
        let mut market = get_arg(optional_args, 0, Value::Null);
        //
        //     {
        //         "type": "best_bid_offer",
        //         "timestamp": "1676151190656903000",
        //         "product_id": 1,
        //         "bid_price": "24990000000000000000000",
        //         "bid_qty": "5000000000000000000",
        //         "ask_price": "25010000000000000000000",
        //         "ask_qty": "3000000000000000000"
        //     }
        //
        let mut marketId: Value = self.safe_string_k(bidask.clone(), "product_id", &[]);
        market = self.safe_market(&[marketId.clone(), market.clone()]);
        let mut timestamp: Value = self.parse_ws_timestamp(bidask.clone(), Value::Str("timestamp".to_string()));
        return self.safe_ticker(Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
        m.insert("timestamp".to_string(), timestamp.clone());
        m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
        m.insert("ask".to_string(), self.parent.parse_x18(self.safe_string_k(bidask.clone(), "ask_price", &[])));
        m.insert("askVolume".to_string(), self.parent.parse_x18(self.safe_string_k(bidask.clone(), "ask_qty", &[])));
        m.insert("bid".to_string(), self.parent.parse_x18(self.safe_string_k(bidask.clone(), "bid_price", &[])));
        m.insert("bidVolume".to_string(), self.parent.parse_x18(self.safe_string_k(bidask.clone(), "bid_qty", &[])));
        m.insert("info".to_string(), bidask.clone());
    m
}), &[market.clone()]);

    Value::Null
}

    pub fn handle_bid_ask(&mut self, mut client: Value, mut message: Value) {
        let mut ticker: Value = self.parse_ws_bid_ask(message.clone(), &[]);
        let mut symbol: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
        if is_equal(&symbol, &Value::Null) {
            return;
        }
        add_element_to_object(&mut self.bidsasks, &symbol, ticker.clone());
        add_element_to_object(&mut self.tickers, &symbol, ticker.clone());
        let mut tickers: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        });
        add_element_to_object(&mut tickers, &symbol, ticker.clone());
        client.resolve(&[ticker.clone(), add(&Value::Str("bidask:".to_string()), &symbol)]);
        client.resolve(&[ticker.clone(), add(&Value::Str("ticker:".to_string()), &symbol)]);
        client.resolve(&[tickers.clone(), Value::Str("bidask".to_string())]);
        client.resolve(&[tickers.clone(), Value::Str("ticker".to_string())]);
}

    pub fn parse_ws_all_bids_asks(&self, mut message: Value) -> Value {
        //
        //     {
        //         "type": "all_bbo",
        //         "time": "1781750134714",
        //         "bbos": {
        //             "2": { "bid": "64924000000000000000000", "ask": "64935000000000000000000" }
        //         }
        //     }
        //
        let mut timestamp: Value = self.safe_integer_k(message.clone(), "time", &[]);
        let mut bbos: Value = self.safe_dict_k(message.clone(), "bbos", &[Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        })]);
        let mut marketIds: Value = object_keys(&bbos);
        let mut result: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        });
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_511: bool = true;
            while { if !__for_first_511 { i = add(&i, &Value::Int(1)); } __for_first_511 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
            let mut marketId: Value = get_value(&marketIds, &i);
            let mut marketId: Value = get_value(&marketIds, &i);
            let mut market: Value = self.safe_market(&[marketId.clone()]);
            let mut bbo: Value = self.safe_dict(bbos.clone(), marketId.clone(), &[Value::Map({
                let mut m = indexmap::IndexMap::new();
                m
            })]);
            let mut bid: Value = self.safe_string_k(bbo.clone(), "bid", &[]);
            let mut ask: Value = self.safe_string_k(bbo.clone(), "ask", &[]);
            let mut maxPrice: Value = Value::Str("170141183460469231731687303715884105727".to_string());
            if is_true(&crate::precise::Precise::stringGt(&bid, &Value::Str("0".to_string()))) && is_true(&crate::precise::Precise::stringGt(&ask, &Value::Str("0".to_string()))) && !is_true(&crate::precise::Precise::stringEquals(&bid, &maxPrice)) && !is_true(&crate::precise::Precise::stringEquals(&ask, &maxPrice)) {
                let mut ticker: Value = self.safe_ticker(Value::Map({
                    let mut m = indexmap::IndexMap::new();
                        m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
                        m.insert("timestamp".to_string(), timestamp.clone());
                        m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
                        m.insert("ask".to_string(), self.parent.parse_x18(ask.clone()));
                        m.insert("bid".to_string(), self.parent.parse_x18(bid.clone()));
                        m.insert("info".to_string(), bbo.clone());
                    m
                }), &[market.clone()]);
                let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
                add_element_to_object(&mut result, &symbol, ticker.clone());
            }
        }
        }
        return result;

    Value::Null
}

    pub fn handle_all_bids_asks(&mut self, mut client: Value, mut message: Value) {
        let mut tickers: Value = self.parse_ws_all_bids_asks(message.clone());
        let mut symbols: Value = object_keys(&tickers);
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_512: bool = true;
            while { if !__for_first_512 { i = add(&i, &Value::Int(1)); } __for_first_512 = false; is_less_than(&i, &get_array_length(&symbols)) } {
            let mut symbol: Value = get_value(&symbols, &i);
            let mut symbol: Value = get_value(&symbols, &i);
            let mut ticker: Value = get_value(&tickers, &symbol);
            let mut ticker: Value = get_value(&tickers, &symbol);
            add_element_to_object(&mut self.bidsasks, &symbol, ticker.clone());
            add_element_to_object(&mut self.tickers, &symbol, ticker.clone());
            client.resolve(&[ticker.clone(), add(&Value::Str("bidask:".to_string()), &symbol)]);
            client.resolve(&[ticker.clone(), add(&Value::Str("ticker:".to_string()), &symbol)]);
        }
        }
        client.resolve(&[tickers.clone(), Value::Str("bidask".to_string())]);
        client.resolve(&[tickers.clone(), Value::Str("ticker".to_string())]);
}

    pub fn handle_delta(&self, mut bookside: Value, mut delta: Value) {
        let mut bidAsk: Value = Value::List(vec![self.parent.parse_x18(self.safe_string(delta.clone(), Value::Int(0), &[])), self.parent.parse_x18(self.safe_string(delta.clone(), Value::Int(1), &[]))]);
        bookside.store_array(bidAsk.clone());
}

    pub fn handle_order_book(&mut self, mut client: Value, mut message: Value) {
        //
        //     {
        //         "type": "book_depth",
        //         "min_timestamp": "1683805381879572835",
        //         "max_timestamp": "1683805381879572835",
        //         "last_max_timestamp": "1683805381771464799",
        //         "product_id": 1,
        //         "bids": [["21594490000000000000000", "51007390115411548"]],
        //         "asks": [["21694490000000000000000", "0"]]
        //     }
        //
        let mut marketId: Value = self.safe_string_k(message.clone(), "product_id", &[]);
        let mut market: Value = self.safe_market(&[marketId.clone()]);
        let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
        if !is_true(&(Value::Bool(in_op(&self.orderbooks, &symbol)))) {
            return;
        }
        let mut orderbook: Value = get_value(&self.orderbooks, &symbol);
        let mut messageHash: Value = add(&Value::Str("orderbook:".to_string()), &symbol);
        let mut maxTimestamp: Value = self.safe_string_k(orderbook.clone(), "maxTimestamp", &[]);
        let mut lastMaxTimestamp: Value = self.safe_string_k(message.clone(), "last_max_timestamp", &[]);
        if is_true(&(!is_equal(&maxTimestamp, &Value::Null))) && is_true(&(!is_equal(&lastMaxTimestamp, &Value::Null))) && is_true(&(!is_equal(&maxTimestamp, &lastMaxTimestamp))) {
            let mut subscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".to_string())));
            {
                                let mut i: Value = Value::Int(0);
                let mut __for_first_513: bool = true;
                while { if !__for_first_513 { i = add(&i, &Value::Int(1)); } __for_first_513 = false; is_less_than(&i, &get_array_length(&subscriptions)) } {
                let mut subscriptionHash: Value = get_value(&subscriptions, &i);
                let mut subscriptionHash: Value = get_value(&subscriptions, &i);
                let mut subscription: Value = self.safe_dict(get_value(&client, &Value::Str("subscriptions".to_string())), subscriptionHash.clone(), &[]);
                let mut streamType: Value = self.safe_string_k(subscription.clone(), "streamType", &[]);
                let mut subscriptionSymbol: Value = self.safe_string_k(subscription.clone(), "symbol", &[]);
                if is_true(&(is_equal(&streamType, &Value::Str("book_depth".to_string())))) && is_true(&(is_equal(&subscriptionSymbol, &symbol))) {
                    remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &subscriptionHash);
                }
            }
            }
            let mut subscriptionMsg: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), messageHash.clone(), &[]);
            if !is_equal(&subscriptionMsg, &Value::Null) {
                remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &messageHash);
            }
            remove(&mut self.orderbooks, &symbol);
            let mut error = Value::from(crate::exchange_errors::invalid_nonce(add(&self.id, &Value::Str(" watchOrderBook received invalid nonce".to_string()))));
            client.reject(&[Value::from(error.clone()), messageHash.clone()]);
            return;
        }
        let mut asks: Value = self.safe_list_k(message.clone(), "asks", &[Value::List(vec![])]);
        let mut bids: Value = self.safe_list_k(message.clone(), "bids", &[Value::List(vec![])]);
        self.handle_deltas(get_value(&orderbook, &Value::Str("asks".to_string())), asks.clone());
        self.handle_deltas(get_value(&orderbook, &Value::Str("bids".to_string())), bids.clone());
        let mut timestamp: Value = self.parse_ws_timestamp(message.clone(), Value::Str("max_timestamp".to_string()));
        add_element_to_object(&mut orderbook, &Value::Str("symbol".to_string()), symbol.clone());
        add_element_to_object(&mut orderbook, &Value::Str("timestamp".to_string()), timestamp.clone());
        add_element_to_object(&mut orderbook, &Value::Str("datetime".to_string()), self.iso8601(timestamp.clone()));
        add_element_to_object(&mut orderbook, &Value::Str("maxTimestamp".to_string()), self.safe_string_k(message.clone(), "max_timestamp", &[]));
        client.resolve(&[orderbook.clone(), messageHash.clone()]);
}

    pub fn handle_execute_response(&self, mut client: Value, mut message: Value) {
        //
        //     {
        //         "status": "success",
        //         "signature": "0x...",
        //         "data": {
        //             "digest": "0x..."
        //         },
        //         "request_type": "execute_place_order",
        //         "id": 100
        //     }
        //
        let mut id: Value = self.safe_string_k(message.clone(), "id", &[]);
        if is_equal(&id, &Value::Null) {
            return;
        }
        let mut messageHash: Value = add(&Value::Str("execute:".to_string()), &id);
        let mut subscription: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), messageHash.clone(), &[]);
        if !is_equal(&subscription, &Value::Null) {
            remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &messageHash);
        }
        client.resolve(&[message.clone(), messageHash.clone()]);
}

    pub fn handle_subscription(&self, mut client: Value, mut message: Value) {
        let mut id: Value = self.safe_string_k(message.clone(), "id", &[]);
        let mut subscription: Value = self.safe_dict(get_value(&client, &Value::Str("subscriptions".to_string())), add(&Value::Str("subscription:".to_string()), &id), &[]);
        if !is_equal(&subscription, &Value::Null) {
            let mut subscribeHash: Value = self.safe_string_k(subscription.clone(), "subscribeHash", &[]);
            remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("subscription:".to_string()), &id));
            client.resolve(&[message.clone(), subscribeHash.clone()]);
        }
}

    pub fn handle_authentication(&self, mut client: Value, mut message: Value) {
        let mut id: Value = self.safe_string_k(message.clone(), "id", &[]);
        let mut messageHash: Value = self.safe_string(get_value(&client, &Value::Str("subscriptions".to_string())), add(&Value::Str("authentication:".to_string()), &id), &[]);
        if !is_equal(&messageHash, &Value::Null) {
            remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("authentication:".to_string()), &id));
            add_element_to_object(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &messageHash, Value::Bool(true));
            client.resolve(&[message.clone(), messageHash.clone()]);
        }
}

    pub fn handle_unsubscription(&mut self, mut client: Value, mut message: Value) {
        let mut id: Value = self.safe_string_k(message.clone(), "id", &[]);
        let mut unsubscription: Value = self.safe_dict(get_value(&client, &Value::Str("subscriptions".to_string())), add(&Value::Str("unsubscription:".to_string()), &id), &[]);
        if !is_equal(&unsubscription, &Value::Null) {
            let mut messageHash: Value = self.safe_string_k(unsubscription.clone(), "messageHash", &[]);
            let mut unsubscribeHash: Value = self.safe_string_k(unsubscription.clone(), "unsubscribeHash", &[]);
            remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("unsubscription:".to_string()), &id));
            if !is_equal(&messageHash, &Value::Null) {
                self.clean_unsubscription(client.clone(), messageHash.clone(), unsubscribeHash.clone(), &[]);
                self.handle_unsubscription_cache(messageHash.clone());
            }
            client.resolve(&[message.clone(), unsubscribeHash.clone()]);
            return;
        }
        let mut subscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".to_string())));
        {
                        let mut i: Value = Value::Int(0);
            let mut __for_first_514: bool = true;
            while { if !__for_first_514 { i = add(&i, &Value::Int(1)); } __for_first_514 = false; is_less_than(&i, &get_array_length(&subscriptions)) } {
            let mut unsubscribeHash: Value = get_value(&subscriptions, &i);
            let mut unsubscribeHash: Value = get_value(&subscriptions, &i);
            let mut subscription: Value = get_value(&get_value(&client, &Value::Str("subscriptions".to_string())), &unsubscribeHash);
            let mut subscriptionId: Value = self.safe_string_k(subscription.clone(), "id", &[]);
            if !is_equal(&subscriptionId, &id) {
                continue;
            }
            let mut messageHash: Value = self.safe_string_k(subscription.clone(), "messageHash", &[]);
            if !is_equal(&messageHash, &Value::Null) {
                self.clean_unsubscription(client.clone(), messageHash.clone(), unsubscribeHash.clone(), &[]);
                self.handle_unsubscription_cache(messageHash.clone());
            }
            client.resolve(&[message.clone(), unsubscribeHash.clone()]);
            return;
        }
        }
}

    pub fn handle_unsubscription_cache(&mut self, mut messageHash: Value) {
        if is_equal(&messageHash, &Value::Null) {
            return;
        }
        if is_equal(&get_index_of(&messageHash, &Value::Str("trade:".to_string())), &Value::Int(0)) {
            let mut symbol: Value = replace_str(&messageHash, &Value::Str("trade:".to_string()), &Value::Str("".to_string()));
            if is_true(&Value::Bool(in_op(&self.trades, &symbol))) {
                remove(&mut self.trades, &symbol);
            }
        }  else if is_equal(&get_index_of(&messageHash, &Value::Str("orderbook:".to_string())), &Value::Int(0)) {
            let mut symbol: Value = replace_str(&messageHash, &Value::Str("orderbook:".to_string()), &Value::Str("".to_string()));
            if is_true(&Value::Bool(in_op(&self.orderbooks, &symbol))) {
                remove(&mut self.orderbooks, &symbol);
            }
        }  else if is_equal(&get_index_of(&messageHash, &Value::Str("ohlcv:".to_string())), &Value::Int(0)) {
            let mut parts: Value = split(&messageHash, &Value::Str(":".to_string()));
            let mut timeframe: Value = self.safe_string(parts.clone(), Value::Int(1), &[]);
            let mut symbol: Value = self.safe_string(parts.clone(), Value::Int(2), &[]);
            if is_true(&(!is_equal(&symbol, &Value::Null))) && is_true(&(!is_equal(&timeframe, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.ohlcvs, &symbol)))) && is_true(&(Value::Bool(in_op(&get_value(&self.ohlcvs, &symbol), &timeframe)))) {
                remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
            }
        }  else if is_equal(&get_index_of(&messageHash, &Value::Str("ticker:".to_string())), &Value::Int(0)) {
            let mut symbol: Value = replace_str(&messageHash, &Value::Str("ticker:".to_string()), &Value::Str("".to_string()));
            if is_true(&Value::Bool(in_op(&self.tickers, &symbol))) {
                remove(&mut self.tickers, &symbol);
            }
        }  else if is_equal(&messageHash, &Value::Str("ticker".to_string())) {
            let mut symbols: Value = object_keys(&self.tickers);
            {
                                let mut i: Value = Value::Int(0);
                let mut __for_first_515: bool = true;
                while { if !__for_first_515 { i = add(&i, &Value::Int(1)); } __for_first_515 = false; is_less_than(&i, &get_array_length(&symbols)) } {
                remove(&mut self.tickers, &get_value(&symbols, &i));
            }
            }
        }  else if is_equal(&get_index_of(&messageHash, &Value::Str("bidask:".to_string())), &Value::Int(0)) {
            let mut symbol: Value = replace_str(&messageHash, &Value::Str("bidask:".to_string()), &Value::Str("".to_string()));
            if is_true(&Value::Bool(in_op(&self.bidsasks, &symbol))) {
                remove(&mut self.bidsasks, &symbol);
            }
        }  else if is_equal(&messageHash, &Value::Str("bidask".to_string())) {
            let mut symbols: Value = object_keys(&self.bidsasks);
            {
                                let mut i: Value = Value::Int(0);
                let mut __for_first_516: bool = true;
                while { if !__for_first_516 { i = add(&i, &Value::Int(1)); } __for_first_516 = false; is_less_than(&i, &get_array_length(&symbols)) } {
                remove(&mut self.bidsasks, &get_value(&symbols, &i));
            }
            }
        }  else if is_equal(&get_index_of(&messageHash, &Value::Str("orders".to_string())), &Value::Int(0)) {
            self.orders = Value::Null;
        }  else if is_equal(&get_index_of(&messageHash, &Value::Str("myTrades".to_string())), &Value::Int(0)) {
            self.myTrades = Value::Null;
        }  else if is_equal(&get_index_of(&messageHash, &Value::Str("positions".to_string())), &Value::Int(0)) {
            self.positions = Value::Null;
        }
}

    pub fn ping(&mut self, mut client: Value) -> Value {
        let mut gatewayUrl: Value = get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("gateway".to_string()));
        if is_equal(&get_value(&client, &Value::Str("url".to_string())), &gatewayUrl) {
            return Value::Null;
        }
        return Value::Map({
    let mut m = indexmap::IndexMap::new();
        m.insert("method".to_string(), Value::Str("ping".to_string()));
        m.insert("id".to_string(), self.request_id());
        m.insert("client_time".to_string(), self.number_to_string(self.milliseconds()));
    m
});

    Value::Null
}

    pub fn handle_pong(&self, mut client: Value, mut message: Value) -> Value {
        //
        //     {
        //         "result": {
        //             "method": "pong",
        //             "server_time": "1780000000123",
        //             "client_time": "1780000000000"
        //         },
        //         "id": 10
        //     }
        //
        let mut result: Value = self.safe_dict_k(message.clone(), "result", &[Value::Map({
            let mut m = indexmap::IndexMap::new();
            m
        })]);
        let __ws_arg_18 = self.milliseconds();
        crate::set_value(&mut client, &Value::Str("lastPong".to_string()), self.safe_integer_k(result.clone(), "server_time", &[__ws_arg_18]));
        return message;

    Value::Null
}

    pub fn handle_error_message(&self, mut client: Value, mut message: Value) -> Value {
        let mut error: Value = self.safe_value_k(message.clone(), "error", &[]);
        let mut status: Value = self.safe_string_k(message.clone(), "status", &[]);
        if is_true(&(is_equal(&error, &Value::Null))) && is_true(&(!is_equal(&status, &Value::Str("failure".to_string())))) {
            return Value::Bool(false);
        }
        let mut feedback = Value::from(crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" ".to_string())), &self.json(message.clone()))));
        let mut id: Value = self.safe_string_k(message.clone(), "id", &[]);
        if !is_equal(&id, &Value::Null) {
            let mut executeHash: Value = add(&Value::Str("execute:".to_string()), &id);
            let mut executeSubscription: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), executeHash.clone(), &[]);
            if !is_equal(&executeSubscription, &Value::Null) {
                remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &executeHash);
                client.reject(&[feedback.clone(), executeHash.clone()]);
                return Value::Bool(true);
            }
        }
        let mut subscription: Value = self.safe_dict(get_value(&client, &Value::Str("subscriptions".to_string())), add(&Value::Str("subscription:".to_string()), &id), &[]);
        if !is_equal(&subscription, &Value::Null) {
            let mut subscribeHash: Value = self.safe_string_k(subscription.clone(), "subscribeHash", &[]);
            remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &add(&Value::Str("subscription:".to_string()), &id));
            client.reject(&[feedback.clone(), subscribeHash.clone()]);
        }  else {
            client.reject(&[feedback.clone()]);
        }
        return Value::Bool(true);

    Value::Null
}

    pub fn handle_message(&mut self, mut client: Value, mut message: Value) {
        if is_equal(&self.handle_error_message(client.clone(), message.clone()), &Value::Bool(true)) {
            return;
        }
        let mut id: Value = self.safe_string_k(message.clone(), "id", &[]);
        let mut hasResult: Value = (Value::Bool(in_op(&message, &Value::Str("result".to_string()))));
        let mut result: Value = self.safe_value_k(message.clone(), "result", &[]);
        let mut method: Value = self.safe_string_k(result.clone(), "method", &[]);
        if is_equal(&method, &Value::Str("pong".to_string())) {
            // pong replies carry both 'id' and 'result' so they must be routed
            // before the subscription-ack branch below swallows them
            self.handle_pong(client.clone(), message.clone());
            return;
        }
        let mut requestType: Value = self.safe_string_k(message.clone(), "request_type", &[]);
        if !is_equal(&requestType, &Value::Null) {
            // v2 gateway execute responses carry 'request_type' and the echoed request id
            self.handle_execute_response(client.clone(), message.clone());
            return;
        }
        if is_true(&(!is_equal(&id, &Value::Null))) && is_true(&hasResult) {
            let mut authentication: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), add(&Value::Str("authentication:".to_string()), &id), &[]);
            if !is_equal(&authentication, &Value::Null) {
                self.handle_authentication(client.clone(), message.clone());
                return;
            }
            let mut subscription: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), add(&Value::Str("subscription:".to_string()), &id), &[]);
            if !is_equal(&subscription, &Value::Null) {
                self.handle_subscription(client.clone(), message.clone());
                return;
            }
            if is_equal(&result, &Value::Null) {
                self.handle_unsubscription(client.clone(), message.clone());
                return;
            }
            self.handle_subscription(client.clone(), message.clone());
            return;
        }
        let mut type_var: Value = self.safe_string_k(message.clone(), "type", &[]);
        let mut methods: Value = Value::Map({
            let mut m = indexmap::IndexMap::new();
                m.insert("trade".to_string(), Value::Str("handle_trade".to_string()).clone());
                m.insert("all_bbo".to_string(), Value::Str("handle_all_bids_asks".to_string()).clone());
                m.insert("best_bid_offer".to_string(), Value::Str("handle_bid_ask".to_string()).clone());
                m.insert("book_depth".to_string(), Value::Str("handle_order_book".to_string()).clone());
                m.insert("fill".to_string(), Value::Str("handle_my_trade".to_string()).clone());
                m.insert("latest_candlestick".to_string(), Value::Str("handle_ohlcv".to_string()).clone());
                m.insert("order_update".to_string(), Value::Str("handle_order".to_string()).clone());
                m.insert("position_change".to_string(), Value::Str("handle_position".to_string()).clone());
            m
        });
        let mut handler: Value = self.safe_value(methods.clone(), type_var.clone(), &[]);
        if !is_equal(&handler, &Value::Null) {
            self.dispatch_ws_handler(&handler, &[client.clone(), message.clone()]);
        }
}
}