Skip to main content

ccxt_base/
exchange_generated.rs

1// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
2// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
3
4// Generated from `ts/src/base/Exchange.ts` — methods below the
5// "METHODS BELOW THIS LINE ARE TRANSPILED" marker. Everything
6// above the marker is hand-written (src/exchange.rs / src/prediction_exchange.rs).
7
8#![allow(unused, non_snake_case, clippy::all)]
9
10use crate::Value;
11use crate::ExchangeError;
12use crate::exchange::Exchange;
13use crate::exchange::ExchangeRuntime;
14use crate::exchange::CallDynamicChecked;
15
16
17
18use crate::runtime::*;
19
20pub trait ExchangeBase:
21    crate::exchange::DerivedExchange
22    + std::ops::DerefMut<Target = Exchange>
23    + Send
24    + Sized
25{
26    /// Dispatch a snake_case method name to this core's inherent async
27    /// methods, falling through to `call_dynamic_base` for base-only methods.
28    /// The single required method — every override reaches the core statically.
29    fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
30        -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>;
31
32    /// Route `method(args)` to the derived override by name, with a per-method
33    /// re-entry guard (so a base method calling its own name falls through to
34    /// the base body instead of looping). Replaces `Exchange::dispatch_to_derived`
35    /// — no stored pointer; `call_dynamic` is a static trait call.
36    fn dispatch_to_derived<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
37        -> std::pin::Pin<Box<dyn std::future::Future<Output = Option<crate::Value>> + Send + 'a>>
38    {
39        Box::pin(async move {
40            if !self.dispatch_guard_enter(method) { return None; }
41            let out = futures::FutureExt::catch_unwind(
42                std::panic::AssertUnwindSafe(self.call_dynamic(method, args))
43            ).await;
44            self.dispatch_guard_exit();
45            match out {
46                Ok(v)  => Some(v),
47                Err(p) => std::panic::resume_unwind(p),
48            }
49        })
50    }
51
52    /// `isDictionary(value)` — hand-provided base method. The ast-transpiler
53    /// drops `Exchange.ts`'s `typeof value === 'object'` body, so supply it here
54    /// as a trait default reachable by every Core (used across the base +
55    /// derived exchanges).
56    fn is_dictionary(&self, value: crate::Value) -> crate::Value {
57        crate::Value::Bool(
58            !crate::runtime::is_equal(&value, &crate::Value::Null)
59            && crate::runtime::is_object(&value)
60            && !crate::runtime::is_array(&value)
61        )
62    }
63
64
65    fn describe(&self) -> Value {
66        return Value::Map({
67    let mut m = indexmap::IndexMap::new();
68        m.insert("id".to_string(), self.id.clone());
69        m.insert("name".to_string(), self.name.clone());
70        m.insert("countries".to_string(), self.countries.clone());
71        m.insert("enableRateLimit".to_string(), self.enableRateLimit.clone());
72        m.insert("rateLimit".to_string(), self.rateLimit.clone());
73        m.insert("rateLimiterAlgorithm".to_string(), self.rateLimiterAlgorithm.clone());
74        m.insert("timeout".to_string(), self.timeout.clone());
75        m.insert("certified".to_string(), self.certified.clone());
76        m.insert("pro".to_string(), self.pro.clone());
77        m.insert("alias".to_string(), self.alias.clone());
78        m.insert("dex".to_string(), Value::Bool(false));
79        m.insert("has".to_string(), Value::Map({
80    let mut m = indexmap::IndexMap::new();
81        m.insert("publicAPI".to_string(), Value::Bool(true));
82        m.insert("privateAPI".to_string(), Value::Bool(true));
83        m.insert("CORS".to_string(), Value::Null);
84        m.insert("sandbox".to_string(), Value::Null);
85        m.insert("spot".to_string(), Value::Null);
86        m.insert("margin".to_string(), Value::Null);
87        m.insert("swap".to_string(), Value::Null);
88        m.insert("future".to_string(), Value::Null);
89        m.insert("option".to_string(), Value::Null);
90        m.insert("index".to_string(), Value::Null);
91        m.insert("addMargin".to_string(), Value::Null);
92        m.insert("borrowCrossMargin".to_string(), Value::Null);
93        m.insert("borrowIsolatedMargin".to_string(), Value::Null);
94        m.insert("borrowMargin".to_string(), Value::Null);
95        m.insert("cancelAllOrders".to_string(), Value::Null);
96        m.insert("cancelAllOrdersWs".to_string(), Value::Null);
97        m.insert("cancelOrder".to_string(), Value::Bool(true));
98        m.insert("cancelOrderWithClientOrderId".to_string(), Value::Null);
99        m.insert("cancelOrderWs".to_string(), Value::Null);
100        m.insert("cancelOrders".to_string(), Value::Null);
101        m.insert("cancelOrdersWithClientOrderId".to_string(), Value::Null);
102        m.insert("cancelOrdersWs".to_string(), Value::Null);
103        m.insert("closeAllPositions".to_string(), Value::Null);
104        m.insert("closePosition".to_string(), Value::Null);
105        m.insert("createDepositAddress".to_string(), Value::Null);
106        m.insert("createLimitBuyOrder".to_string(), Value::Null);
107        m.insert("createLimitBuyOrderWs".to_string(), Value::Null);
108        m.insert("createLimitOrder".to_string(), Value::Bool(true));
109        m.insert("createLimitOrderWs".to_string(), Value::Null);
110        m.insert("createLimitSellOrder".to_string(), Value::Null);
111        m.insert("createLimitSellOrderWs".to_string(), Value::Null);
112        m.insert("createMarketBuyOrder".to_string(), Value::Null);
113        m.insert("createMarketBuyOrderWs".to_string(), Value::Null);
114        m.insert("createMarketBuyOrderWithCost".to_string(), Value::Null);
115        m.insert("createMarketBuyOrderWithCostWs".to_string(), Value::Null);
116        m.insert("createMarketOrder".to_string(), Value::Bool(true));
117        m.insert("createMarketOrderWs".to_string(), Value::Bool(true));
118        m.insert("createMarketOrderWithCost".to_string(), Value::Null);
119        m.insert("createMarketOrderWithCostWs".to_string(), Value::Null);
120        m.insert("createMarketSellOrder".to_string(), Value::Null);
121        m.insert("createMarketSellOrderWs".to_string(), Value::Null);
122        m.insert("createMarketSellOrderWithCost".to_string(), Value::Null);
123        m.insert("createMarketSellOrderWithCostWs".to_string(), Value::Null);
124        m.insert("createOrder".to_string(), Value::Bool(true));
125        m.insert("createOrderWs".to_string(), Value::Null);
126        m.insert("createOrders".to_string(), Value::Null);
127        m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Null);
128        m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Null);
129        m.insert("createPostOnlyOrder".to_string(), Value::Null);
130        m.insert("createPostOnlyOrderWs".to_string(), Value::Null);
131        m.insert("createReduceOnlyOrder".to_string(), Value::Null);
132        m.insert("createReduceOnlyOrderWs".to_string(), Value::Null);
133        m.insert("createStopLimitOrder".to_string(), Value::Null);
134        m.insert("createStopLimitOrderWs".to_string(), Value::Null);
135        m.insert("createStopLossOrder".to_string(), Value::Null);
136        m.insert("createStopLossOrderWs".to_string(), Value::Null);
137        m.insert("createStopMarketOrder".to_string(), Value::Null);
138        m.insert("createStopMarketOrderWs".to_string(), Value::Null);
139        m.insert("createStopOrder".to_string(), Value::Null);
140        m.insert("createStopOrderWs".to_string(), Value::Null);
141        m.insert("createTakeProfitOrder".to_string(), Value::Null);
142        m.insert("createTakeProfitOrderWs".to_string(), Value::Null);
143        m.insert("createTrailingAmountOrder".to_string(), Value::Null);
144        m.insert("createTrailingAmountOrderWs".to_string(), Value::Null);
145        m.insert("createTrailingPercentOrder".to_string(), Value::Null);
146        m.insert("createTrailingPercentOrderWs".to_string(), Value::Null);
147        m.insert("createTriggerOrder".to_string(), Value::Null);
148        m.insert("createTriggerOrderWs".to_string(), Value::Null);
149        m.insert("deposit".to_string(), Value::Null);
150        m.insert("editOrder".to_string(), Value::Str("emulated".into()));
151        m.insert("editOrderWithClientOrderId".to_string(), Value::Null);
152        m.insert("editOrders".to_string(), Value::Null);
153        m.insert("editOrderWs".to_string(), Value::Null);
154        m.insert("fetchAccounts".to_string(), Value::Null);
155        m.insert("fetchADLRank".to_string(), Value::Null);
156        m.insert("fetchBalance".to_string(), Value::Bool(true));
157        m.insert("fetchBalanceWs".to_string(), Value::Null);
158        m.insert("fetchBidsAsks".to_string(), Value::Null);
159        m.insert("fetchBorrowInterest".to_string(), Value::Null);
160        m.insert("fetchBorrowRate".to_string(), Value::Null);
161        m.insert("fetchBorrowRateHistories".to_string(), Value::Null);
162        m.insert("fetchBorrowRateHistory".to_string(), Value::Null);
163        m.insert("fetchBorrowRates".to_string(), Value::Null);
164        m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Null);
165        m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Null);
166        m.insert("fetchCanceledOrders".to_string(), Value::Null);
167        m.insert("fetchClosedOrder".to_string(), Value::Null);
168        m.insert("fetchClosedOrders".to_string(), Value::Null);
169        m.insert("fetchClosedOrdersWs".to_string(), Value::Null);
170        m.insert("fetchConvertCurrencies".to_string(), Value::Null);
171        m.insert("fetchConvertQuote".to_string(), Value::Null);
172        m.insert("fetchConvertTrade".to_string(), Value::Null);
173        m.insert("fetchConvertTradeHistory".to_string(), Value::Null);
174        m.insert("fetchCrossBorrowRate".to_string(), Value::Null);
175        m.insert("fetchCrossBorrowRates".to_string(), Value::Null);
176        m.insert("fetchCurrencies".to_string(), Value::Str("emulated".into()));
177        m.insert("fetchCurrenciesWs".to_string(), Value::Str("emulated".into()));
178        m.insert("fetchDeposit".to_string(), Value::Null);
179        m.insert("fetchDepositAddress".to_string(), Value::Null);
180        m.insert("fetchDepositAddresses".to_string(), Value::Null);
181        m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Null);
182        m.insert("fetchDeposits".to_string(), Value::Null);
183        m.insert("fetchDepositsWithdrawals".to_string(), Value::Null);
184        m.insert("fetchDepositsWs".to_string(), Value::Null);
185        m.insert("fetchDepositWithdrawFee".to_string(), Value::Null);
186        m.insert("fetchDepositWithdrawFees".to_string(), Value::Null);
187        m.insert("fetchFundingHistory".to_string(), Value::Null);
188        m.insert("fetchFundingRate".to_string(), Value::Null);
189        m.insert("fetchFundingRateHistory".to_string(), Value::Null);
190        m.insert("fetchFundingInterval".to_string(), Value::Null);
191        m.insert("fetchFundingIntervals".to_string(), Value::Null);
192        m.insert("fetchFundingRates".to_string(), Value::Null);
193        m.insert("fetchGreeks".to_string(), Value::Null);
194        m.insert("fetchIndexOHLCV".to_string(), Value::Null);
195        m.insert("fetchIsolatedBorrowRate".to_string(), Value::Null);
196        m.insert("fetchIsolatedBorrowRates".to_string(), Value::Null);
197        m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Null);
198        m.insert("fetchIsolatedPositions".to_string(), Value::Null);
199        m.insert("fetchL2OrderBook".to_string(), Value::Bool(true));
200        m.insert("fetchL3OrderBook".to_string(), Value::Null);
201        m.insert("fetchLastPrices".to_string(), Value::Null);
202        m.insert("fetchLedger".to_string(), Value::Null);
203        m.insert("fetchLedgerEntry".to_string(), Value::Null);
204        m.insert("fetchLeverage".to_string(), Value::Null);
205        m.insert("fetchLeverages".to_string(), Value::Null);
206        m.insert("fetchLeverageTiers".to_string(), Value::Null);
207        m.insert("fetchLiquidations".to_string(), Value::Null);
208        m.insert("fetchLongShortRatio".to_string(), Value::Null);
209        m.insert("fetchLongShortRatioHistory".to_string(), Value::Null);
210        m.insert("fetchMarginMode".to_string(), Value::Null);
211        m.insert("fetchMarginModes".to_string(), Value::Null);
212        m.insert("fetchMarketLeverageTiers".to_string(), Value::Null);
213        m.insert("fetchMarkets".to_string(), Value::Bool(true));
214        m.insert("fetchMarketsWs".to_string(), Value::Null);
215        m.insert("fetchMarkOHLCV".to_string(), Value::Null);
216        m.insert("fetchMyLiquidations".to_string(), Value::Null);
217        m.insert("fetchMySettlementHistory".to_string(), Value::Null);
218        m.insert("fetchMyTrades".to_string(), Value::Null);
219        m.insert("fetchMyTradesWs".to_string(), Value::Null);
220        m.insert("fetchOHLCV".to_string(), Value::Null);
221        m.insert("fetchOHLCVWs".to_string(), Value::Null);
222        m.insert("fetchOpenInterest".to_string(), Value::Null);
223        m.insert("fetchOpenInterests".to_string(), Value::Null);
224        m.insert("fetchOpenInterestHistory".to_string(), Value::Null);
225        m.insert("fetchOpenOrder".to_string(), Value::Null);
226        m.insert("fetchOpenOrders".to_string(), Value::Null);
227        m.insert("fetchOpenOrdersWs".to_string(), Value::Null);
228        m.insert("fetchOption".to_string(), Value::Null);
229        m.insert("fetchOptionChain".to_string(), Value::Null);
230        m.insert("fetchOrder".to_string(), Value::Null);
231        m.insert("fetchOrderWithClientOrderId".to_string(), Value::Null);
232        m.insert("fetchOrderBook".to_string(), Value::Bool(true));
233        m.insert("fetchOrderBooks".to_string(), Value::Null);
234        m.insert("fetchOrderBookWs".to_string(), Value::Null);
235        m.insert("fetchOrders".to_string(), Value::Null);
236        m.insert("fetchOrdersByStatus".to_string(), Value::Null);
237        m.insert("fetchOrdersWs".to_string(), Value::Null);
238        m.insert("fetchOrderTrades".to_string(), Value::Null);
239        m.insert("fetchOrderWs".to_string(), Value::Null);
240        m.insert("fetchPosition".to_string(), Value::Null);
241        m.insert("fetchPositionADLRank".to_string(), Value::Null);
242        m.insert("fetchPositionsADLRank".to_string(), Value::Null);
243        m.insert("fetchPositionHistory".to_string(), Value::Null);
244        m.insert("fetchPositionsHistory".to_string(), Value::Null);
245        m.insert("fetchPositionWs".to_string(), Value::Null);
246        m.insert("fetchPositionMode".to_string(), Value::Null);
247        m.insert("fetchPositions".to_string(), Value::Null);
248        m.insert("fetchPositionsWs".to_string(), Value::Null);
249        m.insert("fetchPositionsForSymbol".to_string(), Value::Null);
250        m.insert("fetchPositionsForSymbolWs".to_string(), Value::Null);
251        m.insert("fetchPositionsRisk".to_string(), Value::Null);
252        m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Null);
253        m.insert("fetchSettlementHistory".to_string(), Value::Null);
254        m.insert("fetchStatus".to_string(), Value::Null);
255        m.insert("fetchTicker".to_string(), Value::Bool(true));
256        m.insert("fetchTickerWs".to_string(), Value::Null);
257        m.insert("fetchTickers".to_string(), Value::Null);
258        m.insert("fetchMarkPrices".to_string(), Value::Null);
259        m.insert("fetchTickersWs".to_string(), Value::Null);
260        m.insert("fetchTime".to_string(), Value::Null);
261        m.insert("fetchTrades".to_string(), Value::Bool(true));
262        m.insert("fetchTradesWs".to_string(), Value::Null);
263        m.insert("fetchTradingFee".to_string(), Value::Null);
264        m.insert("fetchTradingFees".to_string(), Value::Null);
265        m.insert("fetchTradingFeesWs".to_string(), Value::Null);
266        m.insert("fetchTradingLimits".to_string(), Value::Null);
267        m.insert("fetchTransactionFee".to_string(), Value::Null);
268        m.insert("fetchTransactionFees".to_string(), Value::Null);
269        m.insert("fetchTransactions".to_string(), Value::Null);
270        m.insert("fetchTransfer".to_string(), Value::Null);
271        m.insert("fetchTransfers".to_string(), Value::Null);
272        m.insert("fetchUnderlyingAssets".to_string(), Value::Null);
273        m.insert("fetchVolatilityHistory".to_string(), Value::Null);
274        m.insert("fetchWithdrawAddresses".to_string(), Value::Null);
275        m.insert("fetchWithdrawal".to_string(), Value::Null);
276        m.insert("fetchWithdrawals".to_string(), Value::Null);
277        m.insert("fetchWithdrawalsWs".to_string(), Value::Null);
278        m.insert("fetchWithdrawalWhitelist".to_string(), Value::Null);
279        m.insert("reduceMargin".to_string(), Value::Null);
280        m.insert("repayCrossMargin".to_string(), Value::Null);
281        m.insert("repayIsolatedMargin".to_string(), Value::Null);
282        m.insert("setLeverage".to_string(), Value::Null);
283        m.insert("setMargin".to_string(), Value::Null);
284        m.insert("setMarginMode".to_string(), Value::Null);
285        m.insert("setPositionMode".to_string(), Value::Null);
286        m.insert("signIn".to_string(), Value::Null);
287        m.insert("transfer".to_string(), Value::Null);
288        m.insert("watchBalance".to_string(), Value::Null);
289        m.insert("watchMyTrades".to_string(), Value::Null);
290        m.insert("watchOHLCV".to_string(), Value::Null);
291        m.insert("watchOHLCVForSymbols".to_string(), Value::Null);
292        m.insert("watchOrderBook".to_string(), Value::Null);
293        m.insert("watchBidsAsks".to_string(), Value::Null);
294        m.insert("watchOrderBookForSymbols".to_string(), Value::Null);
295        m.insert("watchOrders".to_string(), Value::Null);
296        m.insert("watchOrdersForSymbols".to_string(), Value::Null);
297        m.insert("watchPosition".to_string(), Value::Null);
298        m.insert("watchPositions".to_string(), Value::Null);
299        m.insert("watchStatus".to_string(), Value::Null);
300        m.insert("watchTicker".to_string(), Value::Null);
301        m.insert("watchTickers".to_string(), Value::Null);
302        m.insert("watchTrades".to_string(), Value::Null);
303        m.insert("watchTradesForSymbols".to_string(), Value::Null);
304        m.insert("watchLiquidations".to_string(), Value::Null);
305        m.insert("watchLiquidationsForSymbols".to_string(), Value::Null);
306        m.insert("watchMyLiquidations".to_string(), Value::Null);
307        m.insert("unWatchOrders".to_string(), Value::Null);
308        m.insert("unWatchTrades".to_string(), Value::Null);
309        m.insert("unWatchTradesForSymbols".to_string(), Value::Null);
310        m.insert("unWatchOHLCVForSymbols".to_string(), Value::Null);
311        m.insert("unWatchOrderBookForSymbols".to_string(), Value::Null);
312        m.insert("unWatchPositions".to_string(), Value::Null);
313        m.insert("unWatchOrderBook".to_string(), Value::Null);
314        m.insert("unWatchTickers".to_string(), Value::Null);
315        m.insert("unWatchMyTrades".to_string(), Value::Null);
316        m.insert("unWatchTicker".to_string(), Value::Null);
317        m.insert("unWatchOHLCV".to_string(), Value::Null);
318        m.insert("watchMyLiquidationsForSymbols".to_string(), Value::Null);
319        m.insert("withdraw".to_string(), Value::Null);
320        m.insert("ws".to_string(), Value::Null);
321    m
322}));
323        m.insert("urls".to_string(), Value::Map({
324    let mut m = indexmap::IndexMap::new();
325        m.insert("logo".to_string(), Value::Null);
326        m.insert("api".to_string(), Value::Null);
327        m.insert("test".to_string(), Value::Null);
328        m.insert("www".to_string(), Value::Null);
329        m.insert("doc".to_string(), Value::Null);
330        m.insert("api_management".to_string(), Value::Null);
331        m.insert("fees".to_string(), Value::Null);
332        m.insert("referral".to_string(), Value::Null);
333    m
334}));
335        m.insert("api".to_string(), Value::Null);
336        m.insert("requiredCredentials".to_string(), Value::Map({
337    let mut m = indexmap::IndexMap::new();
338        m.insert("apiKey".to_string(), Value::Bool(true));
339        m.insert("secret".to_string(), Value::Bool(true));
340        m.insert("uid".to_string(), Value::Bool(false));
341        m.insert("accountId".to_string(), Value::Bool(false));
342        m.insert("login".to_string(), Value::Bool(false));
343        m.insert("password".to_string(), Value::Bool(false));
344        m.insert("twofa".to_string(), Value::Bool(false));
345        m.insert("privateKey".to_string(), Value::Bool(false));
346        m.insert("walletAddress".to_string(), Value::Bool(false));
347        m.insert("token".to_string(), Value::Bool(false));
348    m
349}));
350        m.insert("markets".to_string(), Value::Null);
351        m.insert("currencies".to_string(), Value::Map({
352    let mut m = indexmap::IndexMap::new();
353    m
354}));
355        m.insert("timeframes".to_string(), Value::Null);
356        m.insert("fees".to_string(), Value::Map({
357    let mut m = indexmap::IndexMap::new();
358        m.insert("trading".to_string(), Value::Map({
359    let mut m = indexmap::IndexMap::new();
360        m.insert("tierBased".to_string(), Value::Null);
361        m.insert("percentage".to_string(), Value::Null);
362        m.insert("taker".to_string(), Value::Null);
363        m.insert("maker".to_string(), Value::Null);
364    m
365}));
366        m.insert("funding".to_string(), Value::Map({
367    let mut m = indexmap::IndexMap::new();
368        m.insert("tierBased".to_string(), Value::Null);
369        m.insert("percentage".to_string(), Value::Null);
370        m.insert("withdraw".to_string(), Value::Map({
371    let mut m = indexmap::IndexMap::new();
372    m
373}));
374        m.insert("deposit".to_string(), Value::Map({
375    let mut m = indexmap::IndexMap::new();
376    m
377}));
378    m
379}));
380    m
381}));
382        m.insert("status".to_string(), Value::Map({
383    let mut m = indexmap::IndexMap::new();
384        m.insert("status".to_string(), Value::Str("ok".into()));
385        m.insert("updated".to_string(), Value::Null);
386        m.insert("eta".to_string(), Value::Null);
387        m.insert("url".to_string(), Value::Null);
388        m.insert("info".to_string(), Value::Null);
389    m
390}));
391        m.insert("exceptions".to_string(), Value::Null);
392        m.insert("httpExceptions".to_string(), Value::Map({
393    let mut m = indexmap::IndexMap::new();
394        m.insert("422".to_string(), Value::Str("ExchangeError".into()).clone());
395        m.insert("418".to_string(), Value::Str("DDoSProtection".into()).clone());
396        m.insert("429".to_string(), Value::Str("RateLimitExceeded".into()).clone());
397        m.insert("404".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
398        m.insert("409".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
399        m.insert("410".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
400        m.insert("451".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
401        m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
402        m.insert("501".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
403        m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
404        m.insert("520".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
405        m.insert("521".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
406        m.insert("522".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
407        m.insert("525".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
408        m.insert("526".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
409        m.insert("400".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
410        m.insert("403".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
411        m.insert("405".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
412        m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
413        m.insert("530".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
414        m.insert("408".to_string(), Value::Str("RequestTimeout".into()).clone());
415        m.insert("504".to_string(), Value::Str("RequestTimeout".into()).clone());
416        m.insert("401".to_string(), Value::Str("AuthenticationError".into()).clone());
417        m.insert("407".to_string(), Value::Str("AuthenticationError".into()).clone());
418        m.insert("511".to_string(), Value::Str("AuthenticationError".into()).clone());
419    m
420}));
421        m.insert("commonCurrencies".to_string(), Value::Map({
422    let mut m = indexmap::IndexMap::new();
423        m.insert("XBT".to_string(), Value::Str("BTC".into()));
424        m.insert("BCHSV".to_string(), Value::Str("BSV".into()));
425    m
426}));
427        m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
428        m.insert("paddingMode".to_string(), Value::Int(crate::runtime::NO_PADDING));
429        m.insert("limits".to_string(), Value::Map({
430    let mut m = indexmap::IndexMap::new();
431        m.insert("leverage".to_string(), Value::Map({
432    let mut m = indexmap::IndexMap::new();
433        m.insert("min".to_string(), Value::Null);
434        m.insert("max".to_string(), Value::Null);
435    m
436}));
437        m.insert("amount".to_string(), Value::Map({
438    let mut m = indexmap::IndexMap::new();
439        m.insert("min".to_string(), Value::Null);
440        m.insert("max".to_string(), Value::Null);
441    m
442}));
443        m.insert("price".to_string(), Value::Map({
444    let mut m = indexmap::IndexMap::new();
445        m.insert("min".to_string(), Value::Null);
446        m.insert("max".to_string(), Value::Null);
447    m
448}));
449        m.insert("cost".to_string(), Value::Map({
450    let mut m = indexmap::IndexMap::new();
451        m.insert("min".to_string(), Value::Null);
452        m.insert("max".to_string(), Value::Null);
453    m
454}));
455    m
456}));
457        m.insert("rollingWindowSize".to_string(), Value::Int(60000));
458    m
459});
460
461    Value::Null
462}
463
464    fn clean_rest_data(&mut self) {
465        self.ids = Value::Null;
466        self.markets = Value::Null;
467        self.markets_by_id = Value::Null;
468        self.symbols = Value::from(vec![]);
469        self.codes = Value::Null;
470        { let __t = self.create_safe_dictionary(&[]); self.currencies = __t; }
471        self.currencies_by_id = Value::Null;
472        self.baseCurrencies = Value::Null;
473        self.quoteCurrencies = Value::Null;
474        self.last_http_response = Value::Null;
475        // this.last_json_response = undefined; // not unified prop
476        self.last_response_headers = Value::Null;
477        self.last_request_headers = Value::Null;
478}
479
480    fn clean_ws_data(&mut self) {
481        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.balance = __t; }
482        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.orderbooks = __t; }
483        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.tickers = __t; }
484        self.liquidations = Value::Null;
485        self.myLiquidations = Value::Null;
486        self.orders = Value::Null;
487        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.trades = __t; }
488        { let __t = self.create_safe_dictionary(&[]); self.transactions = __t; }
489        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.ohlcvs = __t; }
490        self.myTrades = Value::Null;
491        self.positions = Value::Null;
492}
493
494    fn safe_bool_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
495        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
496        /*
497         * @ignore
498         * @method
499         * @description safely extract boolean value from dictionary or list
500         * @returns {bool | undefined}
501         */
502        let mut value: Value = self.safe_value_n(dictionaryOrList, keys, &[defaultValue.clone()]);
503        if matches!(&value, Value::Bool(_)) {
504            return value;
505        }
506        return defaultValue;
507
508    Value::Null
509}
510
511    fn safe_bool2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
512        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
513        /*
514         * @ignore
515         * @method
516         * @description safely extract boolean value from dictionary or list
517         * @returns {bool | undefined}
518         */
519        let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1, &[]);
520        if matches!(&value, Value::Bool(_)) {
521            return value;
522        }
523        let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
524        if matches!(&value2, Value::Bool(_)) {
525            return value2;
526        }
527        return defaultValue;
528
529    Value::Null
530}
531
532    fn safe_bool(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
533        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
534        /*
535         * @ignore
536         * @method
537         * @description safely extract boolean value from dictionary or list
538         * @returns {bool | undefined}
539         */
540        let mut value: Value = self.safe_value(dictionaryOrList, key, &[defaultValue.clone()]);
541        if matches!(&value, Value::Bool(_)) {
542            return value;
543        }
544        return defaultValue;
545
546    Value::Null
547}
548
549    fn safe_dict_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
550        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
551        /*
552         * @ignore
553         * @method
554         * @description safely extract a dictionary from dictionary or list
555         * @returns {object | undefined}
556         */
557        let mut value: Value = self.safe_value_n(dictionaryOrList, keys, &[defaultValue.clone()]);
558        if (value == Value::Null) {
559            return defaultValue;
560        }
561        if is_true(&self.is_dictionary(value.clone())) {
562            return value;
563        }
564        return defaultValue;
565
566    Value::Null
567}
568
569    fn safe_dict(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
570        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
571        /*
572         * @ignore
573         * @method
574         * @description safely extract a dictionary from dictionary or list
575         * @returns {object | undefined}
576         */
577        let mut value: Value = self.safe_value(dictionaryOrList, key, &[defaultValue.clone()]);
578        if (value == Value::Null) {
579            return defaultValue;
580        }
581        if is_true(&self.is_dictionary(value.clone())) {
582            return value;
583        }
584        return defaultValue;
585
586    Value::Null
587}
588
589    fn safe_dict2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
590        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
591        /*
592         * @ignore
593         * @method
594         * @description safely extract a dictionary from dictionary or list
595         * @returns {object | undefined}
596         */
597        let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1, &[]);
598        if is_true(&self.is_dictionary(value.clone())) {
599            return value;
600        }
601        let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
602        if is_true(&self.is_dictionary(value2.clone())) {
603            return value2;
604        }
605        return defaultValue;
606
607    Value::Null
608}
609
610    fn safe_list_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
611        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
612        /*
613         * @ignore
614         * @method
615         * @description safely extract an Array from dictionary or list
616         * @returns {Array | undefined}
617         */
618        let mut value: Value = self.safe_value_n(dictionaryOrList, keys, &[defaultValue.clone()]);
619        if (value == Value::Null) {
620            return defaultValue;
621        }
622        if (matches!(&value, Value::Arr(_))) {
623            return value;
624        }
625        return defaultValue;
626
627    Value::Null
628}
629
630    fn safe_list2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
631        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
632        /*
633         * @ignore
634         * @method
635         * @description safely extract an Array from dictionary or list
636         * @returns {Array | undefined}
637         */
638        let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1, &[]);
639        if (value != Value::Null) && (matches!(&value, Value::Arr(_))) {
640            return value;
641        }
642        let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
643        if (value2 != Value::Null) && (matches!(&value2, Value::Arr(_))) {
644            return value2;
645        }
646        return defaultValue;
647
648    Value::Null
649}
650
651    fn safe_list(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
652        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
653        /*
654         * @ignore
655         * @method
656         * @description safely extract an Array from dictionary or list
657         * @returns {Array | undefined}
658         */
659        let mut value: Value = self.safe_value(dictionaryOrList, key, &[defaultValue.clone()]);
660        if (value == Value::Null) {
661            return defaultValue;
662        }
663        if (matches!(&value, Value::Arr(_))) {
664            return value;
665        }
666        return defaultValue;
667
668    Value::Null
669}
670
671    fn store_by_key(&self, mut dict: Value, mut key: Value, mut value: Value) {
672        /*
673         * @ignore
674         * @method
675         * @description store value under key if key is defined (no-op on undefined)
676         */
677        let mut k: Value = key.clone();
678        if (k != Value::Null) {
679            add_element_to_object(&mut dict, &k, value);
680        }
681}
682
683    fn handle_deltas(&self, mut orderbook: Value, mut deltas: Value) {
684        {
685                        let mut i: Value = Value::Int(0);
686            let mut __for_first_71: bool = true;
687            while { if !__for_first_71 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_71 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
688            self.handle_delta(orderbook.clone(), get_value(&deltas, &i));
689        }
690        }
691}
692
693    fn handle_delta(&self, mut bookside: Value, mut delta: Value) {
694        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" handleDelta not supported yet".into()))));
695}
696
697    fn handle_deltas_with_keys(&self, mut bookSide: Value, mut deltas: Value, optional_args: &[Value]) {
698        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
699        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
700        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
701        {
702                        let mut i: Value = Value::Int(0);
703            let mut __for_first_72: bool = true;
704            while { if !__for_first_72 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_72 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
705            let mut bidAsk: Value = self.parse_order_book_bid_ask(get_value(&deltas, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
706            bookSide.store_array(bidAsk);
707        }
708        }
709}
710
711    fn get_cache_index(&self, mut orderbook: Value, mut deltas: Value) -> Value {
712        return Value::Int(-1);
713
714    Value::Null
715}
716
717    fn arrays_concat(&self, mut arraysOfArrays: Value) -> Value {
718        let mut result: Value = Value::from(vec![]);
719        {
720                        let mut i: Value = Value::Int(0);
721            let mut __for_first_73: bool = true;
722            while { if !__for_first_73 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_73 = false; i.as_f64().unwrap_or(f64::NAN) < ((arraysOfArrays.len() as i64) as f64) } {
723            result = self.array_concat(result.clone(), arraysOfArrays.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
724        }
725        }
726        return result;
727
728    Value::Null
729}
730
731    fn find_timeframe(&self, mut timeframe: Value, optional_args: &[Value]) -> Value {
732        let mut timeframes = get_arg(optional_args, 0, Value::Null);
733        if (timeframes == Value::Null) {
734            timeframes = self.timeframes.clone();
735        }
736        let mut keys: Value = object_keys(&timeframes);
737        {
738                        let mut i: Value = Value::Int(0);
739            let mut __for_first_74: bool = true;
740            while { if !__for_first_74 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_74 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
741            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
742            if is_equal(&get_value(&timeframes, &key), &timeframe) {
743                return key;
744            }
745        }
746        }
747        return Value::Null;
748
749    Value::Null
750}
751
752    fn check_proxy_url_settings(&self, optional_args: &[Value]) -> Value {
753        let mut url = get_arg(optional_args, 0, Value::Null);
754        let mut method = get_arg(optional_args, 1, Value::Null);
755        let mut headers = get_arg(optional_args, 2, Value::Null);
756        let mut body = get_arg(optional_args, 3, Value::Null);
757        let mut usedProxies: Value = Value::from(vec![]);
758        let mut proxyUrl: Value = Value::Null;
759        if (self.proxyUrl.clone() != Value::Null) {
760            append_to_array(&mut usedProxies, Value::Str("proxyUrl".into()));
761            proxyUrl = self.proxyUrl.clone();
762        }
763        if (self.proxy_url.clone() != Value::Null) {
764            append_to_array(&mut usedProxies, Value::Str("proxy_url".into()));
765            proxyUrl = self.proxy_url.clone();
766        }
767        if (self.proxyUrlCallback.clone() != Value::Null) {
768            append_to_array(&mut usedProxies, Value::Str("proxyUrlCallback".into()));
769            proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
770        }
771        if (self.proxy_url_callback.clone() != Value::Null) {
772            append_to_array(&mut usedProxies, Value::Str("proxy_url_callback".into()));
773            proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
774        }
775        // backwards-compatibility
776        if (self.proxy.clone() != Value::Null) {
777            append_to_array(&mut usedProxies, Value::Str("proxy".into()));
778            if is_function(&self.proxy) {
779                proxyUrl = self.proxy_fn(url, method, headers, body);
780            }  else {
781                proxyUrl = self.proxy.clone();
782            }
783        }
784        let mut length: f64 = ((usedProxies.len() as i64) as f64);
785        if length > ((1i64) as f64) {
786            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
787            panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback".into()))));
788        }
789        return proxyUrl;
790
791    Value::Null
792}
793
794    fn url_encoder_for_proxy_url(&self, mut targetUrl: Value) -> Value {
795        // to be overriden
796        let mut includesQuery: bool = Value::Int(targetUrl.as_str().and_then(|__s| __s.find("?")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64);
797        let mut finalUrl: Value = (if includesQuery { self.encode_uri_component(targetUrl.clone()) } else { targetUrl });
798        return finalUrl;
799
800    Value::Null
801}
802
803    fn check_proxy_settings(&self, optional_args: &[Value]) -> Value {
804        let mut url = get_arg(optional_args, 0, Value::Null);
805        let mut method = get_arg(optional_args, 1, Value::Null);
806        let mut headers = get_arg(optional_args, 2, Value::Null);
807        let mut body = get_arg(optional_args, 3, Value::Null);
808        let mut usedProxies: Value = Value::from(vec![]);
809        let mut httpProxy: Value = Value::Null;
810        let mut httpsProxy: Value = Value::Null;
811        let mut socksProxy: Value = Value::Null;
812        // httpProxy
813        let mut isHttpProxyDefined: Value = self.value_is_defined(self.httpProxy.clone());
814        let mut isHttp_proxy_defined: Value = self.value_is_defined(self.http_proxy.clone());
815        if is_true(&isHttpProxyDefined) || is_true(&isHttp_proxy_defined) {
816            append_to_array(&mut usedProxies, Value::Str("httpProxy".into()));
817            httpProxy = (if is_true(&isHttpProxyDefined) { self.httpProxy.clone() } else { self.http_proxy.clone() });
818        }
819        let mut ishttpProxyCallbackDefined: Value = self.value_is_defined(self.httpProxyCallback.clone());
820        let mut ishttp_proxy_callback_defined: Value = self.value_is_defined(self.http_proxy_callback.clone());
821        if is_true(&ishttpProxyCallbackDefined) || is_true(&ishttp_proxy_callback_defined) {
822            append_to_array(&mut usedProxies, Value::Str("httpProxyCallback".into()));
823            httpProxy = (if is_true(&ishttpProxyCallbackDefined) { self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) });
824        }
825        // httpsProxy
826        let mut isHttpsProxyDefined: Value = self.value_is_defined(self.httpsProxy.clone());
827        let mut isHttps_proxy_defined: Value = self.value_is_defined(self.https_proxy.clone());
828        if is_true(&isHttpsProxyDefined) || is_true(&isHttps_proxy_defined) {
829            append_to_array(&mut usedProxies, Value::Str("httpsProxy".into()));
830            httpsProxy = (if is_true(&isHttpsProxyDefined) { self.httpsProxy.clone() } else { self.https_proxy.clone() });
831        }
832        let mut ishttpsProxyCallbackDefined: Value = self.value_is_defined(self.httpsProxyCallback.clone());
833        let mut ishttps_proxy_callback_defined: Value = self.value_is_defined(self.https_proxy_callback.clone());
834        if is_true(&ishttpsProxyCallbackDefined) || is_true(&ishttps_proxy_callback_defined) {
835            append_to_array(&mut usedProxies, Value::Str("httpsProxyCallback".into()));
836            httpsProxy = (if is_true(&ishttpsProxyCallbackDefined) { self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) });
837        }
838        // socksProxy
839        let mut isSocksProxyDefined: Value = self.value_is_defined(self.socksProxy.clone());
840        let mut isSocks_proxy_defined: Value = self.value_is_defined(self.socks_proxy.clone());
841        if is_true(&isSocksProxyDefined) || is_true(&isSocks_proxy_defined) {
842            append_to_array(&mut usedProxies, Value::Str("socksProxy".into()));
843            socksProxy = (if is_true(&isSocksProxyDefined) { self.socksProxy.clone() } else { self.socks_proxy.clone() });
844        }
845        let mut issocksProxyCallbackDefined: Value = self.value_is_defined(self.socksProxyCallback.clone());
846        let mut issocks_proxy_callback_defined: Value = self.value_is_defined(self.socks_proxy_callback.clone());
847        if is_true(&issocksProxyCallbackDefined) || is_true(&issocks_proxy_callback_defined) {
848            append_to_array(&mut usedProxies, Value::Str("socksProxyCallback".into()));
849            socksProxy = (if is_true(&issocksProxyCallbackDefined) { self.socks_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.socks_proxy_callback_fn(url, method, headers, body) });
850        }
851        // check
852        let mut length: f64 = ((usedProxies.len() as i64) as f64);
853        if length > ((1i64) as f64) {
854            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
855            panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback".into()))));
856        }
857        return Value::from(vec![httpProxy, httpsProxy, socksProxy]);
858
859    Value::Null
860}
861
862    fn check_ws_proxy_settings(&self) -> Value {
863        let mut usedProxies: Value = Value::from(vec![]);
864        let mut wsProxy: Value = Value::Null;
865        let mut wssProxy: Value = Value::Null;
866        let mut wsSocksProxy: Value = Value::Null;
867        // ws proxy
868        let mut isWsProxyDefined: Value = self.value_is_defined(self.wsProxy.clone());
869        let mut is_ws_proxy_defined: Value = self.value_is_defined(self.ws_proxy.clone());
870        if is_true(&isWsProxyDefined) || is_true(&is_ws_proxy_defined) {
871            append_to_array(&mut usedProxies, Value::Str("wsProxy".into()));
872            wsProxy = (if is_true(&(isWsProxyDefined)) { self.wsProxy.clone() } else { self.ws_proxy.clone() });
873        }
874        // wss proxy
875        let mut isWssProxyDefined: Value = self.value_is_defined(self.wssProxy.clone());
876        let mut is_wss_proxy_defined: Value = self.value_is_defined(self.wss_proxy.clone());
877        if is_true(&isWssProxyDefined) || is_true(&is_wss_proxy_defined) {
878            append_to_array(&mut usedProxies, Value::Str("wssProxy".into()));
879            wssProxy = (if is_true(&(isWssProxyDefined)) { self.wssProxy.clone() } else { self.wss_proxy.clone() });
880        }
881        // ws socks proxy
882        let mut isWsSocksProxyDefined: Value = self.value_is_defined(self.wsSocksProxy.clone());
883        let mut is_ws_socks_proxy_defined: Value = self.value_is_defined(self.ws_socks_proxy.clone());
884        if is_true(&isWsSocksProxyDefined) || is_true(&is_ws_socks_proxy_defined) {
885            append_to_array(&mut usedProxies, Value::Str("wsSocksProxy".into()));
886            wsSocksProxy = (if is_true(&(isWsSocksProxyDefined)) { self.wsSocksProxy.clone() } else { self.ws_socks_proxy.clone() });
887        }
888        // check
889        let mut length: f64 = ((usedProxies.len() as i64) as f64);
890        if length > ((1i64) as f64) {
891            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
892            panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from: wsProxy, wssProxy, wsSocksProxy".into()))));
893        }
894        return Value::from(vec![wsProxy, wssProxy, wsSocksProxy]);
895
896    Value::Null
897}
898
899    fn check_conflicting_proxies(&self, mut proxyAgentSet: Value, mut proxyUrlSet: Value) {
900        let mut proxyAgentIsSet: bool = (proxyAgentSet != Value::Null) && (proxyAgentSet != Value::Null) && (proxyAgentSet.as_str() != Some(""));
901        let mut proxyUrlIsSet: bool = (proxyUrlSet != Value::Null) && (proxyUrlSet != Value::Null) && (proxyUrlSet.as_str() != Some(""));
902        if proxyAgentIsSet && proxyUrlIsSet {
903            panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy".into()))));
904        }
905}
906
907    fn check_address(&self, optional_args: &[Value]) -> Value {
908        let mut address = get_arg(optional_args, 0, Value::Null);
909        if (address == Value::Null) {
910            panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", self.id.clone(), Value::Str(" address is undefined".into()))));
911        }
912        // check the address is not the same letter like 'aaaaa' nor too short nor has a space
913        let mut uniqChars: Value = (self.unique(self.string_to_chars_array(address.clone())));
914        let mut length: f64 = ((uniqChars.len() as i64) as f64); // py transpiler trick
915        if (length == 1.0) || ((address.len() as i64) as f64) < self.minFundingAddressLength.as_f64().unwrap_or(f64::NAN) || Value::Int(address.as_str().and_then(|__s| __s.find(" ")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64) {
916            panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" address is invalid or has less than ".into())).into()), to_string_val(&self.minFundingAddressLength)).into()), Value::Str(" characters: \"".into())).into()), to_string_val(&address)).into()), Value::Str("\"".into()))));
917        }
918        return address;
919
920    Value::Null
921}
922
923    fn find_message_hashes(&self, mut client: Value, mut element: Value) -> Value {
924        let mut result: Value = Value::from(vec![]);
925        let mut messageHashes: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
926        {
927                        let mut i: Value = Value::Int(0);
928            let mut __for_first_75: bool = true;
929            while { if !__for_first_75 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_75 = false; i.as_f64().unwrap_or(f64::NAN) < ((messageHashes.len() as i64) as f64) } {
930            let mut messageHash: Value = messageHashes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
931            if get_index_of(&messageHash, &element).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
932                append_to_array(&mut result, messageHash.clone());
933            }
934        }
935        }
936        return result;
937
938    Value::Null
939}
940
941    fn filter_by_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
942        let mut limit = get_arg(optional_args, 0, Value::Null);
943        let mut key = get_arg(optional_args, 1, Value::Str("timestamp".into()));
944        let mut fromStart = get_arg(optional_args, 2, Value::Bool(false));
945        if self.value_is_defined(limit.clone()).as_bool() == Some(true) {
946            let mut arrayLength: Value = Value::Int(array.len() as i64);
947            if arrayLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
948                let mut ascending: bool = true;
949                if (in_op(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key)) {
950                    let mut first: Value = get_value(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key);
951                    let mut last: Value = get_value(&get_value(&array, &(match (&(arrayLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &key);
952                    if (first != Value::Null) && (last != Value::Null) {
953                        ascending = is_less_than_or_equal(&first, &last); // true if array is sorted in ascending order based on 'timestamp'
954                    }
955                }
956                if is_true(&fromStart) {
957                    if limit.as_f64().unwrap_or(f64::NAN) > arrayLength.as_f64().unwrap_or(f64::NAN) {
958                        limit = arrayLength;
959                    }
960                    // array = ascending ? this.arraySlice (array, 0, limit) : this.arraySlice (array, -limit);
961                    if ascending {
962                        array = self.array_slice(array.clone(), Value::Int(0), &[limit.clone()]);
963                    }  else {
964                        array = self.array_slice(array.clone(), negate(&limit), &[]);
965                    }
966                }  else {
967                    // array = ascending ? this.arraySlice (array, -limit) : this.arraySlice (array, 0, limit);
968                    if ascending {
969                        array = self.array_slice(array.clone(), negate(&limit), &[]);
970                    }  else {
971                        array = self.array_slice(array.clone(), Value::Int(0), &[limit]);
972                    }
973                }
974            }
975        }
976        return array;
977
978    Value::Null
979}
980
981    fn filter_by_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
982        let mut since = get_arg(optional_args, 0, Value::Null);
983        let mut limit = get_arg(optional_args, 1, Value::Null);
984        let mut key = get_arg(optional_args, 2, Value::Str("timestamp".into()));
985        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
986        if (array == Value::Null) {
987            return Value::from(vec![]);
988        }
989        let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
990        let mut parsedArray: Value = self.to_array(array);
991        let mut result: Value = parsedArray.clone();
992        if is_true(&sinceIsDefined) {
993            result = Value::from(vec![]);
994            {
995                                let mut i: Value = Value::Int(0);
996                let mut __for_first_76: bool = true;
997                while { if !__for_first_76 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_76 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&parsedArray).as_f64().unwrap_or(f64::NAN) } {
998                let mut entry: Value = get_value(&parsedArray, &i);
999                let mut entry: Value = get_value(&parsedArray, &i);
1000                let mut value: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1001                if (value != Value::Null) && (value != Value::Null) && (!is_equal(&value, &Value::Int(0))) && (is_greater_than_or_equal(&value, &since)) {
1002                    append_to_array(&mut result, entry);
1003                }
1004            }
1005            }
1006        }
1007        if is_true(&tail) && (limit != Value::Null) {
1008            return self.array_slice(result.clone(), negate(&limit), &[]);
1009        }
1010        // if the user provided a 'since' argument
1011        // we want to limit the result starting from the 'since'
1012        let mut shouldFilterFromStart: Value = Value::Bool(!is_true(&tail) && is_true(&sinceIsDefined));
1013        return self.filter_by_limit(result, &[limit, key, shouldFilterFromStart]);
1014
1015    Value::Null
1016}
1017
1018    fn filter_by_value_since_limit(&self, mut array: Value, mut field: Value, optional_args: &[Value]) -> Value {
1019        let mut value = get_arg(optional_args, 0, Value::Null);
1020        let mut since = get_arg(optional_args, 1, Value::Null);
1021        let mut limit = get_arg(optional_args, 2, Value::Null);
1022        let mut key = get_arg(optional_args, 3, Value::Str("timestamp".into()));
1023        let mut tail = get_arg(optional_args, 4, Value::Bool(false));
1024        let mut valueIsDefined: Value = self.value_is_defined(value.clone());
1025        let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
1026        let mut parsedArray: Value = self.to_array(array);
1027        let mut result: Value = parsedArray.clone();
1028        // single-pass filter for both symbol and since
1029        if is_true(&valueIsDefined) || is_true(&sinceIsDefined) {
1030            result = Value::from(vec![]);
1031            {
1032                                let mut i: Value = Value::Int(0);
1033                let mut __for_first_77: bool = true;
1034                while { if !__for_first_77 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_77 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&parsedArray).as_f64().unwrap_or(f64::NAN) } {
1035                let mut entry: Value = get_value(&parsedArray, &i);
1036                let mut entry: Value = get_value(&parsedArray, &i);
1037                // safeValue (not entry[field]) so a missing field is a non-match, not a
1038                // KeyError in python/php — prediction structures key on outcome, not symbol
1039                let mut entryFiledEqualValue: Value = Value::Bool(is_equal(&self.safe_value(entry.clone(), field.clone(), &[]), &value));
1040                let mut firstCondition: Value = (if is_true(&valueIsDefined) { entryFiledEqualValue } else { Value::Bool(true) });
1041                let mut entryKeyValue: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1042                let mut entryKeyGESince: Value = Value::Bool((entryKeyValue != Value::Null) && (entryKeyValue != Value::Null) && (!is_equal(&entryKeyValue, &Value::Int(0))) && (since != Value::Null) && (is_greater_than_or_equal(&entryKeyValue, &since)));
1043                let mut secondCondition: Value = (if is_true(&sinceIsDefined) { entryKeyGESince } else { Value::Bool(true) });
1044                if is_true(&firstCondition) && is_true(&secondCondition) {
1045                    append_to_array(&mut result, entry);
1046                }
1047            }
1048            }
1049        }
1050        if is_true(&tail) && (limit != Value::Null) {
1051            return self.array_slice(result.clone(), negate(&limit), &[]);
1052        }
1053        return self.filter_by_limit(result, &[limit, key, sinceIsDefined]);
1054
1055    Value::Null
1056}
1057
1058/*
1059 * @method
1060 * @name Exchange#setSandboxMode
1061 * @description set the sandbox mode for the exchange
1062 * @param {boolean} enabled true to enable sandbox mode, false to disable it
1063 */
1064    fn set_sandbox_mode(&mut self, mut enabled: Value) {
1065        if is_true(&enabled) {
1066            if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("test"))) {
1067                if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1068                    { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".into()), __be_tmp); };
1069                    { let __be_tmp = crate::value::get_value_k(&self.urls, "test"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1070                }  else {
1071                    { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "api")); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".into()), __be_tmp); };
1072                    { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "test")); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1073                }
1074            }  else {
1075                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" does not have a sandbox URL".into()))));
1076            }
1077            // set flag
1078            self.isSandboxModeEnabled = Value::Bool(true);
1079        }  else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackup"))) {
1080            if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1081                { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackup"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1082            }  else {
1083                { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "apiBackup")); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1084            }
1085            let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackup".into()), &[]);
1086            self.urls = newUrls;
1087            // set flag
1088            self.isSandboxModeEnabled = Value::Bool(false);
1089        }
1090}
1091
1092/*
1093 * @method
1094 * @name Exchange#enableDemoTrading
1095 * @description enables or disables demo trading mode
1096 * @param {boolean} [enable] true if demo trading should be enabled, false otherwise
1097 */
1098    fn enable_demo_trading(&mut self, mut enable: Value) {
1099        if is_true(&self.isSandboxModeEnabled) {
1100            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" demo trading does not support in sandbox environment. Please check https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd to see the differences".into()))));
1101        }
1102        if is_true(&enable) {
1103            { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); add_element_to_object(&mut self.urls, &Value::Str("apiBackupDemoTrading".into()), __be_tmp); };
1104            { let __be_tmp = crate::value::get_value_k(&self.urls, "demo"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1105        }  else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackupDemoTrading"))) {
1106            { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackupDemoTrading"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1107            let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".into()), &[]);
1108            self.urls = newUrls;
1109        }
1110        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("enableDemoTrading".into(), enable); }
1111}
1112
1113    fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
1114        // virtual-dispatch (static: DerivedExchange::sign(self, ...))
1115        { let __v = crate::exchange::DerivedExchange::sign(self, path, crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null), crate::runtime::get_arg(optional_args, 2, crate::Value::Null), crate::runtime::get_arg(optional_args, 3, crate::Value::Null), crate::runtime::get_arg(optional_args, 4, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1116
1117        let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
1118        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
1119        let mut params = get_arg(optional_args, 2, Value::Map({
1120    let mut m = indexmap::IndexMap::new();
1121    m
1122}));
1123        let mut headers = get_arg(optional_args, 3, Value::Null);
1124        let mut body = get_arg(optional_args, 4, Value::Null);
1125        return Value::Map({
1126    let mut m = indexmap::IndexMap::new();
1127        m.insert("url".to_string(), Value::Null);
1128        m.insert("method".to_string(), Value::Null);
1129        m.insert("headers".to_string(), Value::Null);
1130        m.insert("body".to_string(), Value::Null);
1131    m
1132});
1133
1134    Value::Null
1135}
1136
1137    fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1138        let mut params = get_arg(optional_args, 0, Value::Map({
1139    let mut m = indexmap::IndexMap::new();
1140    m
1141}));
1142        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAccounts() is not supported yet".into()))));
1143
1144    Value::Null
1145} }
1146
1147    fn watch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1148        let mut since = get_arg(optional_args, 0, Value::Null);
1149        let mut limit = get_arg(optional_args, 1, Value::Null);
1150        let mut params = get_arg(optional_args, 2, Value::Map({
1151    let mut m = indexmap::IndexMap::new();
1152    m
1153}));
1154        if (self.has.as_map().and_then(|__m| __m.get("watchLiquidationsForSymbols")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("watchLiquidationsForSymbols")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
1155            return self.watch_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1156        }
1157        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidations() is not supported yet".into()))));
1158
1159    Value::Null
1160} }
1161
1162    fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1163        let mut since = get_arg(optional_args, 0, Value::Null);
1164        let mut limit = get_arg(optional_args, 1, Value::Null);
1165        let mut params = get_arg(optional_args, 2, Value::Map({
1166    let mut m = indexmap::IndexMap::new();
1167    m
1168}));
1169        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidationsForSymbols() is not supported yet".into()))));
1170
1171    Value::Null
1172} }
1173
1174    fn watch_my_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1175        let mut since = get_arg(optional_args, 0, Value::Null);
1176        let mut limit = get_arg(optional_args, 1, Value::Null);
1177        let mut params = get_arg(optional_args, 2, Value::Map({
1178    let mut m = indexmap::IndexMap::new();
1179    m
1180}));
1181        if (self.has.as_map().and_then(|__m| __m.get("watchMyLiquidationsForSymbols")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("watchMyLiquidationsForSymbols")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
1182            return self.watch_my_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1183        }
1184        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidations() is not supported yet".into()))));
1185
1186    Value::Null
1187} }
1188
1189    fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1190        let mut since = get_arg(optional_args, 0, Value::Null);
1191        let mut limit = get_arg(optional_args, 1, Value::Null);
1192        let mut params = get_arg(optional_args, 2, Value::Map({
1193    let mut m = indexmap::IndexMap::new();
1194    m
1195}));
1196        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".into()))));
1197
1198    Value::Null
1199} }
1200
1201    fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1202        let mut symbol = get_arg(optional_args, 0, Value::Null);
1203        let mut params = get_arg(optional_args, 1, Value::Map({
1204    let mut m = indexmap::IndexMap::new();
1205    m
1206}));
1207        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrders() is not supported yet".into()))));
1208
1209    Value::Null
1210} }
1211
1212    fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1213        let mut params = get_arg(optional_args, 0, Value::Map({
1214    let mut m = indexmap::IndexMap::new();
1215    m
1216}));
1217        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTrades() is not supported yet".into()))));
1218
1219    Value::Null
1220} }
1221
1222    fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1223        let mut params = get_arg(optional_args, 0, Value::Map({
1224    let mut m = indexmap::IndexMap::new();
1225    m
1226}));
1227        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTradesForSymbols() is not supported yet".into()))));
1228
1229    Value::Null
1230} }
1231
1232    fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1233        let mut since = get_arg(optional_args, 0, Value::Null);
1234        let mut limit = get_arg(optional_args, 1, Value::Null);
1235        let mut params = get_arg(optional_args, 2, Value::Map({
1236    let mut m = indexmap::IndexMap::new();
1237    m
1238}));
1239        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCVForSymbols() is not supported yet".into()))));
1240
1241    Value::Null
1242} }
1243
1244    fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1245        let mut params = get_arg(optional_args, 0, Value::Map({
1246    let mut m = indexmap::IndexMap::new();
1247    m
1248}));
1249        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCVForSymbols() is not supported yet".into()))));
1250
1251    Value::Null
1252} }
1253
1254    fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1255        let mut params = get_arg(optional_args, 0, Value::Map({
1256    let mut m = indexmap::IndexMap::new();
1257    m
1258}));
1259        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBookForSymbols() is not supported yet".into()))));
1260
1261    Value::Null
1262} }
1263
1264    fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1265        let mut symbols = get_arg(optional_args, 0, Value::Null);
1266        let mut params = get_arg(optional_args, 1, Value::Map({
1267    let mut m = indexmap::IndexMap::new();
1268    m
1269}));
1270        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchPositions() is not supported yet".into()))));
1271
1272    Value::Null
1273} }
1274
1275    fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1276        let mut params = get_arg(optional_args, 0, Value::Map({
1277    let mut m = indexmap::IndexMap::new();
1278    m
1279}));
1280        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTicker() is not supported yet".into()))));
1281
1282    Value::Null
1283} }
1284
1285    fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1286        let mut params = get_arg(optional_args, 0, Value::Map({
1287    let mut m = indexmap::IndexMap::new();
1288    m
1289}));
1290        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrice() is not supported yet".into()))));
1291
1292    Value::Null
1293} }
1294
1295    fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1296        let mut symbols = get_arg(optional_args, 0, Value::Null);
1297        let mut params = get_arg(optional_args, 1, Value::Map({
1298    let mut m = indexmap::IndexMap::new();
1299    m
1300}));
1301        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrices() is not supported yet".into()))));
1302
1303    Value::Null
1304} }
1305
1306    fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1307        // async-virtual: try the derived exchange first
1308        if let Some(__v) = self.dispatch_to_derived("fetch_deposit_addresses", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1309            if !matches!(__v, crate::Value::Null) { return __v; }
1310        }
1311
1312        let mut codes = get_arg(optional_args, 0, Value::Null);
1313        let mut params = get_arg(optional_args, 1, Value::Map({
1314    let mut m = indexmap::IndexMap::new();
1315    m
1316}));
1317        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddresses() is not supported yet".into()))));
1318
1319    Value::Null
1320} }
1321
1322    fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1323        // async-virtual: try the derived exchange first
1324        if let Some(__v) = self.dispatch_to_derived("fetch_margin_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
1325            if !matches!(__v, crate::Value::Null) { return __v; }
1326        }
1327
1328        let mut params = get_arg(optional_args, 0, Value::Map({
1329    let mut m = indexmap::IndexMap::new();
1330    m
1331}));
1332        if (self.has.as_map().and_then(|__m| __m.get("fetchMarginModes")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchMarginModes")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
1333            let mut marginModes: Value = self.fetch_margin_modes(&[Value::from(vec![symbol.clone()]), params]).await;
1334            return self.safe_dict(marginModes, symbol, &[]);
1335        }  else {
1336            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginMode() is not supported yet".into()))));
1337        }
1338
1339    Value::Null
1340} }
1341
1342    fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1343        // async-virtual: try the derived exchange first
1344        if let Some(__v) = self.dispatch_to_derived("fetch_margin_modes", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1345            if !matches!(__v, crate::Value::Null) { return __v; }
1346        }
1347
1348        let mut symbols = get_arg(optional_args, 0, Value::Null);
1349        let mut params = get_arg(optional_args, 1, Value::Map({
1350    let mut m = indexmap::IndexMap::new();
1351    m
1352}));
1353        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginModes () is not supported yet".into()))));
1354
1355    Value::Null
1356} }
1357
1358    fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1359        let mut params = get_arg(optional_args, 0, Value::Map({
1360    let mut m = indexmap::IndexMap::new();
1361    m
1362}));
1363        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBook() is not supported yet".into()))));
1364
1365    Value::Null
1366} }
1367
1368    fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1369        // async-virtual: try the derived exchange first
1370        if let Some(__v) = self.dispatch_to_derived("fetch_time", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1371            if !matches!(__v, crate::Value::Null) { return __v; }
1372        }
1373
1374        let mut params = get_arg(optional_args, 0, Value::Map({
1375    let mut m = indexmap::IndexMap::new();
1376    m
1377}));
1378        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTime() is not supported yet".into()))));
1379
1380    Value::Null
1381} }
1382
1383    fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1384        let mut symbols = get_arg(optional_args, 0, Value::Null);
1385        let mut params = get_arg(optional_args, 1, Value::Map({
1386    let mut m = indexmap::IndexMap::new();
1387    m
1388}));
1389        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingLimits() is not supported yet".into()))));
1390
1391    Value::Null
1392} }
1393
1394    fn parse_currency(&self, mut rawCurrency: Value) -> Value {
1395        // virtual-dispatch (static: DerivedExchange::parse_currency(self, ...))
1396        { let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency); if !matches!(__v, crate::Value::Null) { return __v; } }
1397
1398        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseCurrency() is not supported yet".into()))));
1399
1400    Value::Null
1401}
1402
1403    fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
1404        let mut result: Value = Value::Map({
1405            let mut m = indexmap::IndexMap::new();
1406            m
1407        });
1408        let mut arr: Value = self.to_array(rawCurrencies);
1409        {
1410                        let mut i: Value = Value::Int(0);
1411            let mut __for_first_78: bool = true;
1412            while { if !__for_first_78 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_78 = false; i.as_f64().unwrap_or(f64::NAN) < ((arr.len() as i64) as f64) } {
1413            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, arr.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
1414            if (parsed == Value::Null) {
1415                continue;
1416            }
1417            let mut code: Value = parsed.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
1418            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), parsed); }
1419        }
1420        }
1421        return result;
1422
1423    Value::Null
1424}
1425
1426    fn parse_market(&self, mut market: Value) -> Value {
1427        // virtual-dispatch (static: DerivedExchange::parse_market(self, ...))
1428        { let __v = crate::exchange::DerivedExchange::parse_market(self, market); if !matches!(__v, crate::Value::Null) { return __v; } }
1429
1430        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarket() is not supported yet".into()))));
1431
1432    Value::Null
1433}
1434
1435    fn parse_markets(&self, mut markets: Value) -> Value {
1436        let mut result: Value = Value::from(vec![]);
1437        {
1438                        let mut i: Value = Value::Int(0);
1439            let mut __for_first_79: bool = true;
1440            while { if !__for_first_79 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_79 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
1441            append_to_array(&mut result, <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i)));
1442        }
1443        }
1444        return result;
1445
1446    Value::Null
1447}
1448
1449    fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
1450        // virtual-dispatch (static: DerivedExchange::parse_ticker(self, ...))
1451        { let __v = crate::exchange::DerivedExchange::parse_ticker(self, ticker, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1452
1453        let mut market = get_arg(optional_args, 0, Value::Null);
1454        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTicker() is not supported yet".into()))));
1455
1456    Value::Null
1457}
1458
1459    fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
1460        // virtual-dispatch (static: DerivedExchange::parse_deposit_address(self, ...))
1461        { let __v = crate::exchange::DerivedExchange::parse_deposit_address(self, depositAddress, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1462
1463        let mut currency = get_arg(optional_args, 0, Value::Null);
1464        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositAddress() is not supported yet".into()))));
1465
1466    Value::Null
1467}
1468
1469    fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1470        // virtual-dispatch (static: DerivedExchange::parse_trade(self, ...))
1471        { let __v = crate::exchange::DerivedExchange::parse_trade(self, trade, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1472
1473        let mut market = get_arg(optional_args, 0, Value::Null);
1474        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTrade() is not supported yet".into()))));
1475
1476    Value::Null
1477}
1478
1479    fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
1480        // virtual-dispatch (static: DerivedExchange::parse_transaction(self, ...))
1481        { let __v = crate::exchange::DerivedExchange::parse_transaction(self, transaction, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1482
1483        let mut currency = get_arg(optional_args, 0, Value::Null);
1484        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransaction() is not supported yet".into()))));
1485
1486    Value::Null
1487}
1488
1489    fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
1490        // virtual-dispatch (static: DerivedExchange::parse_transfer(self, ...))
1491        { let __v = crate::exchange::DerivedExchange::parse_transfer(self, transfer.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1492
1493        let mut currency = get_arg(optional_args, 0, Value::Null);
1494        if (transfer == Value::Null) {
1495            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1496        }
1497        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1498
1499    Value::Null
1500}
1501
1502    fn parse_account(&self, mut account: Value) -> Value {
1503        // virtual-dispatch (static: DerivedExchange::parse_account(self, ...))
1504        { let __v = crate::exchange::DerivedExchange::parse_account(self, account); if !matches!(__v, crate::Value::Null) { return __v; } }
1505
1506        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseAccount() is not supported yet".into()))));
1507
1508    Value::Null
1509}
1510
1511    fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
1512        // virtual-dispatch (static: DerivedExchange::parse_ledger_entry(self, ...))
1513        { let __v = crate::exchange::DerivedExchange::parse_ledger_entry(self, item, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1514
1515        let mut currency = get_arg(optional_args, 0, Value::Null);
1516        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLedgerEntry() is not supported yet".into()))));
1517
1518    Value::Null
1519}
1520
1521    fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1522        // virtual-dispatch (static: DerivedExchange::parse_order(self, ...))
1523        { let __v = crate::exchange::DerivedExchange::parse_order(self, order, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1524
1525        let mut market = get_arg(optional_args, 0, Value::Null);
1526        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOrder() is not supported yet".into()))));
1527
1528    Value::Null
1529}
1530
1531    fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1532        let mut params = get_arg(optional_args, 0, Value::Map({
1533    let mut m = indexmap::IndexMap::new();
1534    m
1535}));
1536        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRates() is not supported yet".into()))));
1537
1538    Value::Null
1539} }
1540
1541    fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1542        let mut params = get_arg(optional_args, 0, Value::Map({
1543    let mut m = indexmap::IndexMap::new();
1544    m
1545}));
1546        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRates() is not supported yet".into()))));
1547
1548    Value::Null
1549} }
1550
1551    fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
1552        // virtual-dispatch (static: DerivedExchange::parse_market_leverage_tiers(self, ...))
1553        { let __v = crate::exchange::DerivedExchange::parse_market_leverage_tiers(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1554
1555        let mut market = get_arg(optional_args, 0, Value::Null);
1556        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarketLeverageTiers() is not supported yet".into()))));
1557
1558    Value::Null
1559}
1560
1561    fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1562        // async-virtual: try the derived exchange first
1563        if let Some(__v) = self.dispatch_to_derived("fetch_leverage_tiers", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1564            if !matches!(__v, crate::Value::Null) { return __v; }
1565        }
1566
1567        let mut symbols = get_arg(optional_args, 0, Value::Null);
1568        let mut params = get_arg(optional_args, 1, Value::Map({
1569    let mut m = indexmap::IndexMap::new();
1570    m
1571}));
1572        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverageTiers() is not supported yet".into()))));
1573
1574    Value::Null
1575} }
1576
1577    fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
1578        // virtual-dispatch (static: DerivedExchange::parse_position(self, ...))
1579        { let __v = crate::exchange::DerivedExchange::parse_position(self, position, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1580
1581        let mut market = get_arg(optional_args, 0, Value::Null);
1582        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parsePosition() is not supported yet".into()))));
1583
1584    Value::Null
1585}
1586
1587    fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
1588        // virtual-dispatch (static: DerivedExchange::parse_funding_rate_history(self, ...))
1589        { let __v = crate::exchange::DerivedExchange::parse_funding_rate_history(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1590
1591        let mut market = get_arg(optional_args, 0, Value::Null);
1592        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRateHistory() is not supported yet".into()))));
1593
1594    Value::Null
1595}
1596
1597    fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
1598        // virtual-dispatch (static: DerivedExchange::parse_borrow_interest(self, ...))
1599        { let __v = crate::exchange::DerivedExchange::parse_borrow_interest(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1600
1601        let mut market = get_arg(optional_args, 0, Value::Null);
1602        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowInterest() is not supported yet".into()))));
1603
1604    Value::Null
1605}
1606
1607    fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
1608        let mut market = get_arg(optional_args, 0, Value::Null);
1609        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIsolatedBorrowRate() is not supported yet".into()))));
1610
1611    Value::Null
1612}
1613
1614    fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1615        let mut market = get_arg(optional_args, 0, Value::Null);
1616        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsTrade() is not supported yet".into()))));
1617
1618    Value::Null
1619}
1620
1621    fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1622        let mut market = get_arg(optional_args, 0, Value::Null);
1623        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrder() is not supported yet".into()))));
1624
1625    Value::Null
1626}
1627
1628    fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1629        let mut market = get_arg(optional_args, 0, Value::Null);
1630        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrderTrade() is not supported yet".into()))));
1631
1632    Value::Null
1633}
1634
1635    fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
1636        let mut market = get_arg(optional_args, 0, Value::Null);
1637        return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv, &[market]);
1638
1639    Value::Null
1640}
1641
1642    fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1643        // async-virtual: try the derived exchange first
1644        if let Some(__v) = self.dispatch_to_derived("fetch_funding_rates", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1645            if !matches!(__v, crate::Value::Null) { return __v; }
1646        }
1647
1648        let mut symbols = get_arg(optional_args, 0, Value::Null);
1649        let mut params = get_arg(optional_args, 1, Value::Map({
1650    let mut m = indexmap::IndexMap::new();
1651    m
1652}));
1653        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRates() is not supported yet".into()))));
1654
1655    Value::Null
1656} }
1657
1658    fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1659        // async-virtual: try the derived exchange first
1660        if let Some(__v) = self.dispatch_to_derived("fetch_funding_intervals", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1661            if !matches!(__v, crate::Value::Null) { return __v; }
1662        }
1663
1664        let mut symbols = get_arg(optional_args, 0, Value::Null);
1665        let mut params = get_arg(optional_args, 1, Value::Map({
1666    let mut m = indexmap::IndexMap::new();
1667    m
1668}));
1669        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingIntervals() is not supported yet".into()))));
1670
1671    Value::Null
1672} }
1673
1674    fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1675        let mut params = get_arg(optional_args, 0, Value::Map({
1676    let mut m = indexmap::IndexMap::new();
1677    m
1678}));
1679        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRate() is not supported yet".into()))));
1680
1681    Value::Null
1682} }
1683
1684    fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1685        let mut symbols = get_arg(optional_args, 0, Value::Null);
1686        let mut params = get_arg(optional_args, 1, Value::Map({
1687    let mut m = indexmap::IndexMap::new();
1688    m
1689}));
1690        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRates() is not supported yet".into()))));
1691
1692    Value::Null
1693} }
1694
1695    fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1696        let mut symbols = get_arg(optional_args, 0, Value::Null);
1697        let mut params = get_arg(optional_args, 1, Value::Map({
1698    let mut m = indexmap::IndexMap::new();
1699    m
1700}));
1701        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRates() is not supported yet".into()))));
1702
1703    Value::Null
1704} }
1705
1706    fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1707        let mut params = get_arg(optional_args, 0, Value::Map({
1708    let mut m = indexmap::IndexMap::new();
1709    m
1710}));
1711        return self.watch_funding_rates(&[symbols, params]).await;
1712
1713    Value::Null
1714} }
1715
1716    fn transfer(&mut self, mut code: Value, mut amount: Value, mut fromAccount: Value, mut toAccount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1717        // async-virtual: try the derived exchange first
1718        if let Some(__v) = self.dispatch_to_derived("transfer", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.push(amount); __args.push(fromAccount); __args.push(toAccount); __args.extend_from_slice(optional_args); __args }).await {
1719            if !matches!(__v, crate::Value::Null) { return __v; }
1720        }
1721
1722        let mut params = get_arg(optional_args, 0, Value::Map({
1723    let mut m = indexmap::IndexMap::new();
1724    m
1725}));
1726        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" transfer() is not supported yet".into()))));
1727
1728    Value::Null
1729} }
1730
1731    fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1732        // async-virtual: try the derived exchange first
1733        if let Some(__v) = self.dispatch_to_derived("withdraw", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.push(amount); __args.push(address); __args.extend_from_slice(optional_args); __args }).await {
1734            if !matches!(__v, crate::Value::Null) { return __v; }
1735        }
1736
1737        let mut tag = get_arg(optional_args, 0, Value::Null);
1738        let mut params = get_arg(optional_args, 1, Value::Map({
1739    let mut m = indexmap::IndexMap::new();
1740    m
1741}));
1742        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdraw() is not supported yet".into()))));
1743
1744    Value::Null
1745} }
1746
1747    fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1748        let mut params = get_arg(optional_args, 0, Value::Map({
1749    let mut m = indexmap::IndexMap::new();
1750    m
1751}));
1752        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createDepositAddress() is not supported yet".into()))));
1753
1754    Value::Null
1755} }
1756
1757    fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1758        // async-virtual: try the derived exchange first
1759        if let Some(__v) = self.dispatch_to_derived("set_leverage", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(leverage); __args.extend_from_slice(optional_args); __args }).await {
1760            if !matches!(__v, crate::Value::Null) { return __v; }
1761        }
1762
1763        let mut symbol = get_arg(optional_args, 0, Value::Null);
1764        let mut params = get_arg(optional_args, 1, Value::Map({
1765    let mut m = indexmap::IndexMap::new();
1766    m
1767}));
1768        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() is not supported yet".into()))));
1769
1770    Value::Null
1771} }
1772
1773    fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1774        // async-virtual: try the derived exchange first
1775        if let Some(__v) = self.dispatch_to_derived("fetch_leverage", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
1776            if !matches!(__v, crate::Value::Null) { return __v; }
1777        }
1778
1779        let mut params = get_arg(optional_args, 0, Value::Map({
1780    let mut m = indexmap::IndexMap::new();
1781    m
1782}));
1783        if (self.has.as_map().and_then(|__m| __m.get("fetchLeverages")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchLeverages")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
1784            let mut leverages: Value = self.fetch_leverages(&[Value::from(vec![symbol.clone()]), params]).await;
1785            return self.safe_dict(leverages, symbol, &[]);
1786        }  else {
1787            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverage() is not supported yet".into()))));
1788        }
1789
1790    Value::Null
1791} }
1792
1793    fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1794        // async-virtual: try the derived exchange first
1795        if let Some(__v) = self.dispatch_to_derived("fetch_leverages", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1796            if !matches!(__v, crate::Value::Null) { return __v; }
1797        }
1798
1799        let mut symbols = get_arg(optional_args, 0, Value::Null);
1800        let mut params = get_arg(optional_args, 1, Value::Map({
1801    let mut m = indexmap::IndexMap::new();
1802    m
1803}));
1804        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverages() is not supported yet".into()))));
1805
1806    Value::Null
1807} }
1808
1809    fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1810        // async-virtual: try the derived exchange first
1811        if let Some(__v) = self.dispatch_to_derived("set_position_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(hedged); __args.extend_from_slice(optional_args); __args }).await {
1812            if !matches!(__v, crate::Value::Null) { return __v; }
1813        }
1814
1815        let mut symbol = get_arg(optional_args, 0, Value::Null);
1816        let mut params = get_arg(optional_args, 1, Value::Map({
1817    let mut m = indexmap::IndexMap::new();
1818    m
1819}));
1820        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setPositionMode() is not supported yet".into()))));
1821
1822    Value::Null
1823} }
1824
1825    fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1826        // async-virtual: try the derived exchange first
1827        if let Some(__v) = self.dispatch_to_derived("add_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
1828            if !matches!(__v, crate::Value::Null) { return __v; }
1829        }
1830
1831        let mut params = get_arg(optional_args, 0, Value::Map({
1832    let mut m = indexmap::IndexMap::new();
1833    m
1834}));
1835        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" addMargin() is not supported yet".into()))));
1836
1837    Value::Null
1838} }
1839
1840    fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1841        // async-virtual: try the derived exchange first
1842        if let Some(__v) = self.dispatch_to_derived("reduce_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
1843            if !matches!(__v, crate::Value::Null) { return __v; }
1844        }
1845
1846        let mut params = get_arg(optional_args, 0, Value::Map({
1847    let mut m = indexmap::IndexMap::new();
1848    m
1849}));
1850        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" reduceMargin() is not supported yet".into()))));
1851
1852    Value::Null
1853} }
1854
1855    fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1856        let mut params = get_arg(optional_args, 0, Value::Map({
1857    let mut m = indexmap::IndexMap::new();
1858    m
1859}));
1860        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMargin() is not supported yet".into()))));
1861
1862    Value::Null
1863} }
1864
1865    fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1866        let mut timeframe = get_arg(optional_args, 0, Value::Null);
1867        let mut params = get_arg(optional_args, 1, Value::Map({
1868    let mut m = indexmap::IndexMap::new();
1869    m
1870}));
1871        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatio() is not supported yet".into()))));
1872
1873    Value::Null
1874} }
1875
1876    fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1877        let mut symbol = get_arg(optional_args, 0, Value::Null);
1878        let mut timeframe = get_arg(optional_args, 1, Value::Null);
1879        let mut since = get_arg(optional_args, 2, Value::Null);
1880        let mut limit = get_arg(optional_args, 3, Value::Null);
1881        let mut params = get_arg(optional_args, 4, Value::Map({
1882    let mut m = indexmap::IndexMap::new();
1883    m
1884}));
1885        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatioHistory() is not supported yet".into()))));
1886
1887    Value::Null
1888} }
1889
1890    fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1891        let mut symbol = get_arg(optional_args, 0, Value::Null);
1892        let mut type_var = get_arg(optional_args, 1, Value::Null);
1893        let mut since = get_arg(optional_args, 2, Value::Null);
1894        let mut limit = get_arg(optional_args, 3, Value::Null);
1895        let mut params = get_arg(optional_args, 4, Value::Map({
1896    let mut m = indexmap::IndexMap::new();
1897    m
1898}));
1899        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".into()))));
1900
1901    Value::Null
1902} }
1903
1904    fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1905        // async-virtual: try the derived exchange first
1906        if let Some(__v) = self.dispatch_to_derived("set_margin_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(marginMode); __args.extend_from_slice(optional_args); __args }).await {
1907            if !matches!(__v, crate::Value::Null) { return __v; }
1908        }
1909
1910        let mut symbol = get_arg(optional_args, 0, Value::Null);
1911        let mut params = get_arg(optional_args, 1, Value::Map({
1912    let mut m = indexmap::IndexMap::new();
1913    m
1914}));
1915        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMarginMode() is not supported yet".into()))));
1916
1917    Value::Null
1918} }
1919
1920    fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1921        // async-virtual: try the derived exchange first
1922        if let Some(__v) = self.dispatch_to_derived("fetch_deposit_addresses_by_network", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.extend_from_slice(optional_args); __args }).await {
1923            if !matches!(__v, crate::Value::Null) { return __v; }
1924        }
1925
1926        let mut params = get_arg(optional_args, 0, Value::Map({
1927    let mut m = indexmap::IndexMap::new();
1928    m
1929}));
1930        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".into()))));
1931
1932    Value::Null
1933} }
1934
1935    fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1936        let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".into()));
1937        let mut since = get_arg(optional_args, 1, Value::Null);
1938        let mut limit = get_arg(optional_args, 2, Value::Null);
1939        let mut params = get_arg(optional_args, 3, Value::Map({
1940    let mut m = indexmap::IndexMap::new();
1941    m
1942}));
1943        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterestHistory() is not supported yet".into()))));
1944
1945    Value::Null
1946} }
1947
1948    fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1949        // async-virtual: try the derived exchange first
1950        if let Some(__v) = self.dispatch_to_derived("fetch_open_interests", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1951            if !matches!(__v, crate::Value::Null) { return __v; }
1952        }
1953
1954        let mut symbols = get_arg(optional_args, 0, Value::Null);
1955        let mut params = get_arg(optional_args, 1, Value::Map({
1956    let mut m = indexmap::IndexMap::new();
1957    m
1958}));
1959        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterests() is not supported yet".into()))));
1960
1961    Value::Null
1962} }
1963
1964    fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1965        // async-virtual: try the derived exchange first
1966        if let Some(__v) = self.dispatch_to_derived("sign_in", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
1967            if !matches!(__v, crate::Value::Null) { return __v; }
1968        }
1969
1970        let mut params = get_arg(optional_args, 0, Value::Map({
1971    let mut m = indexmap::IndexMap::new();
1972    m
1973}));
1974        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" signIn() is not supported yet".into()))));
1975
1976    Value::Null
1977} }
1978
1979    fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1980        let mut params = get_arg(optional_args, 0, Value::Map({
1981    let mut m = indexmap::IndexMap::new();
1982    m
1983}));
1984        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPaymentMethods() is not supported yet".into()))));
1985
1986    Value::Null
1987} }
1988
1989    fn parse_to_int(&self, mut number: Value) -> Value {
1990        // Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
1991        // using a number as parameter which is not valid in ts
1992        // numberToString is typed as nullable under strictNullChecks; cast to string
1993        // the cast is erased at transpile-time, so output matches every target language, rather than
1994        // branching to a bare `NaN` literal, which has no symbol in Go/Java/C#
1995        let mut stringifiedNumber: Value = self.number_to_string(number);
1996        let mut convertedNumber: Value = (match &stringifiedNumber { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null });
1997        return crate::runtime::parse_int(&convertedNumber);
1998
1999    Value::Null
2000}
2001
2002    fn parse_to_numeric(&self, mut number: Value) -> Value {
2003        let mut stringVersion: Value = self.number_to_string(number); // this will convert 1.0 and 1 to "1" and 1.1 to "1.1"
2004        // keep this in mind:
2005        // in JS:     1 === 1.0 is true
2006        // in Python: 1 == 1.0 is true
2007        // in PHP:    1 == 1.0 is true, but 1 === 1.0 is false.
2008        if Value::Int(stringVersion.as_str().and_then(|__s| __s.find(".")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
2009            return (match &stringVersion { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null });
2010        }
2011        return (match &stringVersion { Value::Str(__parse_s) => __parse_s.trim().parse::<i64>().map(Value::Int).unwrap_or(Value::Null), Value::Int(__parse_n) => Value::Int(*__parse_n), Value::Float(__parse_f) => Value::Int(*__parse_f as i64), _ => Value::Null });
2012
2013    Value::Null
2014}
2015
2016    fn is_round_number(&self, mut value: Value) -> Value {
2017        // this method is similar to isInteger, but this is more loyal and does not check for types.
2018        // i.e. isRoundNumber(1.000) returns true, while isInteger(1.000) returns false
2019        let mut res: Value = self.parse_to_numeric((mod_val(&value, &Value::Int(1))));
2020        return Value::Bool(res.as_f64() == Some(0.0));
2021
2022    Value::Null
2023}
2024
2025    fn is_empty_string(&self, mut value: Value) -> Value {
2026        return Value::Bool(!(self.value_is_defined(value.clone()).as_bool() == Some(true)) || (value.as_str() == Some("")));
2027
2028    Value::Null
2029}
2030
2031    fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2032        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2033        let mut value: Value = self.safe_string(obj, key, &[]);
2034        let mut final_val: Value = self.parse_number(self.omit_zero(value), &[]);
2035        return (if (final_val == Value::Null) { defaultValue } else { final_val });
2036
2037    Value::Null
2038}
2039
2040    fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2041        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2042        let mut timestamp: Value = self.safe_integer(obj, key, &[defaultValue]);
2043        if (timestamp == Value::Null) || (timestamp.as_f64() == Some(0.0)) {
2044            return Value::Null;
2045        }
2046        return timestamp;
2047
2048    Value::Null
2049}
2050
2051    fn after_construct(&mut self) {
2052        // networks
2053        self.create_networks_by_id_object();
2054        self.features_generator();
2055        // init predefined markets if any
2056        if (self.markets.clone() != Value::Null) {
2057            self.set_markets(self.markets.clone(), &[]);
2058        }
2059        // init the request rate limiter
2060        self.init_rest_rate_limiter();
2061        // sanbox mode
2062        let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".into()), Value::Str("testnet".into()), &[Value::Bool(false)]);
2063        if (isSandbox.as_bool() == Some(true)) {
2064            self.set_sandbox_mode(isSandbox);
2065        }
2066}
2067
2068    fn init_rest_rate_limiter(&mut self) {
2069        if (self.rateLimit.clone() == Value::Null) || ((self.id.clone() != Value::Null) && (self.rateLimit.as_f64() == Value::Int(-1).as_f64())) {
2070            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(".rateLimit property is not configured".into()))));
2071        }
2072        let mut refillRate: Value = self.MAX_VALUE.clone();
2073        if self.rateLimit.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2074            refillRate = (match ((Value::Int(1)).as_f64(), (self.rateLimit.clone()).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null });
2075        }
2076        let mut useLeaky: bool = (self.rollingWindowSize.as_f64() == Some(0.0)) || (self.rateLimiterAlgorithm.as_str() == Some("leakyBucket"));
2077        let mut algorithm: Value = (if useLeaky { Value::Str("leakyBucket".into()) } else { Value::Str("rollingWindow".into()) });
2078        let mut defaultBucket: Value = Value::Map({
2079            let mut m = indexmap::IndexMap::new();
2080                m.insert("delay".to_string(), Value::Float(0.001));
2081                m.insert("capacity".to_string(), Value::Int(1));
2082                m.insert("cost".to_string(), Value::Int(1));
2083                m.insert("refillRate".to_string(), refillRate);
2084                m.insert("algorithm".to_string(), algorithm);
2085                m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2086                m.insert("rateLimit".to_string(), self.rateLimit.clone());
2087            m
2088        });
2089        let mut existingBucket: Value = (if (self.tokenBucket.clone() == Value::Null) { Value::Map({
2090    let mut m = indexmap::IndexMap::new();
2091    m
2092}) } else { self.tokenBucket.clone() });
2093        { let __t = self.extend(defaultBucket, &[existingBucket]); self.tokenBucket = __t; }
2094        self.init_throttler();
2095}
2096
2097    fn features_generator(&mut self) {
2098        //
2099        // in the exchange-specific features can be something like this, where we support 'string' aliases too:
2100        //
2101        //     {
2102        //         'my' : {
2103        //             'createOrder' : {...},
2104        //         },
2105        //         'swap': {
2106        //             'linear': {
2107        //                 'extends': my',
2108        //             },
2109        //         },
2110        //     }
2111        //
2112        if (self.features.clone() == Value::Null) {
2113            return;
2114        }
2115        // reconstruct
2116        let mut initialFeatures: Value = self.features.clone();
2117        self.features = Value::Map({
2118            let mut m = indexmap::IndexMap::new();
2119            m
2120        });
2121        let mut unifiedMarketTypes: Value = Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into()), Value::Str("future".into()), Value::Str("option".into())]);
2122        let mut subTypes: Value = Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into())]);
2123        {
2124                        let mut i: Value = Value::Int(0);
2125            let mut __for_first_81: bool = true;
2126            while { if !__for_first_81 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_81 = false; i.as_f64().unwrap_or(f64::NAN) < ((unifiedMarketTypes.len() as i64) as f64) } {
2127            let mut marketType: Value = unifiedMarketTypes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2128            // if marketType is not filled for this exchange, don't add that in `features`
2129            if !(in_op(&initialFeatures, &marketType)) {
2130                if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Null); }
2131            }  else {
2132                if (marketType.as_str() == Some("spot")) {
2133                    { let __be_tmp = self.features_mapper(initialFeatures.clone(), marketType.clone(), &[]); if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), __be_tmp); } }
2134                }  else {
2135                    if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Map({
2136    let mut m = indexmap::IndexMap::new();
2137    m
2138})); }
2139                    {
2140                                                let mut j: Value = Value::Int(0);
2141                        let mut __for_first_80: bool = true;
2142                        while { if !__for_first_80 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_80 = false; j.as_f64().unwrap_or(f64::NAN) < ((subTypes.len() as i64) as f64) } {
2143                        let mut subType: Value = subTypes.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2144                        { let __be_tmp = self.features_mapper(initialFeatures.clone(), marketType.clone(), &[subType.clone()]); add_element_to_object(get_value_mut(&mut self.features, &marketType), &subType, __be_tmp); };
2145                    }
2146                    }
2147                }
2148            }
2149        }
2150        }
2151}
2152
2153    fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2154        let mut subType = get_arg(optional_args, 0, Value::Null);
2155        let mut featuresObj: Value = (if (subType != Value::Null) { get_value(&initialFeatures.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &subType) } else { initialFeatures.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null) });
2156        // if exchange does not have that market-type (eg. future>inverse)
2157        if (featuresObj == Value::Null) {
2158            return Value::Null;
2159        }
2160        let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
2161        if (extendsStr != Value::Null) {
2162            featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".into()), &[]);
2163            let mut extendObj: Value = self.features_mapper(initialFeatures, extendsStr, &[]);
2164            featuresObj = self.deep_extend(extendObj, &[featuresObj.clone()]);
2165        }
2166        //
2167        // ### corrections ###
2168        //
2169        // createOrder
2170        if (in_op(&featuresObj, &Value::Str("createOrder".into()))) {
2171            let mut value: Value = self.safe_dict_k(crate::value::get_value_k(&featuresObj, "createOrder"), "attachedStopLossTakeProfit", &[]);
2172            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("stopLoss".into()), value.clone());
2173            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("takeProfit".into()), value.clone());
2174            if (marketType.as_str() == Some("spot")) {
2175                // default 'hedged': false
2176                add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("hedged".into()), Value::Bool(false));
2177                // default 'leverage': false
2178                if !(in_op(&crate::value::get_value_k(&featuresObj, "createOrder"), &Value::Str("leverage".into()))) {
2179                    add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("leverage".into()), Value::Bool(false));
2180                }
2181            }
2182            // default 'GTC' to true
2183            if (self.safe_bool(crate::value::get_value_k(&crate::value::get_value_k(&featuresObj, "createOrder"), "timeInForce"), Value::Str("GTC".into()), &[]) == Value::Null) {
2184                add_element_to_object(get_value_mut(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("timeInForce".into())), &Value::Str("GTC".into()), Value::Bool(true));
2185            }
2186        }
2187        // other methods
2188        let mut keys: Value = object_keys(&featuresObj);
2189        {
2190                        let mut i: Value = Value::Int(0);
2191            let mut __for_first_82: bool = true;
2192            while { if !__for_first_82 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_82 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
2193            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2194            let mut featureBlock: Value = get_value(&featuresObj, &key);
2195            let mut featureBlock: Value = get_value(&featuresObj, &key);
2196            if !(self.in_array(key.clone(), Value::from(vec![Value::Str("sandbox".into())])).as_bool() == Some(true)) && (featureBlock != Value::Null) {
2197                // default "symbolRequired" to false to all methods (except `createOrder`)
2198                if !(in_op(&featureBlock, &Value::Str("symbolRequired".into()))) {
2199                    add_element_to_object(&mut featureBlock, &Value::Str("symbolRequired".into()), self.in_array(key, Value::from(vec![Value::Str("createOrder".into()), Value::Str("createOrders".into()), Value::Str("fetchOHLCV".into())])));
2200                }
2201            }
2202        }
2203        }
2204        return featuresObj;
2205
2206    Value::Null
2207}
2208
2209    fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
2210        let mut methodName = get_arg(optional_args, 0, Value::Null);
2211        let mut paramName = get_arg(optional_args, 1, Value::Null);
2212        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2213        /*
2214         * @method
2215         * @name exchange#featureValue
2216         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2217         * @param {string} [symbol] unified symbol
2218         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2219         * @param {string} [paramName] unified param value, like: `triggerPrice`, `stopLoss.triggerPrice` (check docs for supported param names)
2220         * @param {object} [defaultValue] return default value if no result found
2221         * @returns {object} returns feature value
2222         */
2223        let mut market: Value = self.market(symbol.clone());
2224        return self.feature_value_by_type(market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), market.as_map().and_then(|__m| __m.get("subType")).cloned().unwrap_or(Value::Null), &[methodName, paramName, defaultValue]);
2225
2226    Value::Null
2227}
2228
2229    fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2230        let mut methodName = get_arg(optional_args, 0, Value::Null);
2231        let mut paramName = get_arg(optional_args, 1, Value::Null);
2232        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2233        /*
2234         * @method
2235         * @name exchange#featureValueByType
2236         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2237         * @param {string} [marketType] supported only: "spot", "swap", "future"
2238         * @param {string} [subType] supported only: "linear", "inverse"
2239         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2240         * @param {string} [paramName] unified param value (check docs for supported param names)
2241         * @param {object} [defaultValue] return default value if no result found
2242         * @returns {object} returns feature value
2243         */
2244        // if exchange does not yet have features manually implemented
2245        if (self.features.clone() == Value::Null) {
2246            return defaultValue;
2247        }
2248        if (marketType == Value::Null) {
2249            return defaultValue;
2250        }
2251        // if marketType (e.g. 'option') does not exist in features
2252        if !(in_op(&self.features, &marketType)) {
2253            return defaultValue;
2254        }
2255        // if marketType dict undefined
2256        if (get_value(&self.features, &marketType) == Value::Null) {
2257            return defaultValue;
2258        }
2259        let mut methodsContainer: Value = get_value(&self.features, &marketType);
2260        if (subType == Value::Null) {
2261            if (marketType.as_str() != Some("spot")) {
2262                return defaultValue;
2263            }
2264        }  else {
2265            if !(in_op(&get_value(&self.features, &marketType), &subType)) {
2266                return defaultValue;
2267            }
2268            // if subType dict undefined
2269            if (get_value(&get_value(&self.features, &marketType), &subType) == Value::Null) {
2270                return defaultValue;
2271            }
2272            methodsContainer = get_value(&get_value(&self.features, &marketType), &subType);
2273        }
2274        // if user wanted only marketType and didn't provide methodName, eg: featureIsSupported('spot')
2275        if (methodName == Value::Null) {
2276            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodsContainer.clone() });
2277        }
2278        if !(in_op(&methodsContainer, &methodName)) {
2279            return defaultValue;
2280        }
2281        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2282        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2283        if (methodDict == Value::Null) {
2284            return defaultValue;
2285        }
2286        // if user wanted only method and didn't provide `paramName`, eg: featureIsSupported('swap', 'linear', 'createOrder')
2287        if (paramName == Value::Null) {
2288            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodDict.clone() });
2289        }
2290        let mut splited: Value = split(&paramName, &Value::Str(".".into())); // can be only parent key (`stopLoss`) or with child (`stopLoss.triggerPrice`)
2291        let mut parentKey: Value = splited.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
2292        let mut subKey: Value = self.safe_string(splited, Value::Int(1), &[]);
2293        if !(in_op(&methodDict, &parentKey)) {
2294            return defaultValue;
2295        }
2296        let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2297        if (dictionary == Value::Null) {
2298            return get_value(&methodDict, &parentKey);
2299        }  else {
2300            // return as is, when calling without subKey eg: featureValueByType('spot', undefined, 'createOrder', 'stopLoss')
2301            if (subKey == Value::Null) {
2302                return get_value(&methodDict, &parentKey);
2303            }
2304            // throw an exception for unsupported subKey
2305            if !(in_op(&get_value(&methodDict, &parentKey), &subKey)) {
2306                return defaultValue;
2307            }
2308            return get_value(&get_value(&methodDict, &parentKey), &subKey);
2309        }
2310
2311    Value::Null
2312}
2313
2314    fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2315        return Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(" : ".into())).into()), Value::Str("orderbook data checksum validation failed. You can reconnect by calling watchOrderBook again or you can mute the error by setting exchange.options[\"watchOrderBook\"][\"checksum\"] = false".into())).into());
2316
2317    Value::Null
2318}
2319
2320    fn create_networks_by_id_object(&mut self) {
2321        // automatically generate network-id-to-code mappings
2322        let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2323            let mut m = indexmap::IndexMap::new();
2324            m
2325        })])); // invert defined networks dictionary
2326        { let __be_tmp = self.extend(networkIdsToCodesGenerated, &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2327    let mut m = indexmap::IndexMap::new();
2328    m
2329})])]); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("networksById".into(), __be_tmp); } }; // support manually overriden "networksById" dictionary too
2330}
2331
2332    fn get_default_options(&self) -> Value {
2333        return Value::Map({
2334    let mut m = indexmap::IndexMap::new();
2335        m.insert("defaultNetworkCodeReplacements".to_string(), Value::Map({
2336    let mut m = indexmap::IndexMap::new();
2337        m.insert("ETH".to_string(), Value::Map({
2338    let mut m = indexmap::IndexMap::new();
2339        m.insert("primary".to_string(), Value::Str("ETH".into()));
2340        m.insert("secondary".to_string(), Value::Str("ERC20".into()));
2341        m.insert("default".to_string(), Value::Str("secondary".into()));
2342    m
2343}));
2344        m.insert("CRO".to_string(), Value::Map({
2345    let mut m = indexmap::IndexMap::new();
2346        m.insert("primary".to_string(), Value::Str("CRONOS".into()));
2347        m.insert("secondary".to_string(), Value::Str("CRC20".into()));
2348        m.insert("default".to_string(), Value::Str("secondary".into()));
2349    m
2350}));
2351        m.insert("TRX".to_string(), Value::Map({
2352    let mut m = indexmap::IndexMap::new();
2353        m.insert("primary".to_string(), Value::Str("TRX".into()));
2354        m.insert("secondary".to_string(), Value::Str("TRC20".into()));
2355        m.insert("default".to_string(), Value::Str("secondary".into()));
2356    m
2357}));
2358        m.insert("BTC".to_string(), Value::Map({
2359    let mut m = indexmap::IndexMap::new();
2360        m.insert("primary".to_string(), Value::Str("BTC".into()));
2361        m.insert("secondary".to_string(), Value::Str("BRC20".into()));
2362        m.insert("default".to_string(), Value::Str("primary".into()));
2363    m
2364}));
2365    m
2366}));
2367        m.insert("backwardSupportedNetworkCodes".to_string(), Value::Map({
2368    let mut m = indexmap::IndexMap::new();
2369        m.insert("ARB".to_string(), Value::Str("ARBITRUM".into()));
2370        m.insert("ARBONE".to_string(), Value::Str("ARBITRUM".into()));
2371        m.insert("ARBNOVA".to_string(), Value::Str("ARBITRUM_NOVA".into()));
2372    m
2373}));
2374    m
2375});
2376
2377    Value::Null
2378}
2379
2380    fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2381        let mut currency = get_arg(optional_args, 0, Value::Null);
2382        currency = self.safe_currency(Value::Null, &[currency.clone()]);
2383        let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2384        let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2385        let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2386        let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
2387        if (amount != Value::Null) {
2388            if (before == Value::Null) && (after != Value::Null) {
2389                before = crate::precise::Precise::stringSub(&after, &amount);
2390            }  else if (before != Value::Null) && (after == Value::Null) {
2391                after = crate::precise::Precise::stringAdd(&before, &amount);
2392            }
2393        }
2394        if (before != Value::Null) && (after != Value::Null) {
2395            if (direction == Value::Null) {
2396                if is_true(&crate::precise::Precise::stringGt(&before, &after)) {
2397                    direction = Value::Str("out".into());
2398                }
2399                if is_true(&crate::precise::Precise::stringGt(&after, &before)) {
2400                    direction = Value::Str("in".into());
2401                }
2402            }
2403        }
2404        let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2405        if (fee != Value::Null) {
2406            { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); };
2407        }
2408        let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
2409        let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2410    let mut m = indexmap::IndexMap::new();
2411    m
2412})]);
2413        return Value::Map({
2414    let mut m = indexmap::IndexMap::new();
2415        m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2416        m.insert("timestamp".to_string(), timestamp.clone());
2417        m.insert("datetime".to_string(), self.iso8601(timestamp));
2418        m.insert("direction".to_string(), direction);
2419        m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2420        m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2421        m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2422        m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2423        m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null));
2424        m.insert("amount".to_string(), self.parse_number(amount, &[]));
2425        m.insert("before".to_string(), self.parse_number(before, &[]));
2426        m.insert("after".to_string(), self.parse_number(after, &[]));
2427        m.insert("status".to_string(), self.safe_string_k(entry, "status", &[]));
2428        m.insert("fee".to_string(), fee);
2429        m.insert("info".to_string(), info);
2430    m
2431});
2432
2433    Value::Null
2434}
2435
2436    fn safe_currency_structure(&self, mut currency: Value) -> Value {
2437        // derive data from networks: deposit, withdraw, active, fee, limits, precision
2438        let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2439    let mut m = indexmap::IndexMap::new();
2440    m
2441})]);
2442        let mut keys: Value = object_keys(&networks);
2443        let mut length: f64 = ((keys.len() as i64) as f64);
2444        if (length != 0.0) {
2445            {
2446                                let mut i: Value = Value::Int(0);
2447                let mut __for_first_83: bool = true;
2448                while { if !__for_first_83 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_83 = false; i.as_f64().unwrap_or(f64::NAN) < length } {
2449                let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2450                let mut network: Value = networks.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2451                let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
2452                let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
2453                if (currencyDeposit == Value::Null) || (deposit.as_bool() == Some(true)) {
2454                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("deposit".into(), deposit); }
2455                }
2456                let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
2457                let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
2458                if (currencyWithdraw == Value::Null) || (withdraw.as_bool() == Some(true)) {
2459                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("withdraw".into(), withdraw); }
2460                }
2461                // find lowest fee (which is more desired)
2462                let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
2463                let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
2464                if (feeMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&fee, &feeMain)) {
2465                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("fee".into(), self.parse_number(fee.clone(), &[])); }
2466                }
2467                // find lowest precision (which is more desired)
2468                let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
2469                let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
2470                if (precisionMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&precision, &precisionMain)) {
2471                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("precision".into(), self.parse_number(precision.clone(), &[])); }
2472                }
2473                // limits
2474                let mut limits: Value = self.safe_dict_k(network, "limits", &[]);
2475                let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
2476                if (limitsMain == Value::Null) {
2477                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("limits".into(), Value::Map({
2478    let mut m = indexmap::IndexMap::new();
2479    m
2480})); }
2481                }
2482                // deposits
2483                let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2484                let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
2485                if (limitsDepositMain == Value::Null) {
2486                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into()), Value::Map({
2487    let mut m = indexmap::IndexMap::new();
2488    m
2489}));
2490                }
2491                let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
2492                let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit, "max", &[]);
2493                let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
2494                let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain, "max", &[]);
2495                // find min
2496                if (limitsDepositMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain)) {
2497                    add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into())), &Value::Str("min".into()), self.parse_number(limitsDepositMin, &[]));
2498                }
2499                // find max
2500                if (limitsDepositMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain)) {
2501                    add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into())), &Value::Str("max".into()), self.parse_number(limitsDepositMax, &[]));
2502                }
2503                // withdrawals
2504                let mut limitsWithdraw: Value = self.safe_dict_k(limits, "withdraw", &[]);
2505                let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain, "withdraw", &[]);
2506                if (limitsWithdrawMain == Value::Null) {
2507                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into()), Value::Map({
2508    let mut m = indexmap::IndexMap::new();
2509    m
2510}));
2511                }
2512                let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
2513                let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw, "max", &[]);
2514                let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
2515                let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain, "max", &[]);
2516                // find min
2517                if (limitsWithdrawMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain)) {
2518                    add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into())), &Value::Str("min".into()), self.parse_number(limitsWithdrawMin, &[]));
2519                }
2520                // find max
2521                if (limitsWithdrawMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain)) {
2522                    add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into())), &Value::Str("max".into()), self.parse_number(limitsWithdrawMax, &[]));
2523                }
2524            }
2525            }
2526        }
2527        return self.extend(Value::Map({
2528    let mut m = indexmap::IndexMap::new();
2529        m.insert("info".to_string(), Value::Null);
2530        m.insert("id".to_string(), Value::Null);
2531        m.insert("numericId".to_string(), Value::Null);
2532        m.insert("code".to_string(), Value::Null);
2533        m.insert("precision".to_string(), Value::Null);
2534        m.insert("type".to_string(), Value::Null);
2535        m.insert("name".to_string(), Value::Null);
2536        m.insert("active".to_string(), Value::Null);
2537        m.insert("deposit".to_string(), Value::Null);
2538        m.insert("withdraw".to_string(), Value::Null);
2539        m.insert("fee".to_string(), Value::Null);
2540        m.insert("fees".to_string(), Value::Map({
2541    let mut m = indexmap::IndexMap::new();
2542    m
2543}));
2544        m.insert("networks".to_string(), Value::Map({
2545    let mut m = indexmap::IndexMap::new();
2546    m
2547}));
2548        m.insert("limits".to_string(), Value::Map({
2549    let mut m = indexmap::IndexMap::new();
2550        m.insert("deposit".to_string(), Value::Map({
2551    let mut m = indexmap::IndexMap::new();
2552        m.insert("min".to_string(), Value::Null);
2553        m.insert("max".to_string(), Value::Null);
2554    m
2555}));
2556        m.insert("withdraw".to_string(), Value::Map({
2557    let mut m = indexmap::IndexMap::new();
2558        m.insert("min".to_string(), Value::Null);
2559        m.insert("max".to_string(), Value::Null);
2560    m
2561}));
2562    m
2563}));
2564    m
2565}), &[currency]);
2566
2567    Value::Null
2568}
2569
2570    fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2571        let mut market = get_arg(optional_args, 0, Value::Null);
2572        let mut cleanStructure: Value = Value::Map({
2573            let mut m = indexmap::IndexMap::new();
2574                m.insert("id".to_string(), Value::Null);
2575                m.insert("lowercaseId".to_string(), Value::Null);
2576                m.insert("symbol".to_string(), Value::Null);
2577                m.insert("base".to_string(), Value::Null);
2578                m.insert("quote".to_string(), Value::Null);
2579                m.insert("settle".to_string(), Value::Null);
2580                m.insert("baseId".to_string(), Value::Null);
2581                m.insert("quoteId".to_string(), Value::Null);
2582                m.insert("settleId".to_string(), Value::Null);
2583                m.insert("type".to_string(), Value::Null);
2584                m.insert("spot".to_string(), Value::Null);
2585                m.insert("margin".to_string(), Value::Null);
2586                m.insert("swap".to_string(), Value::Null);
2587                m.insert("future".to_string(), Value::Null);
2588                m.insert("option".to_string(), Value::Null);
2589                m.insert("index".to_string(), Value::Null);
2590                m.insert("active".to_string(), Value::Null);
2591                m.insert("contract".to_string(), Value::Null);
2592                m.insert("linear".to_string(), Value::Null);
2593                m.insert("inverse".to_string(), Value::Null);
2594                m.insert("subType".to_string(), Value::Null);
2595                m.insert("taker".to_string(), Value::Null);
2596                m.insert("maker".to_string(), Value::Null);
2597                m.insert("contractSize".to_string(), Value::Null);
2598                m.insert("expiry".to_string(), Value::Null);
2599                m.insert("expiryDatetime".to_string(), Value::Null);
2600                m.insert("strike".to_string(), Value::Null);
2601                m.insert("optionType".to_string(), Value::Null);
2602                m.insert("precision".to_string(), Value::Map({
2603    let mut m = indexmap::IndexMap::new();
2604        m.insert("amount".to_string(), Value::Null);
2605        m.insert("price".to_string(), Value::Null);
2606        m.insert("cost".to_string(), Value::Null);
2607        m.insert("base".to_string(), Value::Null);
2608        m.insert("quote".to_string(), Value::Null);
2609    m
2610}));
2611                m.insert("limits".to_string(), Value::Map({
2612    let mut m = indexmap::IndexMap::new();
2613        m.insert("leverage".to_string(), Value::Map({
2614    let mut m = indexmap::IndexMap::new();
2615        m.insert("min".to_string(), Value::Null);
2616        m.insert("max".to_string(), Value::Null);
2617    m
2618}));
2619        m.insert("amount".to_string(), Value::Map({
2620    let mut m = indexmap::IndexMap::new();
2621        m.insert("min".to_string(), Value::Null);
2622        m.insert("max".to_string(), Value::Null);
2623    m
2624}));
2625        m.insert("price".to_string(), Value::Map({
2626    let mut m = indexmap::IndexMap::new();
2627        m.insert("min".to_string(), Value::Null);
2628        m.insert("max".to_string(), Value::Null);
2629    m
2630}));
2631        m.insert("cost".to_string(), Value::Map({
2632    let mut m = indexmap::IndexMap::new();
2633        m.insert("min".to_string(), Value::Null);
2634        m.insert("max".to_string(), Value::Null);
2635    m
2636}));
2637    m
2638}));
2639                m.insert("marginModes".to_string(), Value::Map({
2640    let mut m = indexmap::IndexMap::new();
2641        m.insert("cross".to_string(), Value::Null);
2642        m.insert("isolated".to_string(), Value::Null);
2643    m
2644}));
2645                m.insert("created".to_string(), Value::Null);
2646                m.insert("info".to_string(), Value::Null);
2647            m
2648        });
2649        if (market != Value::Null) {
2650            let mut result: Value = self.extend(cleanStructure.clone(), &[market]);
2651            // set undefined swap/future/etc
2652            if is_equal(&result.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2653                if (result.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null) == Value::Null) {
2654                    add_element_to_object(&mut result, &Value::Str("contract".into()), Value::Bool(false));
2655                }
2656                if (result.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null) == Value::Null) {
2657                    add_element_to_object(&mut result, &Value::Str("swap".into()), Value::Bool(false));
2658                }
2659                if (result.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null) == Value::Null) {
2660                    add_element_to_object(&mut result, &Value::Str("future".into()), Value::Bool(false));
2661                }
2662                if (result.as_map().and_then(|__m| __m.get("option")).cloned().unwrap_or(Value::Null) == Value::Null) {
2663                    add_element_to_object(&mut result, &Value::Str("option".into()), Value::Bool(false));
2664                }
2665                if (result.as_map().and_then(|__m| __m.get("index")).cloned().unwrap_or(Value::Null) == Value::Null) {
2666                    add_element_to_object(&mut result, &Value::Str("index".into()), Value::Bool(false));
2667                }
2668            }
2669            return result;
2670        }
2671        return self.extend(cleanStructure, &[]);
2672
2673    Value::Null
2674}
2675
2676    fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2677        let mut currencies = get_arg(optional_args, 0, Value::Null);
2678        let mut values: Value = Value::from(vec![]);
2679        { let __t = self.create_safe_dictionary(&[]); self.markets_by_id = __t; }
2680        // handle marketId conflicts
2681        // we insert spot markets first
2682        let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".into()), &[Value::Bool(true), Value::Bool(true)]);
2683        {
2684                        let mut i: Value = Value::Int(0);
2685            let mut __for_first_85: bool = true;
2686            while { if !__for_first_85 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_85 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketValues.len() as i64) as f64) } {
2687            let mut value: Value = marketValues.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2688            if (in_op(&self.markets_by_id, &crate::value::get_value_k(&value, "id"))) {
2689                let mut marketsByIdArray: Value = get_value(&self.markets_by_id, &crate::value::get_value_k(&value, "id"));
2690                append_to_array(&mut marketsByIdArray, value.clone());
2691                add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), marketsByIdArray);
2692            }  else {
2693                add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), Value::from(vec![value.clone()]));
2694            }
2695            // strip undefined-valued keys from the parsed market before deepExtend,
2696            // otherwise an explicit `taker: undefined` (from safeMarketStructure)
2697            // would clobber the fee defaults from this.fees['trading'] in the merge
2698            let mut valueDefined: Value = Value::Map({
2699                let mut m = indexmap::IndexMap::new();
2700                m
2701            });
2702            let mut valueKeys: Value = object_keys(&value);
2703            {
2704                                let mut j: Value = Value::Int(0);
2705                let mut __for_first_84: bool = true;
2706                while { if !__for_first_84 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_84 = false; j.as_f64().unwrap_or(f64::NAN) < ((valueKeys.len() as i64) as f64) } {
2707                let mut valueKey: Value = valueKeys.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2708                if (get_value(&value, &valueKey) != Value::Null) {
2709                    if let Value::Dict(__d) = &mut valueDefined { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&valueKey), get_value(&value, &valueKey)); }
2710                }
2711            }
2712            }
2713            let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2714                let mut m = indexmap::IndexMap::new();
2715                    m.insert("precision".to_string(), self.precision.clone());
2716                    m.insert("limits".to_string(), self.limits.clone());
2717                m
2718            }), self.fees.as_map().and_then(|__m| __m.get("trading")).cloned().unwrap_or(Value::Null), valueDefined]);
2719            if is_equal(&market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2720                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("linear".into()));
2721            }  else if is_equal(&market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2722                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("inverse".into()));
2723            }  else {
2724                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Null);
2725            }
2726            append_to_array(&mut values, market.clone());
2727        }
2728        }
2729        { let __t = self.map_to_safe_map(self.index_by(values.clone(), Value::Str("symbol".into()))); self.markets = __t; }
2730        let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
2731        let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
2732        self.symbols = object_keys(&marketsSortedBySymbol);
2733        self.ids = object_keys(&marketsSortedById);
2734        let mut numCurrencies: Value = Value::Int(0);
2735        if (currencies != Value::Null) {
2736            let mut keys: Value = object_keys(&currencies);
2737            numCurrencies = Value::Int(keys.len() as i64);
2738        }
2739        if numCurrencies.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2740            // currencies is always undefined when called in constructor but not when called from loadMarkets
2741            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2742        }  else {
2743            let mut baseCurrencies: Value = Value::from(vec![]);
2744            let mut quoteCurrencies: Value = Value::from(vec![]);
2745            {
2746                                let mut i: Value = Value::Int(0);
2747                let mut __for_first_86: bool = true;
2748                while { if !__for_first_86 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_86 = false; i.as_f64().unwrap_or(f64::NAN) < ((values.len() as i64) as f64) } {
2749                let mut market: Value = values.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2750                let mut defaultCurrencyPrecision: Value = (if (self.precisionMode.as_f64() == Value::Int(crate::runtime::DECIMAL_PLACES).as_f64()) { Value::Int(8) } else { self.parse_number(Value::Str("1e-8".into()), &[]) });
2751                let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2752    let mut m = indexmap::IndexMap::new();
2753    m
2754})]);
2755                if (matches!(&market, Value::Dict(__d) if __d.contains_key("base"))) {
2756                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2757                        let mut m = indexmap::IndexMap::new();
2758                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".into()), Value::Str("base".into()), &[]));
2759                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2760                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2761                            m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".into()), Value::Str("amount".into()), &[defaultCurrencyPrecision.clone()]));
2762                        m
2763                    }));
2764                    append_to_array(&mut baseCurrencies, currency.clone());
2765                }
2766                if (matches!(&market, Value::Dict(__d) if __d.contains_key("quote"))) {
2767                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2768                        let mut m = indexmap::IndexMap::new();
2769                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".into()), Value::Str("quote".into()), &[]));
2770                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2771                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2772                            m.insert("precision".to_string(), self.safe_value2(marketPrecision, Value::Str("quote".into()), Value::Str("price".into()), &[defaultCurrencyPrecision]));
2773                        m
2774                    }));
2775                    append_to_array(&mut quoteCurrencies, currency);
2776                }
2777            }
2778            }
2779            baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2780            quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2781            { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".into()))); self.baseCurrencies = __t; }
2782            { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".into()))); self.quoteCurrencies = __t; }
2783            let mut allCurrencies: Value = self.array_concat(baseCurrencies, quoteCurrencies);
2784            let mut groupedCurrencies: Value = self.group_by(allCurrencies, Value::Str("code".into()), &[]);
2785            let mut codes: Value = object_keys(&groupedCurrencies);
2786            let mut resultingCurrencies: Value = Value::from(vec![]);
2787            {
2788                                let mut i: Value = Value::Int(0);
2789                let mut __for_first_88: bool = true;
2790                while { if !__for_first_88 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_88 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2791                let mut code: Value = codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2792                let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code, &[Value::from(vec![])]);
2793                let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2794                {
2795                                        let mut j: Value = Value::Int(1);
2796                    let mut __for_first_87: bool = true;
2797                    while { if !__for_first_87 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_87 = false; j.as_f64().unwrap_or(f64::NAN) < ((groupedCurrenciesCode.len() as i64) as f64) } {
2798                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2799                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2800                    if (self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64()) {
2801                        highestPrecisionCurrency = (if (is_less_than(&crate::value::get_value_k(&currentCurrency, "precision"), &crate::value::get_value_k(&highestPrecisionCurrency, "precision"))) { currentCurrency.clone() } else { highestPrecisionCurrency.clone() });
2802                    }  else {
2803                        highestPrecisionCurrency = (if (is_greater_than(&crate::value::get_value_k(&currentCurrency, "precision"), &crate::value::get_value_k(&highestPrecisionCurrency, "precision"))) { currentCurrency.clone() } else { highestPrecisionCurrency.clone() });
2804                    }
2805                }
2806                }
2807                append_to_array(&mut resultingCurrencies, highestPrecisionCurrency);
2808            }
2809            }
2810            let mut sortedCurrencies: Value = self.sort_by(resultingCurrencies, Value::Str("code".into()), &[]);
2811            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(sortedCurrencies, Value::Str("code".into()))])); self.currencies = __t; }
2812        }
2813        { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".into())); self.currencies_by_id = __t; }
2814        let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
2815        self.codes = object_keys(&currenciesSortedByCode);
2816        if (self.markets.clone() == Value::Null) {
2817            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" setMarkets() markets not set".into()))));
2818        }
2819        return self.markets.clone();
2820
2821    Value::Null
2822}
2823
2824    fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2825        // Validate that both exchanges are of the same type
2826        if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".into()))) {
2827            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", add(&Value::Str(format!("{}{}", self.id.clone(), Value::Str(" shareMarkets() can only share markets with exchanges of the same type (got ".into())).into()), &crate::value::get_value_k(&sourceExchange, "id")), Value::Str(")".into()))));
2828        }
2829        // Validate that source exchange has loaded markets
2830        if (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) || (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) {
2831            panic!("{}", crate::exchange_errors::exchange_error("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function"));
2832        }
2833        // Set all market-related data
2834        self.markets = get_value(&sourceExchange, &Value::Str("markets".into()));
2835        self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".into()));
2836        self.symbols = get_value(&sourceExchange, &Value::Str("symbols".into()));
2837        self.ids = get_value(&sourceExchange, &Value::Str("ids".into()));
2838        self.currencies = get_value(&sourceExchange, &Value::Str("currencies".into()));
2839        self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".into()));
2840        self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".into()));
2841        self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".into()));
2842        self.codes = get_value(&sourceExchange, &Value::Str("codes".into()));
2843        // check marketHelperProps
2844        let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".into())), Value::Str("marketHelperProps".into()), &[Value::from(vec![])]);
2845        {
2846                        let mut i: Value = Value::Int(0);
2847            let mut __for_first_89: bool = true;
2848            while { if !__for_first_89 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_89 = false; i.as_f64().unwrap_or(f64::NAN) < ((sourceExchangeHelpers.len() as i64) as f64) } {
2849            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2850            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2851            if (get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper) != Value::Null) {
2852                if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&helper), get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper)); }
2853            }
2854        }
2855        }
2856        return Value::Null;
2857
2858    Value::Null
2859}
2860
2861    fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2862        let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2863        let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe, &[wsBaseDescribe]);
2864        return superWithRestDescribe;
2865
2866    Value::Null
2867}
2868
2869    fn safe_balance(&self, mut balance: Value) -> Value {
2870        let mut balances: Value = self.omit(balance.clone(), Value::from(vec![Value::Str("info".into()), Value::Str("timestamp".into()), Value::Str("datetime".into()), Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into())]), &[]);
2871        let mut codes: Value = object_keys(&balances);
2872        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("free".into(), Value::Map({
2873    let mut m = indexmap::IndexMap::new();
2874    m
2875})); }
2876        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("used".into(), Value::Map({
2877    let mut m = indexmap::IndexMap::new();
2878    m
2879})); }
2880        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("total".into(), Value::Map({
2881    let mut m = indexmap::IndexMap::new();
2882    m
2883})); }
2884        let mut debtBalance: Value = Value::Map({
2885            let mut m = indexmap::IndexMap::new();
2886            m
2887        });
2888        {
2889                        let mut i: Value = Value::Int(0);
2890            let mut __for_first_90: bool = true;
2891            while { if !__for_first_90 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_90 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2892            let mut code: Value = codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2893            let mut total: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("total".into()), &[]);
2894            let mut free: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("free".into()), &[]);
2895            let mut used: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("used".into()), &[]);
2896            let mut debt: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("debt".into()), &[]);
2897            if (total == Value::Null) && (free != Value::Null) && (used != Value::Null) {
2898                total = crate::precise::Precise::stringAdd(&free, &used);
2899            }
2900            if (free == Value::Null) && (total != Value::Null) && (used != Value::Null) {
2901                free = crate::precise::Precise::stringSub(&total, &used);
2902            }
2903            if (used == Value::Null) && (total != Value::Null) && (free != Value::Null) {
2904                used = crate::precise::Precise::stringSub(&total, &free);
2905            }
2906            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".into()), self.parse_number(free, &[]));
2907            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".into()), self.parse_number(used, &[]));
2908            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".into()), self.parse_number(total, &[]));
2909            { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "free"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("free".into())), &code, __be_tmp); };
2910            { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "used"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("used".into())), &code, __be_tmp); };
2911            { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "total"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("total".into())), &code, __be_tmp); };
2912            if (debt != Value::Null) {
2913                add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".into()), self.parse_number(debt, &[]));
2914                if let Value::Dict(__d) = &mut debtBalance { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), crate::value::get_value_k(&balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), "debt")); }
2915            }
2916        }
2917        }
2918        let mut debtBalanceArray: Value = object_keys(&debtBalance);
2919        let mut length: Value = Value::Int(debtBalanceArray.len() as i64);
2920        if (length != Value::Null) && (length.as_f64() != Some(0.0)) {
2921            if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("debt".into(), debtBalance); }
2922        }
2923        return balance;
2924
2925    Value::Null
2926}
2927
2928    fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2929        let mut market = get_arg(optional_args, 0, Value::Null);
2930        // parses numbers as strings
2931        // * it is important pass the trades as unparsed rawTrades
2932        if (order == Value::Null) {
2933            order = Value::Map({
2934                let mut m = indexmap::IndexMap::new();
2935                m
2936            });
2937        }
2938        let mut amount: Value = self.omit_zero(self.safe_string_k(order.clone(), "amount", &[]));
2939        let mut remaining: Value = self.safe_string_k(order.clone(), "remaining", &[]);
2940        let mut filled: Value = self.safe_string_k(order.clone(), "filled", &[]);
2941        let mut cost: Value = self.safe_string_k(order.clone(), "cost", &[]);
2942        let mut average: Value = self.omit_zero(self.safe_string_k(order.clone(), "average", &[]));
2943        let mut price: Value = self.omit_zero(self.safe_string_k(order.clone(), "price", &[]));
2944        let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(order.clone(), "lastTradeTimestamp", &[]);
2945        let mut symbol: Value = self.safe_string_k(order.clone(), "symbol", &[]);
2946        let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
2947        let mut status: Value = self.safe_string_k(order.clone(), "status", &[]);
2948        let mut parseFilled: bool = filled == Value::Null;
2949        let mut parseCost: bool = cost == Value::Null;
2950        let mut parseLastTradeTimeTimestamp: bool = lastTradeTimeTimestamp == Value::Null;
2951        let mut fee: Value = self.safe_value_k(order.clone(), "fee", &[]);
2952        let mut parseFee: bool = fee == Value::Null;
2953        let mut parseFees: bool = self.safe_value_k(order.clone(), "fees", &[]) == Value::Null;
2954        let mut parseSymbol: bool = symbol == Value::Null;
2955        let mut parseSide: bool = side == Value::Null;
2956        let mut shouldParseFees: bool = parseFee || parseFees;
2957        let mut fees: Value = self.safe_list_k(order.clone(), "fees", &[Value::from(vec![])]);
2958        let mut trades: Value = Value::from(vec![]);
2959        let mut isTriggerOrSLTpOrder: bool = ((self.safe_string_k(order.clone(), "triggerPrice", &[]) != Value::Null) || (self.safe_string_k(order.clone(), "stopLossPrice", &[]) != Value::Null)) || (self.safe_string_k(order.clone(), "takeProfitPrice", &[]) != Value::Null);
2960        if parseFilled || parseCost || shouldParseFees {
2961            let mut rawTrades: Value = self.safe_value_k(order.clone(), "trades", &[trades.clone()]);
2962            // const oldNumber = this.number;
2963            // we parse trades as strings here!
2964            // i don't think this is needed anymore
2965            // (this as any).number = String;
2966            let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
2967            // parse trades if they haven't already been parsed
2968            let mut tradesAreParsed: bool = (firstTrade != Value::Null) && (in_op(&firstTrade, &Value::Str("info".into()))) && (in_op(&firstTrade, &Value::Str("id".into())));
2969            if !tradesAreParsed {
2970                trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
2971            }  else {
2972                trades = rawTrades;
2973            }
2974            // this.number = oldNumber; why parse trades as strings if you read the value using `safeString` ?
2975            let mut tradesLength: Value = Value::Int(0);
2976            let mut isArray: bool = matches!(&trades, Value::Arr(_));
2977            if isArray {
2978                tradesLength = Value::Int(trades.len() as i64);
2979            }
2980            if isArray && (tradesLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) {
2981                // move properties that are defined in trades up into the order
2982                if (order.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) == Value::Null) {
2983                    add_element_to_object(&mut order, &Value::Str("symbol".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "symbol"));
2984                }
2985                if (order.as_map().and_then(|__m| __m.get("side")).cloned().unwrap_or(Value::Null) == Value::Null) {
2986                    if let Value::Dict(__d) = &mut order { std::sync::Arc::make_mut(__d).insert("side".into(), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "side")); }
2987                }
2988                if (order.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null) == Value::Null) {
2989                    if let Value::Dict(__d) = &mut order { std::sync::Arc::make_mut(__d).insert("type".into(), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "type")); }
2990                }
2991                if (order.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null) == Value::Null) {
2992                    { let __be_tmp = crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "order"); if let Value::Dict(__d) = &mut order { std::sync::Arc::make_mut(__d).insert("id".into(), __be_tmp); } }
2993                }
2994                if parseFilled {
2995                    filled = Value::Str("0".into());
2996                }
2997                if parseCost {
2998                    cost = Value::Str("0".into());
2999                }
3000                {
3001                                        let mut i: Value = Value::Int(0);
3002                    let mut __for_first_92: bool = true;
3003                    while { if !__for_first_92 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_92 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3004                    let mut trade: Value = trades.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3005                    let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3006                    if parseFilled && (tradeAmount != Value::Null) {
3007                        filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
3008                    }
3009                    let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3010                    if parseCost && (tradeCost != Value::Null) {
3011                        cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
3012                    }
3013                    if parseSymbol {
3014                        symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
3015                    }
3016                    if parseSide {
3017                        side = self.safe_string_k(trade.clone(), "side", &[]);
3018                    }
3019                    let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
3020                    if parseLastTradeTimeTimestamp && (tradeTimestamp != Value::Null) {
3021                        if (lastTradeTimeTimestamp == Value::Null) {
3022                            lastTradeTimeTimestamp = tradeTimestamp.clone();
3023                        }  else {
3024                            lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
3025                        }
3026                    }
3027                    if shouldParseFees {
3028                        let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
3029                        if (tradeFees != Value::Null) {
3030                            {
3031                                                                let mut j: Value = Value::Int(0);
3032                                let mut __for_first_91: bool = true;
3033                                while { if !__for_first_91 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_91 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&tradeFees).as_f64().unwrap_or(f64::NAN) } {
3034                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3035                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3036                                append_to_array(&mut fees, self.extend(Value::Map({
3037                                    let mut m = indexmap::IndexMap::new();
3038                                    m
3039                                }), &[tradeFee.clone()]));
3040                            }
3041                            }
3042                        }  else {
3043                            let mut tradeFee: Value = self.safe_value_k(trade, "fee", &[]);
3044                            if (tradeFee != Value::Null) {
3045                                append_to_array(&mut fees, self.extend(Value::Map({
3046                                    let mut m = indexmap::IndexMap::new();
3047                                    m
3048                                }), &[tradeFee.clone()]));
3049                            }
3050                        }
3051                    }
3052                }
3053                }
3054            }
3055        }
3056        if shouldParseFees {
3057            let mut reducedFees: Value = fees.clone();
3058            if is_true(&self.reduceFees) {
3059                reducedFees = self.reduce_fees_by_currency(fees);
3060            }
3061            if (reducedFees == Value::Null) {
3062                reducedFees = Value::from(vec![]);
3063            }
3064            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3065            {
3066                                let mut i: Value = Value::Int(0);
3067                let mut __for_first_93: bool = true;
3068                while { if !__for_first_93 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_93 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3069                { let __be_tmp = self.safe_number_k(get_value(&reducedFees, &i), "cost", &[]); add_element_to_object(get_value_mut(&mut reducedFees, &i), &Value::Str("cost".into()), __be_tmp); };
3070                if (in_op(&reducedFees.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &Value::Str("rate".into()))) {
3071                    { let __be_tmp = self.safe_number_k(get_value(&reducedFees, &i), "rate", &[]); add_element_to_object(get_value_mut(&mut reducedFees, &i), &Value::Str("rate".into()), __be_tmp); };
3072                }
3073            }
3074            }
3075            if !parseFee && (reducedLength == 0.0) {
3076                // copy fee to avoid modification by reference
3077                let mut feeCopy: Value = self.deep_extend(fee, &[]);
3078                { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".into()), __be_tmp); };
3079                if (in_op(&feeCopy, &Value::Str("rate".into()))) {
3080                    { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".into()), __be_tmp); };
3081                }
3082                append_to_array(&mut reducedFees, feeCopy);
3083            }
3084            if let Value::Dict(__d) = &mut order { std::sync::Arc::make_mut(__d).insert("fees".into(), reducedFees.clone()); }
3085            if parseFee && (reducedLength == 1.0) {
3086                if let Value::Dict(__d) = &mut order { std::sync::Arc::make_mut(__d).insert("fee".into(), reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)); }
3087            }
3088        }
3089        if (amount == Value::Null) {
3090            // ensure amount = filled + remaining
3091            if (filled != Value::Null) && (remaining != Value::Null) {
3092                amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3093            }  else if (status.as_str() == Some("closed")) {
3094                amount = filled.clone();
3095            }
3096        }
3097        if (filled == Value::Null) {
3098            if (amount != Value::Null) && (remaining != Value::Null) {
3099                filled = crate::precise::Precise::stringSub(&amount, &remaining);
3100            }  else if (status.as_str() == Some("closed")) && (amount != Value::Null) {
3101                filled = amount.clone();
3102            }
3103        }
3104        if (remaining == Value::Null) {
3105            if (amount != Value::Null) && (filled != Value::Null) {
3106                remaining = crate::precise::Precise::stringSub(&amount, &filled);
3107            }  else if (status.as_str() == Some("closed")) {
3108                remaining = Value::Str("0".into());
3109            }
3110        }
3111        // ensure that the average field is calculated correctly
3112        let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3113        let mut contractSize: Value = self.number_to_string(self.safe_value_k(market, "contractSize", &[Value::Int(1)]));
3114        // inverse
3115        // price = filled * contract size / cost
3116        //
3117        // linear
3118        // price = cost / (filled * contract size)
3119        if (average == Value::Null) {
3120            if (filled != Value::Null) && (cost != Value::Null) && is_true(&crate::precise::Precise::stringGt(&filled, &Value::Str("0".into()))) {
3121                let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3122                if (inverse.as_bool() == Some(true)) {
3123                    average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3124                }  else {
3125                    average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3126                }
3127            }
3128        }
3129        // similarly
3130        // inverse
3131        // cost = filled * contract size / price
3132        //
3133        // linear
3134        // cost = filled * contract size * price
3135        let mut costPriceExists: bool = (average != Value::Null) || (price != Value::Null);
3136        if parseCost && (filled != Value::Null) && costPriceExists {
3137            let mut multiplyPrice: Value = Value::Null;
3138            if (average == Value::Null) {
3139                multiplyPrice = price.clone();
3140            }  else {
3141                multiplyPrice = average.clone();
3142            }
3143            // contract trading
3144            let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3145            if (inverse.as_bool() == Some(true)) {
3146                cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3147            }  else {
3148                cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3149            }
3150        }
3151        // support for market orders
3152        let mut orderType: Value = self.safe_value_k(order.clone(), "type", &[]);
3153        let mut emptyPrice: bool = (price == Value::Null) || is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".into())));
3154        if emptyPrice && (orderType.as_str() == Some("market")) {
3155            price = average.clone();
3156        }
3157        {
3158                        let mut i: Value = Value::Int(0);
3159            let mut __for_first_95: bool = true;
3160            while { if !__for_first_95 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_95 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3161            let mut entry: Value = get_value(&trades, &i);
3162            let mut entry: Value = get_value(&trades, &i);
3163            { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".into()), __be_tmp); };
3164            { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".into()), __be_tmp); };
3165            { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".into()), __be_tmp); };
3166            let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3167    let mut m = indexmap::IndexMap::new();
3168    m
3169})]);
3170            { let __be_tmp = self.safe_number_k(tradeFee.clone(), "cost", &[]); if let Value::Dict(__d) = &mut tradeFee { std::sync::Arc::make_mut(__d).insert("cost".into(), __be_tmp); } }
3171            if (matches!(&tradeFee, Value::Dict(__d) if __d.contains_key("rate"))) {
3172                { let __be_tmp = self.safe_number_k(tradeFee.clone(), "rate", &[]); if let Value::Dict(__d) = &mut tradeFee { std::sync::Arc::make_mut(__d).insert("rate".into(), __be_tmp); } }
3173            }
3174            let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::from(vec![])]);
3175            {
3176                                let mut j: Value = Value::Int(0);
3177                let mut __for_first_94: bool = true;
3178                while { if !__for_first_94 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_94 = false; j.as_f64().unwrap_or(f64::NAN) < ((entryFees.len() as i64) as f64) } {
3179                { let __be_tmp = self.safe_number_k(get_value(&entryFees, &j), "cost", &[]); add_element_to_object(get_value_mut(&mut entryFees, &j), &Value::Str("cost".into()), __be_tmp); };
3180            }
3181            }
3182            add_element_to_object(&mut entry, &Value::Str("fees".into()), entryFees);
3183            add_element_to_object(&mut entry, &Value::Str("fee".into()), tradeFee);
3184        }
3185        }
3186        let mut timeInForce: Value = self.safe_string_k(order.clone(), "timeInForce", &[]);
3187        let mut postOnly: Value = self.safe_value_k(order.clone(), "postOnly", &[]);
3188        // timeInForceHandling
3189        if (timeInForce == Value::Null) {
3190            if !isTriggerOrSLTpOrder && (self.safe_string_k(order.clone(), "type", &[]).as_str() == Some("market")) {
3191                timeInForce = Value::Str("IOC".into());
3192            }
3193            // allow postOnly override
3194            if is_equal(&postOnly, &Value::Bool(true)) {
3195                timeInForce = Value::Str("PO".into());
3196            }
3197        }  else if (postOnly == Value::Null) {
3198            // timeInForce is not undefined here
3199            postOnly = Value::Bool(timeInForce.as_str() == Some("PO"));
3200        }
3201        let mut timestamp: Value = self.safe_integer_k(order.clone(), "timestamp", &[]);
3202        let mut lastUpdateTimestamp: Value = self.safe_integer_k(order.clone(), "lastUpdateTimestamp", &[]);
3203        let mut datetime: Value = self.safe_string_k(order.clone(), "datetime", &[]);
3204        if (datetime == Value::Null) {
3205            datetime = self.iso8601(timestamp.clone());
3206        }
3207        let mut triggerPrice: Value = self.parse_number(self.safe_string2(order.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]), &[]);
3208        let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(order.clone(), "takeProfitPrice", &[]), &[]);
3209        let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(order.clone(), "stopLossPrice", &[]), &[]);
3210        return self.extend(order.clone(), &[Value::Map({
3211    let mut m = indexmap::IndexMap::new();
3212        m.insert("id".to_string(), self.safe_string_k(order.clone(), "id", &[]));
3213        m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "clientOrderId", &[]));
3214        m.insert("timestamp".to_string(), timestamp);
3215        m.insert("datetime".to_string(), datetime);
3216        m.insert("symbol".to_string(), symbol);
3217        m.insert("type".to_string(), self.safe_string_k(order.clone(), "type", &[]));
3218        m.insert("side".to_string(), side);
3219        m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp);
3220        m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp);
3221        m.insert("price".to_string(), self.parse_number(price, &[]));
3222        m.insert("amount".to_string(), self.parse_number(amount, &[]));
3223        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3224        m.insert("average".to_string(), self.parse_number(average, &[]));
3225        m.insert("filled".to_string(), self.parse_number(filled, &[]));
3226        m.insert("remaining".to_string(), self.parse_number(remaining, &[]));
3227        m.insert("timeInForce".to_string(), timeInForce);
3228        m.insert("postOnly".to_string(), postOnly);
3229        m.insert("trades".to_string(), trades);
3230        m.insert("reduceOnly".to_string(), self.safe_value_k(order.clone(), "reduceOnly", &[]));
3231        m.insert("stopPrice".to_string(), triggerPrice.clone());
3232        m.insert("triggerPrice".to_string(), triggerPrice);
3233        m.insert("takeProfitPrice".to_string(), takeProfitPrice);
3234        m.insert("stopLossPrice".to_string(), stopLossPrice);
3235        m.insert("status".to_string(), status);
3236        m.insert("fee".to_string(), self.safe_value_k(order, "fee", &[]));
3237    m
3238})]);
3239
3240    Value::Null
3241}
3242
3243    fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3244        let mut market = get_arg(optional_args, 0, Value::Null);
3245        let mut since = get_arg(optional_args, 1, Value::Null);
3246        let mut limit = get_arg(optional_args, 2, Value::Null);
3247        let mut params = get_arg(optional_args, 3, Value::Map({
3248    let mut m = indexmap::IndexMap::new();
3249    m
3250}));
3251        //
3252        // the value of orders is either a dict or a list
3253        //
3254        // dict
3255        //
3256        //     {
3257        //         'id1': { ... },
3258        //         'id2': { ... },
3259        //         'id3': { ... },
3260        //         ...
3261        //     }
3262        //
3263        // list
3264        //
3265        //     [
3266        //         { 'id': 'id1', ... },
3267        //         { 'id': 'id2', ... },
3268        //         { 'id': 'id3', ... },
3269        //         ...
3270        //     ]
3271        //
3272        if (orders == Value::Null) {
3273            return Value::from(vec![]);
3274        }
3275        let mut results: Value = Value::from(vec![]);
3276        if (matches!(&orders, Value::Arr(_))) {
3277            {
3278                                let mut i: Value = Value::Int(0);
3279                let mut __for_first_96: bool = true;
3280                while { if !__for_first_96 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_96 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
3281                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, get_value(&orders, &i), &[market.clone()]); // don't inline this call
3282                let mut order: Value = self.extend(parsed, &[params.clone()]);
3283                append_to_array(&mut results, order.clone());
3284            }
3285            }
3286        }  else {
3287            let mut ids: Value = object_keys(&orders);
3288            {
3289                                let mut i: Value = Value::Int(0);
3290                let mut __for_first_97: bool = true;
3291                while { if !__for_first_97 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_97 = false; i.as_f64().unwrap_or(f64::NAN) < ((ids.len() as i64) as f64) } {
3292                let mut id: Value = ids.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3293                let mut idExtended: Value = self.extend(Value::Map({
3294                    let mut m = indexmap::IndexMap::new();
3295                        m.insert("id".to_string(), id.clone());
3296                    m
3297                }), &[get_value(&orders, &id)]);
3298                let mut parsedOrder: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, idExtended, &[market.clone()]); // don't  inline these calls
3299                let mut order: Value = self.extend(parsedOrder, &[params.clone()]);
3300                append_to_array(&mut results, order);
3301            }
3302            }
3303        }
3304        results = self.sort_by(results.clone(), Value::Str("timestamp".into()), &[]);
3305        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
3306        return self.filter_by_symbol_since_limit(results, &[symbol, since, limit]);
3307
3308    Value::Null
3309}
3310
3311    fn calculate_fee_with_rate(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3312        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3313        let mut feeRate = get_arg(optional_args, 1, Value::Null);
3314        let mut params = get_arg(optional_args, 2, Value::Map({
3315    let mut m = indexmap::IndexMap::new();
3316    m
3317}));
3318        if (type_var.as_str() == Some("market")) && (takerOrMaker.as_str() == Some("maker")) {
3319            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" calculateFee() - you have provided incompatible arguments - \"market\" type order can not be \"maker\". Change either the \"type\" or the \"takerOrMaker\" argument to calculate the fee.".into()))));
3320        }
3321        let mut markets: Value = self.markets.clone();
3322        if (markets == Value::Null) {
3323            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
3324        }
3325        let mut market: Value = get_value(&markets, &symbol);
3326        let mut market: Value = get_value(&markets, &symbol);
3327        let mut feeSide: Option<String> = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".into())]).as_str().map(str::to_owned);
3328        let mut useQuote: Value = Value::Null;
3329        if (feeSide.as_deref() == Some("get")) {
3330            // the fee is always in the currency you get
3331            useQuote = Value::Bool(side.as_str() == Some("sell"));
3332        }  else if (feeSide.as_deref() == Some("give")) {
3333            // the fee is always in the currency you give
3334            useQuote = Value::Bool(side.as_str() == Some("buy"));
3335        }  else {
3336            // the fee is always in feeSide currency
3337            useQuote = Value::Bool(feeSide.as_deref() == Some("quote"));
3338        }
3339        let mut cost: Value = self.number_to_string(amount);
3340        let mut key: Value = Value::Null;
3341        if useQuote.as_bool() == Some(true) {
3342            let mut priceString: Value = self.number_to_string(price);
3343            cost = crate::precise::Precise::stringMul(&cost, &priceString);
3344            key = Value::Str("quote".into());
3345        }  else {
3346            key = Value::Str("base".into());
3347        }
3348        // for derivatives, the fee is in 'settle' currency
3349        if !is_equal(&crate::value::get_value_k(&market, "spot"), &Value::Bool(true)) {
3350            key = Value::Str("settle".into());
3351        }
3352        // even if `takerOrMaker` argument was set to 'maker', for 'market' orders we should forcefully override it to 'taker'
3353        if (type_var.as_str() == Some("market")) {
3354            takerOrMaker = Value::Str("taker".into());
3355        }
3356        let mut rate: Value = (if (feeRate != Value::Null) { self.number_to_string(feeRate) } else { self.safe_string(market.clone(), takerOrMaker.clone(), &[]) });
3357        cost = crate::precise::Precise::stringMul(&cost, &rate);
3358        return Value::Map({
3359    let mut m = indexmap::IndexMap::new();
3360        m.insert("type".to_string(), takerOrMaker);
3361        m.insert("currency".to_string(), get_value(&market, &key));
3362        m.insert("rate".to_string(), self.parse_number(rate, &[]));
3363        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3364    m
3365});
3366
3367    Value::Null
3368}
3369
3370    fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3371        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3372        let mut params = get_arg(optional_args, 1, Value::Map({
3373    let mut m = indexmap::IndexMap::new();
3374    m
3375}));
3376        return self.calculate_fee_with_rate(symbol, type_var, side, amount, price, &[takerOrMaker, Value::Null, params]);
3377
3378    Value::Null
3379}
3380
3381    fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3382        let mut market = get_arg(optional_args, 0, Value::Null);
3383        let __market_empty = indexmap::IndexMap::new();
3384        let market = market.as_map().unwrap_or(&__market_empty);
3385        let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
3386        let mut contractSize: Value = (match market.get("contractSize") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null });
3387        let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
3388        let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3389        let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3390        if (baseValue == Value::Null) && (contracts != Value::Null) && (contractSize != Value::Null) && (price != Value::Null) {
3391            baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
3392        }
3393        if (quoteValue == Value::Null) && (baseValue != Value::Null) && (price != Value::Null) {
3394            quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
3395        }
3396        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(contracts, &[])); }
3397        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(contractSize, &[])); }
3398        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3399        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("baseValue".into(), self.parse_number(baseValue, &[])); }
3400        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("quoteValue".into(), self.parse_number(quoteValue, &[])); }
3401        return liquidation;
3402
3403    Value::Null
3404}
3405
3406    fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3407        let mut market = get_arg(optional_args, 0, Value::Null);
3408        let __market_empty = indexmap::IndexMap::new();
3409        let market = market.as_map().unwrap_or(&__market_empty);
3410        let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3411        let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
3412        let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3413        if (cost == Value::Null) {
3414            // contract trading
3415            let mut contractSize: Value = (match market.get("contractSize") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null });
3416            let mut multiplyPrice: Value = price.clone();
3417            if (contractSize != Value::Null) {
3418                let mut inverse: Value = (match market.get("inverse") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) });
3419                if (inverse.as_bool() == Some(true)) {
3420                    multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &price);
3421                }
3422                multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3423            }
3424            cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
3425        }
3426        let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
3427        let mut resultFee: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3428        let mut resultFees: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
3429        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fee".into(), resultFee); }
3430        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fees".into(), resultFees); }
3431        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("amount".into(), self.parse_number(amount, &[])); }
3432        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3433        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("cost".into(), self.parse_number(cost, &[])); }
3434        return trade;
3435
3436    Value::Null
3437}
3438
3439    fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3440        let mut timestamp = get_arg(optional_args, 0, Value::Null);
3441        let mut side = get_arg(optional_args, 1, Value::Null);
3442        let mut amount = get_arg(optional_args, 2, Value::Null);
3443        let mut price = get_arg(optional_args, 3, Value::Null);
3444        let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3445        // this approach is being used by multiple exchanges (mexc, woo, coinsbit, dydx, ...)
3446        let mut id: Value = Value::Null;
3447        if (timestamp != Value::Null) {
3448            id = self.number_to_string(timestamp);
3449            if (side != Value::Null) {
3450                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), side).into())).into());
3451            }
3452            if (amount != Value::Null) {
3453                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(amount)).into())).into());
3454            }
3455            if (price != Value::Null) {
3456                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(price)).into())).into());
3457            }
3458            if (takerOrMaker != Value::Null) {
3459                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), takerOrMaker).into())).into());
3460            }
3461        }
3462        return id;
3463
3464    Value::Null
3465}
3466
3467    fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3468        let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3469        let mut fees: Value = self.safe_list_k(container, "fees", &[]);
3470        let mut feeDefined: bool = fee != Value::Null;
3471        let mut feesDefined: bool = fees != Value::Null;
3472        // parsing only if at least one of them is defined
3473        let mut shouldParseFees: bool = feeDefined || feesDefined;
3474        if shouldParseFees {
3475            if feeDefined {
3476                fee = self.parse_fee_numeric(fee.clone());
3477            }
3478            if !feesDefined {
3479                // just set it directly, no further processing needed.
3480                fees = Value::from(vec![fee.clone()]);
3481            }
3482            // 'fees' were set, so reparse them
3483            let mut reducedFees: Value = fees.clone();
3484            if is_true(&self.reduceFees) {
3485                reducedFees = self.reduce_fees_by_currency(fees.clone());
3486            }
3487            if (reducedFees == Value::Null) {
3488                reducedFees = Value::from(vec![]);
3489            }
3490            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3491            {
3492                                let mut i: Value = Value::Int(0);
3493                let mut __for_first_98: bool = true;
3494                while { if !__for_first_98 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_98 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3495                { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3496            }
3497            }
3498            fees = reducedFees.clone();
3499            if (reducedLength == 1.0) {
3500                fee = reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3501            }  else if (reducedLength == 0.0) {
3502                fee = Value::Null;
3503            }
3504        }
3505        // in case `fee & fees` are undefined, set `fees` as empty array
3506        if (fee == Value::Null) {
3507            fee = Value::Map({
3508                let mut m = indexmap::IndexMap::new();
3509                    m.insert("cost".to_string(), Value::Null);
3510                    m.insert("currency".to_string(), Value::Null);
3511                m
3512            });
3513        }
3514        if (fees == Value::Null) {
3515            fees = Value::from(vec![]);
3516        }
3517        return Value::from(vec![fee, fees]);
3518
3519    Value::Null
3520}
3521
3522    fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3523        { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); }; // ensure numeric
3524        if (in_op(&fee, &Value::Str("rate".into()))) {
3525            { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".into()), __be_tmp); };
3526        }
3527        return fee;
3528
3529    Value::Null
3530}
3531
3532    fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3533        //  i.e. findNearestCeiling ([ 10, 30, 50],  23) returns 30
3534        let mut length: Value = Value::Int(arr.len() as i64);
3535        {
3536                        let mut i: Value = Value::Int(0);
3537            let mut __for_first_99: bool = true;
3538            while { if !__for_first_99 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_99 = false; i.as_f64().unwrap_or(f64::NAN) < length.as_f64().unwrap_or(f64::NAN) } {
3539            let mut current: Value = arr.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3540            if providedValue.as_f64().unwrap_or(f64::NAN) <= current.as_f64().unwrap_or(f64::NAN) {
3541                return current;
3542            }
3543        }
3544        }
3545        return get_value(&arr, &(match (&(length), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }));
3546
3547    Value::Null
3548}
3549
3550    fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3551        let mut result: Value = Value::from(vec![]);
3552        let mut keys: Value = object_keys(&obj);
3553        {
3554                        let mut i: Value = Value::Int(0);
3555            let mut __for_first_100: bool = true;
3556            while { if !__for_first_100 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_100 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
3557            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3558            let mut item: Value = get_value(&obj, &key);
3559            let mut item: Value = get_value(&obj, &key);
3560            if (item == Value::Null) {
3561                continue;
3562            }
3563            let mut itemWithKey: Value = self.extend(Value::Map({
3564                let mut m = indexmap::IndexMap::new();
3565                m
3566            }), &[item]);
3567            add_element_to_object(&mut itemWithKey, &keyName, key);
3568            append_to_array(&mut result, itemWithKey);
3569        }
3570        }
3571        return result;
3572
3573    Value::Null
3574}
3575
3576    fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3577        let mut reversed: Value = Value::Map({
3578            let mut m = indexmap::IndexMap::new();
3579            m
3580        });
3581        let mut keys: Value = object_keys(&dict);
3582        {
3583                        let mut i: Value = Value::Int(0);
3584            let mut __for_first_101: bool = true;
3585            while { if !__for_first_101 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_101 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
3586            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3587            let mut value: Value = get_value(&dict, &key);
3588            let mut value: Value = get_value(&dict, &key);
3589            if matches!(&value, Value::Str(_)) {
3590                if let Value::Dict(__d) = &mut reversed { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&value), key); }
3591            }
3592        }
3593        }
3594        return reversed;
3595
3596    Value::Null
3597}
3598
3599    fn string_to_base16(&self, mut str_val: Value) -> Value {
3600        return Value::Str(format!("{}{}", Value::Str("0x".into()), self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val, &[]), &[]), &[])).into());
3601
3602    Value::Null
3603}
3604
3605    fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3606        //
3607        // this function takes a list of fee structures having the following format
3608        //
3609        //     string = true
3610        //
3611        //     [
3612        //         { 'currency': 'BTC', 'cost': '0.1' },
3613        //         { 'currency': 'BTC', 'cost': '0.2'  },
3614        //         { 'currency': 'BTC', 'cost': '0.2', 'rate': '0.00123' },
3615        //         { 'currency': 'BTC', 'cost': '0.4', 'rate': '0.00123' },
3616        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3617        //         { 'currency': 'USDT', 'cost': '12.3456' },
3618        //     ]
3619        //
3620        //     string = false
3621        //
3622        //     [
3623        //         { 'currency': 'BTC', 'cost': 0.1 },
3624        //         { 'currency': 'BTC', 'cost': 0.2 },
3625        //         { 'currency': 'BTC', 'cost': 0.2, 'rate': 0.00123 },
3626        //         { 'currency': 'BTC', 'cost': 0.4, 'rate': 0.00123 },
3627        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3628        //         { 'currency': 'USDT', 'cost': 12.3456 },
3629        //     ]
3630        //
3631        // and returns a reduced fee list, where fees are summed per currency and rate (if any)
3632        //
3633        //     string = true
3634        //
3635        //     [
3636        //         { 'currency': 'BTC', 'cost': '0.4'  },
3637        //         { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
3638        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3639        //         { 'currency': 'USDT', 'cost': '12.3456' },
3640        //     ]
3641        //
3642        //     string  = false
3643        //
3644        //     [
3645        //         { 'currency': 'BTC', 'cost': 0.3  },
3646        //         { 'currency': 'BTC', 'cost': 0.6, 'rate': 0.00123 },
3647        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3648        //         { 'currency': 'USDT', 'cost': 12.3456 },
3649        //     ]
3650        //
3651        let mut reduced: Value = Value::Map({
3652            let mut m = indexmap::IndexMap::new();
3653            m
3654        });
3655        {
3656                        let mut i: Value = Value::Int(0);
3657            let mut __for_first_102: bool = true;
3658            while { if !__for_first_102 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_102 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&fees).as_f64().unwrap_or(f64::NAN) } {
3659            let mut fee: Value = get_value(&fees, &i);
3660            let mut fee: Value = get_value(&fees, &i);
3661            let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3662            let mut feeCurrencyCode: Value = (if (code != Value::Null) { code.clone() } else { to_string_val(&i) });
3663            if (feeCurrencyCode != Value::Null) {
3664                let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3665                let mut cost: Value = self.safe_string_k(fee, "cost", &[]);
3666                if (cost == Value::Null) {
3667                    continue;
3668                }
3669                if !(in_op(&reduced, &feeCurrencyCode)) {
3670                    if let Value::Dict(__d) = &mut reduced { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&feeCurrencyCode), Value::Map({
3671    let mut m = indexmap::IndexMap::new();
3672    m
3673})); }
3674                }
3675                let mut rateKey: Value = (if (rate == Value::Null) { Value::Str("".into()) } else { rate.clone() });
3676                if (in_op(&reduced.as_map().and_then(|__m| feeCurrencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &rateKey)) {
3677                    { let __be_tmp = crate::precise::Precise::stringAdd(&crate::value::get_value_k(&get_value(&get_value(&reduced, &feeCurrencyCode), &rateKey), "cost"), &cost); add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("cost".into()), __be_tmp); };
3678                }  else {
3679                    add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
3680    let mut m = indexmap::IndexMap::new();
3681        m.insert("currency".to_string(), code);
3682        m.insert("cost".to_string(), cost);
3683    m
3684}));
3685                    if (rate != Value::Null) {
3686                        add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".into()), rate);
3687                    }
3688                }
3689            }
3690        }
3691        }
3692        let mut result: Value = Value::from(vec![]);
3693        let mut feeValues: Value = object_values(&reduced);
3694        {
3695                        let mut i: Value = Value::Int(0);
3696            let mut __for_first_103: bool = true;
3697            while { if !__for_first_103 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_103 = false; i.as_f64().unwrap_or(f64::NAN) < ((feeValues.len() as i64) as f64) } {
3698            let mut reducedFeeValues: Value = object_values(&feeValues.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
3699            result = self.array_concat(result.clone(), reducedFeeValues);
3700        }
3701        }
3702        return result;
3703
3704    Value::Null
3705}
3706
3707    fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3708        let mut market = get_arg(optional_args, 0, Value::Null);
3709        let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3710        let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".into()), Value::Str("last".into()), &[]));
3711        let mut change: Value = self.safe_string_k(ticker.clone(), "change", &[]); // change can be a legitimate zero on a flat day, do not omitZero it, see https://github.com/ccxt/ccxt/issues/25971
3712        let mut percentage: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "percentage", &[]));
3713        let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3714        let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3715        let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
3716        let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
3717        if (vwap == Value::Null) {
3718            vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
3719        }
3720        // calculate open
3721        if (change != Value::Null) {
3722            if (close == Value::Null) && (average != Value::Null) {
3723                close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".into())));
3724            }
3725            if (open == Value::Null) && (close != Value::Null) {
3726                open = crate::precise::Precise::stringSub(&close, &change);
3727            }
3728        }  else if (percentage != Value::Null) {
3729            if (close == Value::Null) && (average != Value::Null) {
3730                let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".into()));
3731                // openAddClose = open * (1 + (100 + percentage)/100)
3732                let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3733                let mut calcOpen: Value = (if (open != Value::Null) { open.clone() } else { crate::precise::Precise::stringDiv(&openAddClose, &denominator) });
3734                close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3735            }
3736            if (open == Value::Null) && (close != Value::Null) {
3737                open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3738            }
3739        }
3740        // change
3741        if (change == Value::Null) {
3742            if (close != Value::Null) && (open != Value::Null) {
3743                change = crate::precise::Precise::stringSub(&close, &open);
3744            }  else if (close != Value::Null) && (percentage != Value::Null) {
3745                change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".into())));
3746            }  else if (open != Value::Null) && (percentage != Value::Null) {
3747                change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3748            }
3749        }
3750        // calculate things according to "open" (similar can be done with "close")
3751        if (open != Value::Null) {
3752            // percentage (using change)
3753            if (percentage == Value::Null) && (change != Value::Null) {
3754                percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".into()));
3755            }
3756            // close (using change)
3757            if (close == Value::Null) && (change != Value::Null) {
3758                close = crate::precise::Precise::stringAdd(&open, &change);
3759            }
3760            // close (using average)
3761            if (close == Value::Null) && (average != Value::Null) {
3762                // average is the midpoint of open and close, so twice it is their sum
3763                close = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&average, &Value::Str("2".into())), &open);
3764            }
3765            // average
3766            if (average == Value::Null) && (close != Value::Null) {
3767                let mut precision: Value = Value::Int(18);
3768                if (market != Value::Null) && self.is_tick_precision().as_bool() == Some(true) {
3769                    let mut marketPrecision: Value = self.safe_dict_k(market, "precision", &[]);
3770                    let mut precisionPrice: Value = self.safe_string_k(marketPrecision, "price", &[]);
3771                    if (precisionPrice != Value::Null) {
3772                        precision = self.precision_from_string(precisionPrice);
3773                    }
3774                }
3775                average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".into()), &precision);
3776            }
3777        }
3778        // timestamp and symbol operations don't belong in safeTicker
3779        // they should be done in the derived classes
3780        let mut closeParsed: Value = self.parse_number(self.omit_zero(close), &[]);
3781        return self.extend(ticker.clone(), &[Value::Map({
3782    let mut m = indexmap::IndexMap::new();
3783        m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3784        m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3785        m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3786        m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3787        m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3788        m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3789        m.insert("open".to_string(), self.parse_number(self.omit_zero(open), &[]));
3790        m.insert("close".to_string(), closeParsed.clone());
3791        m.insert("last".to_string(), closeParsed);
3792        m.insert("change".to_string(), self.parse_number(change, &[]));
3793        m.insert("percentage".to_string(), self.parse_number(percentage, &[]));
3794        m.insert("average".to_string(), self.parse_number(average, &[]));
3795        m.insert("vwap".to_string(), self.parse_number(vwap, &[]));
3796        m.insert("baseVolume".to_string(), self.parse_number(baseVolume, &[]));
3797        m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume, &[]));
3798        m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3799        m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3800        m.insert("markPrice".to_string(), self.safe_number_k(ticker, "markPrice", &[]));
3801    m
3802})]);
3803
3804    Value::Null
3805}
3806
3807    fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3808        let mut params = get_arg(optional_args, 0, Value::Map({
3809    let mut m = indexmap::IndexMap::new();
3810    m
3811}));
3812        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".into()))));
3813
3814    Value::Null
3815} }
3816
3817    fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3818        // async-virtual: try the derived exchange first
3819        if let Some(__v) = self.dispatch_to_derived("repay_cross_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
3820            if !matches!(__v, crate::Value::Null) { return __v; }
3821        }
3822
3823        let mut params = get_arg(optional_args, 0, Value::Map({
3824    let mut m = indexmap::IndexMap::new();
3825    m
3826}));
3827        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayCrossMargin is not support yet".into()))));
3828
3829    Value::Null
3830} }
3831
3832    fn repay_isolated_margin(&mut self, mut symbol: Value, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3833        // async-virtual: try the derived exchange first
3834        if let Some(__v) = self.dispatch_to_derived("repay_isolated_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(code); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
3835            if !matches!(__v, crate::Value::Null) { return __v; }
3836        }
3837
3838        let mut params = get_arg(optional_args, 0, Value::Map({
3839    let mut m = indexmap::IndexMap::new();
3840    m
3841}));
3842        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayIsolatedMargin is not support yet".into()))));
3843
3844    Value::Null
3845} }
3846
3847    fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3848        // async-virtual: try the derived exchange first
3849        if let Some(__v) = self.dispatch_to_derived("borrow_cross_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
3850            if !matches!(__v, crate::Value::Null) { return __v; }
3851        }
3852
3853        let mut params = get_arg(optional_args, 0, Value::Map({
3854    let mut m = indexmap::IndexMap::new();
3855    m
3856}));
3857        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowCrossMargin is not support yet".into()))));
3858
3859    Value::Null
3860} }
3861
3862    fn borrow_isolated_margin(&mut self, mut symbol: Value, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3863        // async-virtual: try the derived exchange first
3864        if let Some(__v) = self.dispatch_to_derived("borrow_isolated_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(code); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
3865            if !matches!(__v, crate::Value::Null) { return __v; }
3866        }
3867
3868        let mut params = get_arg(optional_args, 0, Value::Map({
3869    let mut m = indexmap::IndexMap::new();
3870    m
3871}));
3872        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowIsolatedMargin is not support yet".into()))));
3873
3874    Value::Null
3875} }
3876
3877    fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3878        let mut symbol = get_arg(optional_args, 0, Value::Null);
3879        let mut params = get_arg(optional_args, 1, Value::Map({
3880    let mut m = indexmap::IndexMap::new();
3881    m
3882}));
3883        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".into()))));
3884
3885    Value::Null
3886} }
3887
3888    fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3889        let mut symbol = get_arg(optional_args, 0, Value::Null);
3890        let mut params = get_arg(optional_args, 1, Value::Map({
3891    let mut m = indexmap::IndexMap::new();
3892    m
3893}));
3894        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".into()))));
3895
3896    Value::Null
3897} }
3898
3899    fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3900        // async-virtual: try the derived exchange first
3901        if let Some(__v) = self.dispatch_to_derived("fetch_ohlcv", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.extend_from_slice(optional_args); __args }).await {
3902            if !matches!(__v, crate::Value::Null) { return __v; }
3903        }
3904
3905        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3906        let mut since = get_arg(optional_args, 1, Value::Null);
3907        let mut limit = get_arg(optional_args, 2, Value::Null);
3908        let mut params = get_arg(optional_args, 3, Value::Map({
3909    let mut m = indexmap::IndexMap::new();
3910    m
3911}));
3912        let mut message: Value = Value::Str("".into());
3913        if (self.has.as_map().and_then(|__m| __m.get("fetchTrades")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTrades")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
3914            message = Value::Str(". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".into());
3915        }
3916        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() is not supported yet".into())).into()), message)));
3917
3918    Value::Null
3919} }
3920
3921    fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3922        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3923        let mut since = get_arg(optional_args, 1, Value::Null);
3924        let mut limit = get_arg(optional_args, 2, Value::Null);
3925        let mut params = get_arg(optional_args, 3, Value::Map({
3926    let mut m = indexmap::IndexMap::new();
3927    m
3928}));
3929        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotOHLCV() is not supported yet".into()))));
3930
3931    Value::Null
3932} }
3933
3934    fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3935        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3936        let mut since = get_arg(optional_args, 1, Value::Null);
3937        let mut limit = get_arg(optional_args, 2, Value::Null);
3938        let mut params = get_arg(optional_args, 3, Value::Map({
3939    let mut m = indexmap::IndexMap::new();
3940    m
3941}));
3942        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractOHLCV() is not supported yet".into()))));
3943
3944    Value::Null
3945} }
3946
3947    fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3948        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3949        let mut since = get_arg(optional_args, 1, Value::Null);
3950        let mut limit = get_arg(optional_args, 2, Value::Null);
3951        let mut params = get_arg(optional_args, 3, Value::Map({
3952    let mut m = indexmap::IndexMap::new();
3953    m
3954}));
3955        let mut message: Value = Value::Str("".into());
3956        if (self.has.as_map().and_then(|__m| __m.get("fetchTradesWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTradesWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
3957            message = Value::Str(". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".into());
3958        }
3959        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCVWs() is not supported yet. Try using fetchOHLCV instead.".into())).into()), message)));
3960
3961    Value::Null
3962} }
3963
3964    fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3965        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3966        let mut since = get_arg(optional_args, 1, Value::Null);
3967        let mut limit = get_arg(optional_args, 2, Value::Null);
3968        let mut params = get_arg(optional_args, 3, Value::Map({
3969    let mut m = indexmap::IndexMap::new();
3970    m
3971}));
3972        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCV() is not supported yet".into()))));
3973
3974    Value::Null
3975} }
3976
3977    fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
3978        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
3979        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
3980        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
3981        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
3982        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
3983        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
3984        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
3985        let mut result: Value = Value::from(vec![]);
3986        let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp, &[Value::from(vec![])]);
3987        let mut opens: Value = self.safe_list(ohlcvs.clone(), open, &[Value::from(vec![])]);
3988        let mut highs: Value = self.safe_list(ohlcvs.clone(), high, &[Value::from(vec![])]);
3989        let mut lows: Value = self.safe_list(ohlcvs.clone(), low, &[Value::from(vec![])]);
3990        let mut closes: Value = self.safe_list(ohlcvs.clone(), close, &[Value::from(vec![])]);
3991        let mut volumes: Value = self.safe_list(ohlcvs, volume, &[Value::from(vec![])]);
3992        {
3993                        let mut i: Value = Value::Int(0);
3994            let mut __for_first_104: bool = true;
3995            while { if !__for_first_104 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_104 = false; i.as_f64().unwrap_or(f64::NAN) < ((timestamps.len() as i64) as f64) } {
3996            append_to_array(&mut result, Value::from(vec![(if is_true(&ms) { self.safe_integer(timestamps.clone(), i.clone(), &[]) } else { self.safe_timestamp(timestamps.clone(), i.clone(), &[]) }), self.safe_value(opens.clone(), i.clone(), &[]), self.safe_value(highs.clone(), i.clone(), &[]), self.safe_value(lows.clone(), i.clone(), &[]), self.safe_value(closes.clone(), i.clone(), &[]), self.safe_value(volumes.clone(), i.clone(), &[])]));
3997        }
3998        }
3999        return result;
4000
4001    Value::Null
4002}
4003
4004    fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4005        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4006        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4007        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4008        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4009        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4010        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4011        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4012        let mut result: Value = Value::Map({
4013            let mut m = indexmap::IndexMap::new();
4014            m
4015        });
4016        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&timestamp), Value::from(vec![])); }
4017        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&open), Value::from(vec![])); }
4018        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&high), Value::from(vec![])); }
4019        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&low), Value::from(vec![])); }
4020        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&close), Value::from(vec![])); }
4021        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&volume), Value::from(vec![])); }
4022        {
4023                        let mut i: Value = Value::Int(0);
4024            let mut __for_first_105: bool = true;
4025            while { if !__for_first_105 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_105 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4026            let mut ts: Value = (if is_true(&ms) { ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null) } else { self.parse_to_int((match ((ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })) });
4027            let mut resultTimestamp: Value = get_value(&result, &timestamp);
4028            append_to_array(&mut resultTimestamp, ts);
4029            crate::set_value(&mut result, &timestamp, resultTimestamp);
4030            let mut resultOpen: Value = get_value(&result, &open);
4031            append_to_array(&mut resultOpen, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null));
4032            crate::set_value(&mut result, &open, resultOpen);
4033            let mut resultHigh: Value = get_value(&result, &high);
4034            append_to_array(&mut resultHigh, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(2)).cloned().unwrap_or(Value::Null));
4035            crate::set_value(&mut result, &high, resultHigh);
4036            let mut resultLow: Value = get_value(&result, &low);
4037            append_to_array(&mut resultLow, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(3)).cloned().unwrap_or(Value::Null));
4038            crate::set_value(&mut result, &low, resultLow);
4039            let mut resultClose: Value = get_value(&result, &close);
4040            append_to_array(&mut resultClose, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(4)).cloned().unwrap_or(Value::Null));
4041            crate::set_value(&mut result, &close, resultClose);
4042            let mut resultVolume: Value = get_value(&result, &volume);
4043            append_to_array(&mut resultVolume, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(5)).cloned().unwrap_or(Value::Null));
4044            crate::set_value(&mut result, &volume, resultVolume);
4045        }
4046        }
4047        return result;
4048
4049    Value::Null
4050}
4051
4052    fn fetch_web_endpoint(&mut self, mut method: Value, mut endpointMethod: Value, mut returnAsJson: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4053        let mut startRegex = get_arg(optional_args, 0, Value::Null);
4054        let mut endRegex = get_arg(optional_args, 1, Value::Null);
4055        let mut errorMessage: Value = Value::Str("".into());
4056        let mut options: Value = self.safe_value(self.options.clone(), method, &[Value::Map({
4057            let mut m = indexmap::IndexMap::new();
4058            m
4059        })]);
4060        let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4061        {
4062            // if it was not explicitly disabled, then don't fetch
4063            if !matches!(self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)]), Value::Bool(true)) {
4064                return Value::Null;
4065            }
4066            let mut maxRetries: Value = self.safe_value_k(options, "webApiRetries", &[Value::Int(10)]);
4067            let mut response: Value = Value::Null;
4068            let mut retry: f64 = ((0i64) as f64);
4069            let mut shouldBreak: bool = false;
4070            while retry < maxRetries.as_f64().unwrap_or(f64::NAN) {
4071                {
4072                    response = self.call_dynamic_checked(endpointMethod.clone(), vec![(Value::Map({
4073                        let mut m = indexmap::IndexMap::new();
4074                        m
4075                    })).clone()]).await;
4076                    shouldBreak = true;
4077                    break;
4078                }
4079                if shouldBreak {
4080                    break;
4081                }
4082            }
4083            let mut content: Value = response;
4084            if (content == Value::Null) {
4085                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4086            }
4087            if (startRegex != Value::Null) {
4088                let mut splitted_by_start: Value = split(&content, &startRegex);
4089                content = get_value(&splitted_by_start, &Value::Int(1)); // we need second part after start
4090            }
4091            if (content == Value::Null) {
4092                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4093            }
4094            if (endRegex != Value::Null) {
4095                let mut splitted_by_end: Value = split(&content, &endRegex);
4096                content = get_value(&splitted_by_end, &Value::Int(0)); // we need first part after start
4097            }
4098            if (is_equal(&returnAsJson, &Value::Bool(true))) && (matches!(&content, Value::Str(_))) {
4099                let mut jsoned: Value = self.parse_json_value(trim(&content)); // content should be trimmed before json parsing
4100                if (jsoned != Value::Null) && (jsoned != Value::Null) {
4101                    return jsoned;
4102                }  else {
4103                    panic!("{}", crate::exchange_errors::bad_response("could not parse the response into json"));
4104                }
4105            }  else {
4106                return content;
4107            }
4108        }
4109        if (muteOnFailure.as_bool() == Some(true)) {
4110            return Value::Null;
4111        }  else {
4112            panic!("{}", crate::exchange_errors::bad_response(errorMessage));
4113        }
4114} }
4115
4116    fn market_ids(&self, optional_args: &[Value]) -> Value {
4117        let mut symbols = get_arg(optional_args, 0, Value::Null);
4118        /*
4119         * @param {string[]|undefined} symbols list of unified symbols
4120         * @returns {string[]|undefined} list of exchange-specific market ids
4121         * Overloads: non-null `string[]` input yields `string[]`; optional input yields `Strings`.
4122         */
4123        if (symbols == Value::Null) {
4124            return symbols;
4125        }
4126        let mut result: Value = Value::from(vec![]);
4127        {
4128                        let mut i: Value = Value::Int(0);
4129            let mut __for_first_106: bool = true;
4130            while { if !__for_first_106 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_106 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4131            let mut id: Value = self.market_id(symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4132            if (id != Value::Null) {
4133                append_to_array(&mut result, id);
4134            }
4135        }
4136        }
4137        return result;
4138
4139    Value::Null
4140}
4141
4142    fn currency_ids(&self, optional_args: &[Value]) -> Value {
4143        let mut codes = get_arg(optional_args, 0, Value::Null);
4144        if (codes == Value::Null) {
4145            return codes;
4146        }
4147        let mut result: Value = Value::from(vec![]);
4148        {
4149                        let mut i: Value = Value::Int(0);
4150            let mut __for_first_107: bool = true;
4151            while { if !__for_first_107 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_107 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
4152            let mut id: Value = self.currency_id(codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4153            if (id != Value::Null) {
4154                append_to_array(&mut result, id);
4155            }
4156        }
4157        }
4158        return result;
4159
4160    Value::Null
4161}
4162
4163    fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4164        let mut symbols = get_arg(optional_args, 0, Value::Null);
4165        if (symbols == Value::Null) {
4166            return Value::Null;
4167        }
4168        let mut result: Value = Value::from(vec![]);
4169        {
4170                        let mut i: Value = Value::Int(0);
4171            let mut __for_first_108: bool = true;
4172            while { if !__for_first_108 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_108 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4173            append_to_array(&mut result, self.market(symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)));
4174        }
4175        }
4176        return result;
4177
4178    Value::Null
4179}
4180
4181// allowEmpty: false always returns string[] (throws on empty/undefined at runtime)
4182    fn market_symbols(&self, optional_args: &[Value]) -> Value {
4183        let mut symbols = get_arg(optional_args, 0, Value::Null);
4184        let mut type_var = get_arg(optional_args, 1, Value::Null);
4185        let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4186        let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4187        let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4188        /*
4189         * @param {string[]|undefined} symbols list of unified symbols
4190         * @param {string|undefined} type filter by market type
4191         * @param {boolean} allowEmpty whether empty/undefined symbols is allowed
4192         * @param {boolean} sameTypeOnly require all markets to share type
4193         * @param {boolean} sameSubTypeOnly require all markets to share linear/inverse subType
4194         * @returns {string[]|undefined} validated unified symbols
4195         * Overloads: `allowEmpty: false` or non-null `string[]` input yields `string[]`; permissive form yields `Strings`.
4196         */
4197        if (symbols == Value::Null) {
4198            if !is_true(&allowEmpty) {
4199                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4200            }
4201            return symbols;
4202        }
4203        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
4204        if (symbolsLength == 0.0) {
4205            if !is_true(&allowEmpty) {
4206                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4207            }
4208            return symbols;
4209        }
4210        let mut result: Value = Value::from(vec![]);
4211        let mut marketType: Value = Value::Null;
4212        let mut isLinearSubType: Value = Value::Null;
4213        {
4214                        let mut i: Value = Value::Int(0);
4215            let mut __for_first_109: bool = true;
4216            while { if !__for_first_109 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_109 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4217            let mut market: Value = self.market(symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4218            if is_true(&sameTypeOnly) && (marketType != Value::Null) {
4219                if (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != marketType.as_str()) {
4220                    panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same type, either ".into())).into()), marketType).into()), Value::Str(" or ".into())).into()), market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null)).into()), Value::Str(".".into()))));
4221                }
4222            }
4223            if is_true(&sameSubTypeOnly) && (isLinearSubType != Value::Null) {
4224                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() != isLinearSubType.as_bool()) {
4225                    panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same subType, either linear or inverse.".into()))));
4226                }
4227            }
4228            if (type_var != Value::Null) && (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != type_var.as_str()) {
4229                panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same type ".into())).into()), type_var).into()), Value::Str(". If the type is incorrect you can change it in options or the params of the request".into()))));
4230            }
4231            marketType = market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null);
4232            if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
4233                isLinearSubType = market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null);
4234            }
4235            let mut symbol: Value = self.safe_string_k(market, "symbol", &[symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)]);
4236            append_to_array(&mut result, symbol);
4237        }
4238        }
4239        return result;
4240
4241    Value::Null
4242}
4243
4244    fn market_codes(&self, optional_args: &[Value]) -> Value {
4245        let mut codes = get_arg(optional_args, 0, Value::Null);
4246        if (codes == Value::Null) {
4247            return codes;
4248        }
4249        let mut result: Value = Value::from(vec![]);
4250        {
4251                        let mut i: Value = Value::Int(0);
4252            let mut __for_first_110: bool = true;
4253            while { if !__for_first_110 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_110 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
4254            append_to_array(&mut result, self.common_currency_code(codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)));
4255        }
4256        }
4257        return result;
4258
4259    Value::Null
4260}
4261
4262    fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4263        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4264        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4265        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4266        bidasks = self.to_array(bidasks.clone());
4267        let mut result: Value = Value::from(vec![]);
4268        {
4269                        let mut i: Value = Value::Int(0);
4270            let mut __for_first_111: bool = true;
4271            while { if !__for_first_111 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_111 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&bidasks).as_f64().unwrap_or(f64::NAN) } {
4272            append_to_array(&mut result, self.parse_order_book_bid_ask(get_value(&bidasks, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4273        }
4274        }
4275        return result;
4276
4277    Value::Null
4278}
4279
4280    fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4281        let mut value = get_arg(optional_args, 0, Value::Null);
4282        if (value == Value::Null) {
4283            return objects;
4284        }
4285        let mut result: Value = Value::from(vec![]);
4286        {
4287                        let mut i: Value = Value::Int(0);
4288            let mut __for_first_112: bool = true;
4289            while { if !__for_first_112 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_112 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objects).as_f64().unwrap_or(f64::NAN) } {
4290            let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
4291            if (objectValue.as_str() == value.as_str()) {
4292                append_to_array(&mut result, get_value(&objects, &i));
4293            }
4294        }
4295        }
4296        return result;
4297
4298    Value::Null
4299}
4300
4301    fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4302        let mut symbol = get_arg(optional_args, 0, Value::Null);
4303        return self.filter_by_key(objects, Value::Str("symbol".into()), &[symbol]);
4304
4305    Value::Null
4306}
4307
4308    fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4309        // virtual-dispatch (static: DerivedExchange::parse_ohlcv(self, ...))
4310        { let __v = crate::exchange::DerivedExchange::parse_ohlcv(self, ohlcv.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
4311
4312        let mut market = get_arg(optional_args, 0, Value::Null);
4313        if (matches!(&ohlcv, Value::Arr(_))) {
4314            return Value::from(vec![self.safe_integer(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv.clone(), Value::Int(5), &[])]);
4315        }
4316        return ohlcv;
4317
4318    Value::Null
4319}
4320
4321    fn safe_network(&self, mut network: Value) -> Value {
4322        let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
4323        let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
4324        let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
4325        let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4326        let mut deposit: Value = self.safe_dict_k(limits, "deposit", &[]);
4327        let mut isEnabled: Value = withdrawEnabled.clone();
4328        if (withdrawEnabled.as_bool() == Some(true)) {
4329            isEnabled = depositEnabled.clone();
4330        }
4331        return Value::Map({
4332    let mut m = indexmap::IndexMap::new();
4333        m.insert("info".to_string(), crate::value::get_value_k(&network, "info"));
4334        m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
4335        m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
4336        m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
4337        m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled]));
4338        m.insert("deposit".to_string(), depositEnabled);
4339        m.insert("withdraw".to_string(), withdrawEnabled);
4340        m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
4341        m.insert("precision".to_string(), self.safe_number_k(network, "precision", &[]));
4342        m.insert("limits".to_string(), Value::Map({
4343    let mut m = indexmap::IndexMap::new();
4344        m.insert("withdraw".to_string(), Value::Map({
4345    let mut m = indexmap::IndexMap::new();
4346        m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4347        m.insert("max".to_string(), self.safe_number_k(withdraw, "max", &[]));
4348    m
4349}));
4350        m.insert("deposit".to_string(), Value::Map({
4351    let mut m = indexmap::IndexMap::new();
4352        m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4353        m.insert("max".to_string(), self.safe_number_k(deposit, "max", &[]));
4354    m
4355}));
4356    m
4357}));
4358    m
4359});
4360
4361    Value::Null
4362}
4363
4364    fn prioritized_network_aliases(&self, optional_args: &[Value]) -> Value {
4365        let mut networkCode = get_arg(optional_args, 0, Value::Null);
4366        let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4367        let mut allowDefault = get_arg(optional_args, 2, Value::Bool(false));
4368        /*
4369         * @method
4370         * @name Exchange#prioritizedNetworkAliases
4371         * @description returns the chain pair [preferred, alternative] for the given networkCode & currency, e.g:
4372         *   ---------------------------------
4373         *   | input          | output       |
4374         *   --------------------------------|
4375         *   | ETH & USDC     | ERC20, ETH   |
4376         *   | ERC20 & USDC   | ERC20, ETH   |
4377         *   | ETH & ETH      | ETH, ERC20   |
4378         *   | ERC20 & ETH    | ETH, ERC20   |
4379         *   | ERC20          | ERC20, ETH   |
4380         *   | ETH            | ERC20, ETH   |
4381         *   ---------------------------------
4382         * @param {string} networkCode unified network-code
4383         * @param {string} currencyCode unified currency-code
4384         * @param {boolean} allowDefault when currencyCode is undefined, order by replacement's "default" instead of by user input
4385         * @returns {string[]} [preferredChain, alternativeChain]
4386         */
4387        if (networkCode == Value::Null) {
4388            return Value::Null;
4389        }
4390        let mut replacements: Value = self.safe_dict_k(self.options.clone(), "defaultNetworkCodeReplacements", &[Value::Map({
4391    let mut m = indexmap::IndexMap::new();
4392    m
4393})]);
4394        let mut keys: Value = object_keys(&replacements);
4395        {
4396                        let mut i: Value = Value::Int(0);
4397            let mut __for_first_113: bool = true;
4398            while { if !__for_first_113 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_113 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
4399            let mut baseCoin: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4400            let mut entry: Value = replacements.as_map().and_then(|__m| baseCoin.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4401            let mut primary: Value = crate::value::get_value_k(&entry, "primary");
4402            let mut secondary: Value = crate::value::get_value_k(&entry, "secondary");
4403            if !is_equal(&networkCode, &primary) && !is_equal(&networkCode, &secondary) {
4404                continue;
4405            }
4406            // pick which form goes first in the returned pair
4407            let mut preferPrimary: bool = false;
4408            if (currencyCode.as_str() == baseCoin.as_str()) {
4409                preferPrimary = true; // mainnet currency uses primary chain
4410            }  else if (currencyCode != Value::Null) {
4411                preferPrimary = false; // any other (token) currency uses secondary chain
4412            }  else if is_true(&allowDefault) {
4413                preferPrimary = crate::value::get_value_k(&entry, "default").as_str() == Some("primary");
4414            }  else {
4415                preferPrimary = is_equal(&networkCode, &primary); // keep user input first
4416            }
4417            return (if (preferPrimary) { Value::from(vec![primary.clone(), secondary.clone()]) } else { Value::from(vec![secondary, primary]) });
4418        }
4419        }
4420        return Value::from(vec![networkCode.clone(), networkCode.clone()]);
4421
4422    Value::Null
4423}
4424
4425    fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4426        let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4427        /*
4428         * @ignore
4429         * @method
4430         * @name exchange#networkCodeToId
4431         * @description tries to convert the provided networkCode (which is expected to be an unified network code) to a network id. In order to achieve this, derived class needs to have 'options->networks' defined.
4432         * @param {string} networkCode unified network code
4433         * @param {string} currencyCode unified currency code, but this argument is not required by default, unless there is an exchange (like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
4434         * @returns {string|undefined} exchange-specific network id
4435         */
4436        if (networkCode == Value::Null) {
4437            return Value::Null;
4438        }
4439        let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4440    let mut m = indexmap::IndexMap::new();
4441    m
4442})]);
4443        // try the preferred form first, fall back to its alternative (e.g. when only 'ETH' or only 'ERC20' is defined)
4444        let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(false)]);
4445        let mut preferredChain: Value = (if (chainPair == Value::Null) { networkCode.clone() } else { chainPair.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null) });
4446        let mut alternativeChain: Value = (if (chainPair == Value::Null) { networkCode.clone() } else { chainPair.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null) });
4447        let mut networkId: Value = self.safe_string2(networkIdsByCodes, preferredChain, alternativeChain, &[]);
4448        if (networkId != Value::Null) {
4449            return networkId;
4450        }
4451        // fall back to scanning loaded currencies
4452        let mut currenciesToCheck: Value = Value::from(vec![]);
4453        if (currencyCode == Value::Null) {
4454            currenciesToCheck = object_keys(&self.currencies);
4455        }  else {
4456            currenciesToCheck = Value::from(vec![self.safe_dict(self.currencies.clone(), currencyCode.clone(), &[])]);
4457        }
4458        {
4459                        let mut i: Value = Value::Int(0);
4460            let mut __for_first_114: bool = true;
4461            while { if !__for_first_114 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_114 = false; i.as_f64().unwrap_or(f64::NAN) < ((currenciesToCheck.len() as i64) as f64) } {
4462            let mut networks: Value = self.safe_dict(currenciesToCheck.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), Value::Str("networks".into()), &[Value::Map({
4463    let mut m = indexmap::IndexMap::new();
4464    m
4465})]);
4466            if (in_op(&networks, &networkCode)) {
4467                return self.safe_string(networks.as_map().and_then(|__m| networkCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("id".into()), &[]);
4468            }
4469        }
4470        }
4471        // before returning the original input, try to match if it's backward-maintained networkCode
4472        let mut oldCodes: Value = self.safe_dict_k(self.options.clone(), "backwardSupportedNetworkCodes", &[Value::Map({
4473    let mut m = indexmap::IndexMap::new();
4474    m
4475})]);
4476        if (in_op(&oldCodes, &networkCode)) {
4477            return self.network_code_to_id(oldCodes.as_map().and_then(|__m| networkCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &[currencyCode]);
4478        }
4479        return networkCode;
4480
4481    Value::Null
4482}
4483
4484    fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4485        let mut networkId = get_arg(optional_args, 0, Value::Null);
4486        let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4487        /*
4488         * @ignore
4489         * @method
4490         * @name exchange#networkIdToCode
4491         * @description tries to convert the provided exchange-specific networkId to an unified network Code. In order to achieve this, derived class needs to have "options['networksById']" defined.
4492         * @param {string} networkId exchange specific network id/title, like: TRON, Trc-20, usdt-erc20, etc
4493         * @param {string|undefined} currencyCode unified currency code, but this argument is not required by default, unless there is an exchange (like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
4494         * @returns {string|undefined} unified network code
4495         */
4496        if (networkId == Value::Null) {
4497            return Value::Null;
4498        }
4499        let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4500    let mut m = indexmap::IndexMap::new();
4501    m
4502})]);
4503        let mut networkCode: Value = self.safe_string(networkCodesByIds, networkId.clone(), &[networkId.clone()]);
4504        let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(true)]);
4505        if (chainPair == Value::Null) {
4506            return networkCode;
4507        }
4508        let mut preferredChain: Value = chainPair.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
4509        let mut alternativeChain: Value = chainPair.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
4510        // when the exchange explicitly defines both forms in options.networks (e.g. BTC + BRC20),
4511        // it disambiguates them — trust the direct id→code inversion instead of guessing
4512        if (currencyCode == Value::Null) {
4513            let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4514    let mut m = indexmap::IndexMap::new();
4515    m
4516})]);
4517            if (in_op(&networkIdsByCodes, &preferredChain)) && (in_op(&networkIdsByCodes, &alternativeChain)) {
4518                return networkCode;
4519            }
4520        }
4521        return preferredChain;
4522
4523    Value::Null
4524}
4525
4526    fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4527        let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".into()), Value::Str("network".into()), &[]);
4528        if (networkCodeInParams != Value::Null) {
4529            params = self.omit(params.clone(), Value::from(vec![Value::Str("networkCode".into()), Value::Str("network".into())]), &[]);
4530        }
4531        return Value::from(vec![networkCodeInParams, params]);
4532
4533    Value::Null
4534}
4535
4536    fn default_network_code(&self, mut currencyCode: Value) -> Value {
4537        let mut defaultNetworkCode: Value = Value::Null;
4538        let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4539    let mut m = indexmap::IndexMap::new();
4540    m
4541})]);
4542        if (in_op(&defaultNetworks, &currencyCode)) {
4543            // if currency had set its network in "defaultNetworks", use it
4544            defaultNetworkCode = defaultNetworks.as_map().and_then(|__m| currencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4545        }  else {
4546            // otherwise, try to use the global-scope 'defaultNetwork' value (even if that network is not supported by currency, it doesn't make any problem, this will be just used "at first" if currency supports this network at all)
4547            let mut defaultNetwork: Value = self.safe_string_k(self.options.clone(), "defaultNetwork", &[]);
4548            if (defaultNetwork != Value::Null) {
4549                defaultNetworkCode = defaultNetwork;
4550            }
4551        }
4552        return defaultNetworkCode;
4553
4554    Value::Null
4555}
4556
4557    fn select_network_code_from_unified_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4558        return self.select_network_key_from_networks(currencyCode, networkCode, indexedNetworkEntries, &[Value::Bool(true)]);
4559
4560    Value::Null
4561}
4562
4563    fn select_network_id_from_raw_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4564        return self.select_network_key_from_networks(currencyCode, networkCode, indexedNetworkEntries, &[Value::Bool(false)]);
4565
4566    Value::Null
4567}
4568
4569    fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4570        let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4571        // this method is used against raw & unparse network entries, which are just indexed by network id
4572        let mut chosenNetworkId: Value = Value::Null;
4573        let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4574        let mut responseNetworksLength: f64 = ((availableNetworkIds.len() as i64) as f64);
4575        if (networkCode != Value::Null) {
4576            if (responseNetworksLength == 0.0) {
4577                panic!("{}", crate::exchange_errors::not_supported(add(&Value::Str(format!("{}{}", add(&Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), &networkCode), Value::Str(" network did not return any result for ".into())).into()), &currencyCode)));
4578            }  else {
4579                // if networkCode was provided by user, we should check it after response, as the referenced exchange doesn't support network-code during request
4580                let mut networkIdOrCode: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { networkCode.clone() } else { self.network_code_to_id(networkCode, &[currencyCode.clone()]) });
4581                if (in_op(&indexedNetworkEntries, &networkIdOrCode)) {
4582                    chosenNetworkId = networkIdOrCode.clone();
4583                }  else {
4584                    panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", add(&Value::Str(format!("{}{}", add(&Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), &networkIdOrCode), Value::Str(" network was not found for ".into())).into()), &currencyCode), Value::Str(", use one of ".into())).into()), join(&availableNetworkIds, &Value::Str(", ".into())))));
4585                }
4586            }
4587        }  else {
4588            if (responseNetworksLength == 0.0) {
4589                panic!("{}", crate::exchange_errors::not_supported(add(&Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - no networks were returned for ".into())).into()), &currencyCode)));
4590            }  else {
4591                // if networkCode was not provided by user, then we try to use the default network (if it was defined in "defaultNetworks"), otherwise, we just return the first network entry
4592                let mut defaultNetworkCode: Value = self.default_network_code(currencyCode.clone());
4593                let mut defaultNetworkId: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { defaultNetworkCode.clone() } else { self.network_code_to_id(defaultNetworkCode, &[currencyCode]) });
4594                if (defaultNetworkId == Value::Null) {
4595                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".into()))));
4596                }
4597                if (in_op(&indexedNetworkEntries, &defaultNetworkId)) {
4598                    return defaultNetworkId;
4599                }
4600                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - can not determine the default network, please pass param[\"network\"] one from : ".into())).into()), join(&availableNetworkIds, &Value::Str(", ".into())))));
4601            }
4602        }
4603        return chosenNetworkId;
4604
4605    Value::Null
4606}
4607
4608    fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4609        let mut d = get_arg(optional_args, 0, Value::Null);
4610        let mut value: Value = self.safe_string2(dictionary, key1, key2, &[]);
4611        return self.parse_number(value, &[d]);
4612
4613    Value::Null
4614}
4615
4616    fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4617        // virtual-dispatch (static: DerivedExchange::parse_order_book(self, ...))
4618        { let __v = crate::exchange::DerivedExchange::parse_order_book(self, orderbook.clone(), symbol.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null), crate::runtime::get_arg(optional_args, 2, crate::Value::Null), crate::runtime::get_arg(optional_args, 3, crate::Value::Null), crate::runtime::get_arg(optional_args, 4, crate::Value::Null), crate::runtime::get_arg(optional_args, 5, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
4619
4620        let mut timestamp = get_arg(optional_args, 0, Value::Null);
4621        let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4622        let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4623        let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4624        let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4625        let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4626        if (orderbook == Value::Null) {
4627            orderbook = Value::Map({
4628                let mut m = indexmap::IndexMap::new();
4629                m
4630            });
4631        }
4632        let mut bids: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook.clone(), bidsKey, &[Value::from(vec![])]), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
4633        let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4634        return Value::Map({
4635    let mut m = indexmap::IndexMap::new();
4636        m.insert("symbol".to_string(), symbol);
4637        m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4638        m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4639        m.insert("timestamp".to_string(), timestamp.clone());
4640        m.insert("datetime".to_string(), self.iso8601(timestamp));
4641        m.insert("nonce".to_string(), Value::Null);
4642    m
4643});
4644
4645    Value::Null
4646}
4647
4648    fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4649        let mut market = get_arg(optional_args, 0, Value::Null);
4650        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
4651        let mut since = get_arg(optional_args, 2, Value::Null);
4652        let mut limit = get_arg(optional_args, 3, Value::Null);
4653        let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4654        if (ohlcvs == Value::Null) {
4655            return Value::from(vec![]);
4656        }
4657        let mut results: Value = Value::from(vec![]);
4658        {
4659                        let mut i: Value = Value::Int(0);
4660            let mut __for_first_115: bool = true;
4661            while { if !__for_first_115 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_115 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4662            append_to_array(&mut results, <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]));
4663        }
4664        }
4665        let mut sorted: Value = self.sort_by(results, Value::Int(0), &[]);
4666        return self.filter_by_since_limit(sorted, &[since, limit, Value::Int(0), tail]);
4667
4668    Value::Null
4669}
4670
4671    fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4672        let mut symbols = get_arg(optional_args, 0, Value::Null);
4673        let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4674        // marketIdKey should only be undefined when response is a dictionary.
4675        symbols = self.market_symbols(&[symbols.clone()]);
4676        let mut tiers: Value = Value::Map({
4677            let mut m = indexmap::IndexMap::new();
4678            m
4679        });
4680        let mut symbolsLength: Value = Value::Int(0);
4681        if (symbols != Value::Null) {
4682            symbolsLength = Value::Int(symbols.len() as i64);
4683        }
4684        let mut noSymbols: bool = (symbols == Value::Null) || (symbolsLength.as_f64() == Some(0.0));
4685        if (matches!(&response, Value::Arr(_))) {
4686            {
4687                                let mut i: Value = Value::Int(0);
4688                let mut __for_first_116: bool = true;
4689                while { if !__for_first_116 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_116 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
4690                let mut item: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4691                let mut id: Value = (if (marketIdKey == Value::Null) { Value::Null } else { self.safe_string(item.clone(), marketIdKey.clone(), &[]) });
4692                let mut market: Value = self.safe_market(&[id, Value::Null, Value::Null, Value::Str("swap".into())]);
4693                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4694                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4695                if (contract.as_bool() == Some(true)) && (noSymbols || ((symbols != Value::Null) && self.in_array(symbol.clone(), symbols.clone()).as_bool() == Some(true))) {
4696                    if let Value::Dict(__d) = &mut tiers { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item.clone(), &[market.clone()])); }
4697                }
4698            }
4699            }
4700        }  else {
4701            let mut keys: Value = object_keys(&response);
4702            {
4703                                let mut i: Value = Value::Int(0);
4704                let mut __for_first_117: bool = true;
4705                while { if !__for_first_117 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_117 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
4706                let mut marketId: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4707                let mut item: Value = get_value(&response, &marketId);
4708                let mut item: Value = get_value(&response, &marketId);
4709                let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("swap".into())]);
4710                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4711                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4712                if (contract.as_bool() == Some(true)) && (noSymbols || ((symbols != Value::Null) && self.in_array(symbol.clone(), symbols.clone()).as_bool() == Some(true))) {
4713                    if let Value::Dict(__d) = &mut tiers { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item, &[market])); }
4714                }
4715            }
4716            }
4717        }
4718        return tiers;
4719
4720    Value::Null
4721}
4722
4723    fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4724        let mut symbols = get_arg(optional_args, 0, Value::Null);
4725        let mut reload = get_arg(optional_args, 1, Value::Bool(false));
4726        let mut params = get_arg(optional_args, 2, Value::Map({
4727    let mut m = indexmap::IndexMap::new();
4728    m
4729}));
4730        if (self.has.as_map().and_then(|__m| __m.get("fetchTradingLimits")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTradingLimits")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
4731            if is_true(&reload) || !(matches!(&self.options, Value::Dict(__d) if __d.contains_key("limitsLoaded"))) {
4732                let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4733                let mut symbolsArray: Value = self.require_value(symbols, &[Value::Str("loadTradingLimits() requires a symbols argument".into())]);
4734                let mut markets: Value = self.markets.clone();
4735                if (markets == Value::Null) {
4736                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
4737                }
4738                {
4739                                        let mut i: Value = Value::Int(0);
4740                    let mut __for_first_118: bool = true;
4741                    while { if !__for_first_118 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_118 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&symbolsArray).as_f64().unwrap_or(f64::NAN) } {
4742                    let mut symbol: Value = get_value(&symbolsArray, &i);
4743                    let mut symbol: Value = get_value(&symbolsArray, &i);
4744                    { let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
4745                }
4746                }
4747                { let __be_tmp = self.milliseconds(); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("limitsLoaded".into(), __be_tmp); } }
4748            }
4749        }
4750        return self.markets.clone();
4751
4752    Value::Null
4753} }
4754
4755    fn safe_position(&self, mut position: Value) -> Value {
4756        // simplified version of: /pull/12765/
4757        let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
4758        let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
4759        //
4760        // PERCENTAGE
4761        //
4762        let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
4763        if (percentage == Value::Null) && (unrealizedPnlString != Value::Null) && (initialMarginString != Value::Null) {
4764            // as it was done in all implementations ( aax, btcex, bybit, deribit, gate, kucoinfutures, phemex )
4765            let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".into()));
4766            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("percentage".into(), self.parse_number(percentageString, &[])); }
4767        }
4768        // if contractSize is undefined get from market
4769        let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
4770        let mut symbol: Value = self.safe_string_k(position.clone(), "symbol", &[]);
4771        let mut market: Value = Value::Null;
4772        if (symbol != Value::Null) {
4773            market = self.safe_value(self.markets.clone(), symbol, &[]);
4774        }
4775        if (contractSize == Value::Null) && (market != Value::Null) {
4776            contractSize = self.safe_number_k(market, "contractSize", &[]);
4777            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), contractSize); }
4778        }
4779        return position;
4780
4781    Value::Null
4782}
4783
4784    fn parse_positions(&self, mut positions: Value, optional_args: &[Value]) -> Value {
4785        let mut symbols = get_arg(optional_args, 0, Value::Null);
4786        let mut params = get_arg(optional_args, 1, Value::Map({
4787    let mut m = indexmap::IndexMap::new();
4788    m
4789}));
4790        symbols = self.market_symbols(&[symbols.clone()]);
4791        let mut positionsArray: Value = self.to_array(positions);
4792        let mut result: Value = Value::from(vec![]);
4793        {
4794                        let mut i: Value = Value::Int(0);
4795            let mut __for_first_119: bool = true;
4796            while { if !__for_first_119 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_119 = false; i.as_f64().unwrap_or(f64::NAN) < ((positionsArray.len() as i64) as f64) } {
4797            let mut position: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_position(self, positionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
4798            append_to_array(&mut result, position);
4799        }
4800        }
4801        return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
4802
4803    Value::Null
4804}
4805
4806    fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
4807        // virtual-dispatch (static: DerivedExchange::parse_adl_rank(self, ...))
4808        { let __v = crate::exchange::DerivedExchange::parse_adl_rank(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
4809
4810        let mut market = get_arg(optional_args, 0, Value::Null);
4811        if (info == Value::Null) {
4812            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
4813        }
4814        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
4815
4816    Value::Null
4817}
4818
4819    fn parse_adl_ranks(&self, mut ranks: Value, optional_args: &[Value]) -> Value {
4820        let mut symbols = get_arg(optional_args, 0, Value::Null);
4821        let mut params = get_arg(optional_args, 1, Value::Map({
4822    let mut m = indexmap::IndexMap::new();
4823    m
4824}));
4825        symbols = self.market_symbols(&[symbols.clone()]);
4826        let mut ranksArray: Value = self.to_array(ranks);
4827        let mut result: Value = Value::from(vec![]);
4828        {
4829                        let mut i: Value = Value::Int(0);
4830            let mut __for_first_120: bool = true;
4831            while { if !__for_first_120 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_120 = false; i.as_f64().unwrap_or(f64::NAN) < ((ranksArray.len() as i64) as f64) } {
4832            let mut rank: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, ranksArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
4833            append_to_array(&mut result, rank);
4834        }
4835        }
4836        return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
4837
4838    Value::Null
4839}
4840
4841    fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
4842        let mut params = get_arg(optional_args, 0, Value::Map({
4843    let mut m = indexmap::IndexMap::new();
4844    m
4845}));
4846        let mut accountsArray: Value = self.to_array(accounts);
4847        let mut result: Value = Value::from(vec![]);
4848        {
4849                        let mut i: Value = Value::Int(0);
4850            let mut __for_first_121: bool = true;
4851            while { if !__for_first_121 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_121 = false; i.as_f64().unwrap_or(f64::NAN) < ((accountsArray.len() as i64) as f64) } {
4852            let mut account: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_account(self, accountsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), &[params.clone()]);
4853            append_to_array(&mut result, account);
4854        }
4855        }
4856        return result;
4857
4858    Value::Null
4859}
4860
4861    fn parse_trades_helper(&self, mut isWs: Value, mut trades: Value, optional_args: &[Value]) -> Value {
4862        let mut market = get_arg(optional_args, 0, Value::Null);
4863        let mut since = get_arg(optional_args, 1, Value::Null);
4864        let mut limit = get_arg(optional_args, 2, Value::Null);
4865        let mut params = get_arg(optional_args, 3, Value::Map({
4866    let mut m = indexmap::IndexMap::new();
4867    m
4868}));
4869        let mut tradesArray: Value = self.to_array(trades);
4870        let mut result: Value = Value::from(vec![]);
4871        {
4872                        let mut i: Value = Value::Int(0);
4873            let mut __for_first_122: bool = true;
4874            while { if !__for_first_122 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_122 = false; i.as_f64().unwrap_or(f64::NAN) < ((tradesArray.len() as i64) as f64) } {
4875            let mut parsed: Value = Value::Null;
4876            if is_true(&isWs) {
4877                parsed = self.parse_ws_trade(tradesArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]);
4878            }  else {
4879                parsed = <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, tradesArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]);
4880            }
4881            let mut trade: Value = self.extend(parsed, &[params.clone()]);
4882            append_to_array(&mut result, trade);
4883        }
4884        }
4885        result = self.sort_by2(result.clone(), Value::Str("timestamp".into()), Value::Str("id".into()), &[]);
4886        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
4887        return self.filter_by_symbol_since_limit(result, &[symbol, since, limit]);
4888
4889    Value::Null
4890}
4891
4892    fn parse_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4893        let mut market = get_arg(optional_args, 0, Value::Null);
4894        let mut since = get_arg(optional_args, 1, Value::Null);
4895        let mut limit = get_arg(optional_args, 2, Value::Null);
4896        let mut params = get_arg(optional_args, 3, Value::Map({
4897    let mut m = indexmap::IndexMap::new();
4898    m
4899}));
4900        return self.parse_trades_helper(Value::Bool(false), trades, &[market, since, limit, params]);
4901
4902    Value::Null
4903}
4904
4905    fn parse_ws_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4906        let mut market = get_arg(optional_args, 0, Value::Null);
4907        let mut since = get_arg(optional_args, 1, Value::Null);
4908        let mut limit = get_arg(optional_args, 2, Value::Null);
4909        let mut params = get_arg(optional_args, 3, Value::Map({
4910    let mut m = indexmap::IndexMap::new();
4911    m
4912}));
4913        return self.parse_trades_helper(Value::Bool(true), trades, &[market, since, limit, params]);
4914
4915    Value::Null
4916}
4917
4918    fn parse_transactions(&self, mut transactions: Value, optional_args: &[Value]) -> Value {
4919        let mut currency = get_arg(optional_args, 0, Value::Null);
4920        let mut since = get_arg(optional_args, 1, Value::Null);
4921        let mut limit = get_arg(optional_args, 2, Value::Null);
4922        let mut params = get_arg(optional_args, 3, Value::Map({
4923    let mut m = indexmap::IndexMap::new();
4924    m
4925}));
4926        let mut transactionsArray: Value = self.to_array(transactions);
4927        let mut result: Value = Value::from(vec![]);
4928        {
4929                        let mut i: Value = Value::Int(0);
4930            let mut __for_first_123: bool = true;
4931            while { if !__for_first_123 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_123 = false; i.as_f64().unwrap_or(f64::NAN) < ((transactionsArray.len() as i64) as f64) } {
4932            let mut transaction: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, transactionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]), &[params.clone()]);
4933            append_to_array(&mut result, transaction);
4934        }
4935        }
4936        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
4937        let mut code: Value = (if (currency != Value::Null) { currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null) } else { Value::Null });
4938        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
4939
4940    Value::Null
4941}
4942
4943    fn parse_transfers(&self, mut transfers: Value, optional_args: &[Value]) -> Value {
4944        let mut currency = get_arg(optional_args, 0, Value::Null);
4945        let mut since = get_arg(optional_args, 1, Value::Null);
4946        let mut limit = get_arg(optional_args, 2, Value::Null);
4947        let mut params = get_arg(optional_args, 3, Value::Map({
4948    let mut m = indexmap::IndexMap::new();
4949    m
4950}));
4951        let mut transfersArray: Value = self.to_array(transfers);
4952        let mut result: Value = Value::from(vec![]);
4953        {
4954                        let mut i: Value = Value::Int(0);
4955            let mut __for_first_124: bool = true;
4956            while { if !__for_first_124 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_124 = false; i.as_f64().unwrap_or(f64::NAN) < ((transfersArray.len() as i64) as f64) } {
4957            let mut transfer: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, transfersArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]), &[params.clone()]);
4958            append_to_array(&mut result, transfer);
4959        }
4960        }
4961        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
4962        let mut code: Value = (if (currency != Value::Null) { currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null) } else { Value::Null });
4963        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
4964
4965    Value::Null
4966}
4967
4968    fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
4969        let mut currency = get_arg(optional_args, 0, Value::Null);
4970        let mut since = get_arg(optional_args, 1, Value::Null);
4971        let mut limit = get_arg(optional_args, 2, Value::Null);
4972        let mut params = get_arg(optional_args, 3, Value::Map({
4973    let mut m = indexmap::IndexMap::new();
4974    m
4975}));
4976        let mut result: Value = Value::from(vec![]);
4977        let mut arrayData: Value = self.to_array(data);
4978        {
4979                        let mut i: Value = Value::Int(0);
4980            let mut __for_first_126: bool = true;
4981            while { if !__for_first_126 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_126 = false; i.as_f64().unwrap_or(f64::NAN) < ((arrayData.len() as i64) as f64) } {
4982            let mut itemOrItems: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, arrayData.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]);
4983            if (matches!(&itemOrItems, Value::Arr(_))) {
4984                {
4985                                        let mut j: Value = Value::Int(0);
4986                    let mut __for_first_125: bool = true;
4987                    while { if !__for_first_125 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_125 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&itemOrItems).as_f64().unwrap_or(f64::NAN) } {
4988                    append_to_array(&mut result, self.extend(get_value(&itemOrItems, &j), &[params.clone()]));
4989                }
4990                }
4991            }  else {
4992                append_to_array(&mut result, self.extend(itemOrItems, &[params.clone()]));
4993            }
4994        }
4995        }
4996        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
4997        let mut code: Value = (if (currency != Value::Null) { currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null) } else { Value::Null });
4998        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
4999
5000    Value::Null
5001}
5002
5003    fn nonce(&self) -> Value {
5004        // virtual-dispatch (static: DerivedExchange::nonce(self, ...))
5005        { let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
5006
5007        return self.seconds();
5008
5009    Value::Null
5010}
5011
5012/*
5013 * @method
5014 * @ignore
5015 * @name Exchange#incrementingNonce
5016 * @description returns a strictly-increasing nonce for venues that reject duplicate nonces per signer; the unit is whatever nonce () returns — the base default is seconds, so a venue that does not override nonce () gets a second-resolution counter that drifts ahead of wall clock under load, while venues needing milliseconds override nonce () as hyperliquid does. The counter is per exchange instance, so it narrows the duplicate-nonce race but does not remove it across instances or processes.
5017 * @returns {int} a strictly-increasing nonce in the unit returned by nonce ()
5018 */
5019    fn incrementing_nonce(&mut self) -> Value {
5020        let mut currentNonce: Value = <Self as crate::exchange_generated::ExchangeBase>::nonce(self, );
5021        self.lock_last_nonce(&[]);
5022        let mut lastNonce: Value = self.safe_integer_k(self.options.clone(), "lastNonce", &[Value::Int(0)]);
5023        let mut result: Value = (if (currentNonce.as_f64().unwrap_or(f64::NAN) > lastNonce.as_f64().unwrap_or(f64::NAN)) { currentNonce } else { (match (&(lastNonce), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }) });
5024        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("lastNonce".into(), result.clone()); }
5025        self.unlock_last_nonce(&[]);
5026        return result;
5027
5028    Value::Null
5029}
5030
5031    fn set_headers(&self, mut headers: Value) -> Value {
5032        return headers;
5033
5034    Value::Null
5035}
5036
5037    fn currency_id(&self, mut code: Value) -> Value {
5038        if (code == Value::Null) {
5039            return code;
5040        }
5041        let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5042        if (currency == Value::Null) {
5043            currency = self.safe_currency(code.clone(), &[]);
5044        }
5045        if (currency != Value::Null) {
5046            return currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5047        }
5048        return code;
5049
5050    Value::Null
5051}
5052
5053    fn market_id(&self, mut symbol: Value) -> Value {
5054        let mut market: Value = self.market(symbol.clone());
5055        if (market != Value::Null) {
5056            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5057        }
5058        return symbol;
5059
5060    Value::Null
5061}
5062
5063    fn symbol(&self, mut symbol: Value) -> Value {
5064        if (symbol == Value::Null) {
5065            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" symbol() requires a symbol argument".into()))));
5066        }
5067        let mut market: Value = self.market(symbol.clone());
5068        return self.safe_string_k(market, "symbol", &[symbol]);
5069
5070    Value::Null
5071}
5072
5073/* eslint-disable no-unused-vars */
5074/* eslint-enable no-unused-vars */
5075    fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5076        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5077        let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue]);
5078        if (value != Value::Null) {
5079            params = self.omit(params.clone(), paramName, &[]);
5080        }
5081        return Value::from(vec![value, params]);
5082
5083    Value::Null
5084}
5085
5086/* eslint-disable no-unused-vars */
5087/* eslint-enable no-unused-vars */
5088    fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5089        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5090        let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5091        if (value != Value::Null) {
5092            params = self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]);
5093        }
5094        return Value::from(vec![value, params]);
5095
5096    Value::Null
5097}
5098
5099    fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5100        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5101        let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue]);
5102        if (value != Value::Null) {
5103            params = self.omit(params.clone(), paramName, &[]);
5104        }
5105        return Value::from(vec![value, params]);
5106
5107    Value::Null
5108}
5109
5110    fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5111        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5112        let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5113        if (value != Value::Null) {
5114            params = self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]);
5115        }
5116        return Value::from(vec![value, params]);
5117
5118    Value::Null
5119}
5120
5121    fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5122        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5123        let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue]);
5124        if (value != Value::Null) {
5125            params = self.omit(params.clone(), paramName, &[]);
5126        }
5127        return Value::from(vec![value, params]);
5128
5129    Value::Null
5130}
5131
5132    fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5133        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5134        let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5135        if (value != Value::Null) {
5136            params = self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]);
5137        }
5138        return Value::from(vec![value, params]);
5139
5140    Value::Null
5141}
5142
5143/*
5144 * @param {object} params - extra parameters
5145 * @param {object} request - existing dictionary of request
5146 * @param {string} exchangeSpecificKey - the key for chain id to be set in request
5147 * @param {object} currencyCode - (optional) existing dictionary of request
5148 * @param {boolean} isRequired - (optional) whether that param is required to be present
5149 * @returns {object[]} - returns [request, params] where request is the modified request object and params is the modified params object
5150 */
5151    fn handle_request_network(&self, mut params: Value, mut request: Value, mut exchangeSpecificKey: Value, optional_args: &[Value]) -> Value {
5152        let mut currencyCode = get_arg(optional_args, 0, Value::Null);
5153        let mut isRequired = get_arg(optional_args, 1, Value::Bool(false));
5154        let mut networkCode: Value = Value::Null;
5155        { let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
5156        if (networkCode != Value::Null) {
5157            if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&exchangeSpecificKey), self.network_code_to_id(networkCode, &[currencyCode])); }
5158        }  else if is_true(&isRequired) {
5159            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" - \"network\" param is required for this request".into()))));
5160        }
5161        return Value::from(vec![request, params]);
5162
5163    Value::Null
5164}
5165
5166    fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5167        return Value::from(vec![self.implode_params(path.clone(), params.clone()), self.omit(params, self.extract_params(path), &[])]);
5168
5169    Value::Null
5170}
5171
5172    fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5173        let mut newArray: Value = objects.clone();
5174        if !(matches!(&objects, Value::Arr(_))) {
5175            newArray = self.to_array(objects.clone());
5176        }
5177        let mut results: Value = Value::from(vec![]);
5178        {
5179                        let mut i: Value = Value::Int(0);
5180            let mut __for_first_127: bool = true;
5181            while { if !__for_first_127 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_127 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&newArray).as_f64().unwrap_or(f64::NAN) } {
5182            append_to_array(&mut results, get_value(&get_value(&newArray, &i), &key));
5183        }
5184        }
5185        return results;
5186
5187    Value::Null
5188}
5189
5190    fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5191        let mut marketType = get_arg(optional_args, 0, Value::Null);
5192        let mut subType = get_arg(optional_args, 1, Value::Null);
5193        let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5194        let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5195        let mut filteredMarkets: Value = self.markets.clone();
5196        if (marketType != Value::Null) {
5197            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".into()), marketType, &[]);
5198        }
5199        if (subType != Value::Null) {
5200            self.check_required_argument(Value::Str("getSymbolsForMarketType".into()), subType.clone(), Value::Str("subType".into()), &[Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into()), Value::Str("quanto".into())])]);
5201            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".into()), subType, &[]);
5202        }
5203        let mut activeStatuses: Value = Value::from(vec![]);
5204        if is_true(&symbolWithActiveStatus) {
5205            append_to_array(&mut activeStatuses, Value::Bool(true));
5206        }
5207        if is_true(&symbolWithUnknownStatus) {
5208            append_to_array(&mut activeStatuses, Value::Null);
5209        }
5210        filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".into()), &[activeStatuses, Value::Bool(false)]);
5211        return self.get_list_from_object_values(filteredMarkets, Value::Str("symbol".into()));
5212
5213    Value::Null
5214}
5215
5216    fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5217        let mut values = get_arg(optional_args, 0, Value::Null);
5218        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5219        objects = self.to_array(objects.clone());
5220        // return all of them if no values were passed
5221        if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5222            // return indexed ? this.indexBy (objects, key) : objects;
5223            if is_true(&indexed) {
5224                return self.index_by(objects.clone(), key.clone());
5225            }  else {
5226                return objects;
5227            }
5228        }
5229        let mut results: Value = Value::from(vec![]);
5230        {
5231                        let mut i: Value = Value::Int(0);
5232            let mut __for_first_128: bool = true;
5233            while { if !__for_first_128 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_128 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objects).as_f64().unwrap_or(f64::NAN) } {
5234            if self.in_array(get_value(&get_value(&objects, &i), &key), values.clone()).as_bool() == Some(true) {
5235                append_to_array(&mut results, get_value(&objects, &i));
5236            }
5237        }
5238        }
5239        // return indexed ? this.indexBy (results, key) : results;
5240        if is_true(&indexed) {
5241            return self.index_by(results.clone(), key);
5242        }
5243        return results;
5244
5245    Value::Null
5246}
5247
5248    fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5249        let mut values = get_arg(optional_args, 0, Value::Null);
5250        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5251        objects = self.to_array(objects.clone());
5252        // return all of them if no values were passed
5253        if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5254            // return indexed ? this.indexBy (objects, key) : objects;
5255            if is_true(&indexed) {
5256                return self.index_by(objects.clone(), key.clone());
5257            }  else {
5258                return objects;
5259            }
5260        }
5261        let mut results: Value = Value::from(vec![]);
5262        {
5263                        let mut i: Value = Value::Int(0);
5264            let mut __for_first_129: bool = true;
5265            while { if !__for_first_129 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_129 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objects).as_f64().unwrap_or(f64::NAN) } {
5266            if !(self.in_array(get_value(&get_value(&objects, &i), &key), values.clone()).as_bool() == Some(true)) {
5267                append_to_array(&mut results, get_value(&objects, &i));
5268            }
5269        }
5270        }
5271        // return indexed ? this.indexBy (results, key) : results;
5272        if is_true(&indexed) {
5273            return self.index_by(results.clone(), key);
5274        }
5275        return results;
5276
5277    Value::Null
5278}
5279
5280    fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5281        let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
5282        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5283        let mut params = get_arg(optional_args, 2, Value::Map({
5284    let mut m = indexmap::IndexMap::new();
5285    m
5286}));
5287        let mut headers = get_arg(optional_args, 3, Value::Null);
5288        let mut body = get_arg(optional_args, 4, Value::Null);
5289        let mut config = get_arg(optional_args, 5, Value::Map({
5290    let mut m = indexmap::IndexMap::new();
5291    m
5292}));
5293        if is_true(&self.enableRateLimit) {
5294            let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config]);
5295            self.throttle(&[cost]).await;
5296        }
5297        let mut retries: Value = Value::Int(0);
5298        { let __destr_tmp = self.handle_option_and_params(params.clone(), path.clone(), Value::Str("maxRetriesOnFailure".into()), &[retries.clone()]); retries = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
5299        let mut retryDelay: Value = Value::Int(0);
5300        { let __destr_tmp = self.handle_option_and_params(params.clone(), path.clone(), Value::Str("maxRetriesOnFailureDelay".into()), &[retryDelay.clone()]); retryDelay = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
5301        let mut fetchDataCacheEnabled: bool = self.fetchHistoryCacheSize.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64);
5302        {
5303                        let mut i: Value = Value::Int(0);
5304            let mut __for_first_130: bool = true;
5305            while { if !__for_first_130 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_130 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(retries), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
5306            let mut fetchData: Value = Value::Null;
5307            if fetchDataCacheEnabled {
5308                fetchData = Value::Map({
5309                    let mut m = indexmap::IndexMap::new();
5310                        m.insert("request".to_string(), Value::Null);
5311                        m.insert("response".to_string(), Value::Map({
5312    let mut m = indexmap::IndexMap::new();
5313        m.insert("body".to_string(), Value::Null);
5314    m
5315}));
5316                        m.insert("error".to_string(), Value::Null);
5317                    m
5318                });
5319            }
5320            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5321                self.set_last_rest_request_timestamp();
5322                let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()]);
5323                if (fetchData != Value::Null) {
5324                    add_element_to_object(&mut fetchData, &Value::Str("request".into()), request.clone());
5325                }
5326                self.set_last_request(request.clone());
5327                let mut response: Value = self.fetch(request.as_map().and_then(|__m| __m.get("url")).cloned().unwrap_or(Value::Null), &[request.as_map().and_then(|__m| __m.get("method")).cloned().unwrap_or(Value::Null), request.as_map().and_then(|__m| __m.get("headers")).cloned().unwrap_or(Value::Null), request.as_map().and_then(|__m| __m.get("body")).cloned().unwrap_or(Value::Null)]).await;
5328                if (fetchData != Value::Null) {
5329                    add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".into())), &Value::Str("body".into()), response.clone());
5330                    self.add_fetch_cache(fetchData.clone());
5331                }
5332                return response;
5333             #[allow(unreachable_code)] { Value::Null }})).await;
5334match _try_result { Ok(__try_ok) => { if !matches!(__try_ok, Value::Null) { return __try_ok; } return Value::Null; } Err(_try_err) => { let e: Value = panic_to_value(_try_err); 
5335                if (fetchData != Value::Null) {
5336                    add_element_to_object(&mut fetchData, &Value::Str("error".into()), e.clone());
5337                    self.add_fetch_cache(fetchData);
5338                }
5339                if is_instance(&e, &Value::Str("OperationFailed".into())) {
5340                    if i.as_f64().unwrap_or(f64::NAN) < retries.as_f64().unwrap_or(f64::NAN) {
5341                        if is_true(&self.verbose) {
5342                            let mut index: Value = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
5343                            self.log(Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Request failed with the error: ".into()), to_string_val(&e)).into()), Value::Str(", retrying ".into())).into()), to_string_val(&index)).into()), Value::Str(" of ".into())).into()), to_string_val(&retries)).into()), Value::Str("...".into())).into()));
5344                        }
5345                        if (retryDelay != Value::Null) && (retryDelay.as_f64() != Some(0.0)) {
5346                            self.sleep(retryDelay.clone()).await;
5347                        }
5348                    }  else {
5349                        panic!("{}", e);
5350                    }
5351                }  else {
5352                    panic!("{}", e);
5353                }
5354             } }
5355        }
5356        }
5357        return Value::Null;
5358
5359    Value::Null
5360} }
5361
5362    fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5363        let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
5364        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5365        let mut params = get_arg(optional_args, 2, Value::Map({
5366    let mut m = indexmap::IndexMap::new();
5367    m
5368}));
5369        let mut headers = get_arg(optional_args, 3, Value::Null);
5370        let mut body = get_arg(optional_args, 4, Value::Null);
5371        let mut config = get_arg(optional_args, 5, Value::Map({
5372    let mut m = indexmap::IndexMap::new();
5373    m
5374}));
5375        return self.fetch2(path, &[api, method, params, headers, body, config]).await;
5376
5377    Value::Null
5378} }
5379
5380    fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5381        let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5382        let mut params = get_arg(optional_args, 1, Value::Map({
5383    let mut m = indexmap::IndexMap::new();
5384    m
5385}));
5386        if is_true(&reload) {
5387            { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5388        }  else {
5389            if (self.accounts.clone() != Value::Null) {
5390                return self.accounts.clone();
5391            }  else {
5392                { let __t = self.fetch_accounts(&[params]).await; self.accounts = __t; }
5393            }
5394        }
5395        { let __t = self.index_by(self.accounts.clone(), Value::Str("id".into())); self.accountsById = __t; }
5396        return self.accounts.clone();
5397
5398    Value::Null
5399} }
5400
5401    fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5402        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
5403        let mut since = get_arg(optional_args, 1, Value::Int(0));
5404        let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5405        // given a sorted arrays of trades (recent last) and a timeframe builds an array of OHLCV candles
5406        // note, default limit value (2147483647) is max int32 value
5407        let mut ms: Value = (match (&(self.parse_timeframe(timeframe)), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
5408        let mut ohlcvs: Value = Value::from(vec![]);
5409        let mut i_timestamp: Value = Value::Int(0);
5410        // const open = 1;
5411        let mut i_high: Value = Value::Int(2);
5412        let mut i_low: Value = Value::Int(3);
5413        let mut i_close: Value = Value::Int(4);
5414        let mut i_volume: Value = Value::Int(5);
5415        let mut i_count: Value = Value::Int(6);
5416        let mut tradesLength: Value = Value::Int(trades.len() as i64);
5417        let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5418        let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5419    let mut m = indexmap::IndexMap::new();
5420    m
5421})]);
5422        let mut skipZeroPrices: Value = self.safe_bool_k(options, "skipZeroPrices", &[Value::Bool(true)]);
5423        {
5424                        let mut i: Value = Value::Int(0);
5425            let mut __for_first_131: bool = true;
5426            while { if !__for_first_131 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_131 = false; i.as_f64().unwrap_or(f64::NAN) < oldest.as_f64().unwrap_or(f64::NAN) } {
5427            let mut trade: Value = trades.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5428            let mut ts: Value = trade.as_map().and_then(|__m| __m.get("timestamp")).cloned().unwrap_or(Value::Null);
5429            let mut price: Value = trade.as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null);
5430            if (ts == Value::Null) || (price == Value::Null) {
5431                continue;
5432            }
5433            if ts.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5434                continue;
5435            }
5436            if (ts == Value::Null) {
5437                panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing ts".into()))));
5438            }
5439            let mut openingTime: Value = (match (&(math_floor(&(match ((ts).as_f64(), (ms).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))), &(ms)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }); // shift to the edge of m/h/d (but not M)
5440            if openingTime.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5441                continue;
5442            }
5443            let mut ohlcv_length: Value = Value::Int(ohlcvs.len() as i64);
5444            let mut candle: Value = (match (&(ohlcv_length), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
5445            if (price == Value::Null) {
5446                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() requires a price argument".into()))));
5447            }
5448            if (skipZeroPrices.as_bool() == Some(true)) && !(price.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) && !(price.as_f64().unwrap_or(f64::NAN) < ((0i64) as f64)) {
5449                continue;
5450            }
5451            let mut isFirstCandle: bool = candle.as_f64() == Value::Int(-1).as_f64();
5452            if isFirstCandle || is_greater_than_or_equal(&openingTime, &self.sum(&[get_value(&ohlcvs, &candle).as_array().and_then(|__arr| match &i_timestamp { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), ms.clone()])) {
5453                // moved to a new timeframe -> create a new candle from opening trade
5454                append_to_array(&mut ohlcvs, Value::from(vec![openingTime.clone(), price.clone(), price.clone(), price.clone(), price.clone(), trade.as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null), Value::Int(1)]));
5455            }  else {
5456                // still processing the same timeframe -> update opening trade
5457                let mut prevHigh: Value = get_value(&ohlcvs, &candle).as_array().and_then(|__arr| match &i_high { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5458                let mut prevLow: Value = get_value(&ohlcvs, &candle).as_array().and_then(|__arr| match &i_low { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5459                let mut prevHighValue: Value = (if (prevHigh == Value::Null) { price.clone() } else { prevHigh });
5460                let mut prevLowValue: Value = (if (prevLow == Value::Null) { price.clone() } else { prevLow });
5461                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
5462                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
5463                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price);
5464                { let __be_tmp = self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_volume), trade.as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null)]); add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_volume, __be_tmp); };
5465                { let __be_tmp = self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_count), Value::Int(1)]); add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_count, __be_tmp); };
5466            }
5467        }
5468        }
5469        return ohlcvs;
5470
5471    Value::Null
5472}
5473
5474    fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5475        let mut market = get_arg(optional_args, 0, Value::Null);
5476        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
5477        let mut since = get_arg(optional_args, 2, Value::Null);
5478        let mut limit = get_arg(optional_args, 3, Value::Null);
5479        let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs, &[]);
5480        return self.parse_ohlc_vs(result, &[market, timeframe, since, limit]);
5481
5482    Value::Null
5483}
5484
5485    fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5486        let mut code = get_arg(optional_args, 0, Value::Null);
5487        let mut symbol = get_arg(optional_args, 1, Value::Null);
5488        let mut since = get_arg(optional_args, 2, Value::Null);
5489        let mut limit = get_arg(optional_args, 3, Value::Null);
5490        let mut params = get_arg(optional_args, 4, Value::Map({
5491    let mut m = indexmap::IndexMap::new();
5492    m
5493}));
5494        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowInterest() is not supported yet".into()))));
5495
5496    Value::Null
5497} }
5498
5499    fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5500        // async-virtual: try the derived exchange first
5501        if let Some(__v) = self.dispatch_to_derived("fetch_ledger", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
5502            if !matches!(__v, crate::Value::Null) { return __v; }
5503        }
5504
5505        let mut code = get_arg(optional_args, 0, Value::Null);
5506        let mut since = get_arg(optional_args, 1, Value::Null);
5507        let mut limit = get_arg(optional_args, 2, Value::Null);
5508        let mut params = get_arg(optional_args, 3, Value::Map({
5509    let mut m = indexmap::IndexMap::new();
5510    m
5511}));
5512        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedger() is not supported yet".into()))));
5513
5514    Value::Null
5515} }
5516
5517    fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5518        let mut code = get_arg(optional_args, 0, Value::Null);
5519        let mut params = get_arg(optional_args, 1, Value::Map({
5520    let mut m = indexmap::IndexMap::new();
5521    m
5522}));
5523        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedgerEntry() is not supported yet".into()))));
5524
5525    Value::Null
5526} }
5527
5528    fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5529        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5530        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5531        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5532        let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5533        let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5534        let mut countOrId: Value = self.safe_integer(bidask, countOrIdKey, &[]);
5535        let mut bidAsk: Value = Value::from(vec![price, amount]);
5536        if (countOrId != Value::Null) {
5537            append_to_array(&mut bidAsk, countOrId);
5538        }
5539        return bidAsk;
5540
5541    Value::Null
5542}
5543
5544    fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5545        let mut currency = get_arg(optional_args, 0, Value::Null);
5546        if (currencyId == Value::Null) && (currency != Value::Null) {
5547            return currency;
5548        }
5549        if (currencyId != Value::Null) && (self.currencies_by_id.clone() != Value::Null) && (in_op(&self.currencies_by_id, &currencyId)) && (get_value(&self.currencies_by_id, &currencyId) != Value::Null) {
5550            return get_value(&self.currencies_by_id, &currencyId);
5551        }
5552        let mut code: Value = currencyId.clone();
5553        if (currencyId != Value::Null) {
5554            code = self.common_currency_code(to_upper(&currencyId));
5555        }
5556        return self.safe_currency_structure(Value::Map({
5557    let mut m = indexmap::IndexMap::new();
5558        m.insert("id".to_string(), currencyId);
5559        m.insert("code".to_string(), code);
5560        m.insert("precision".to_string(), Value::Null);
5561    m
5562}));
5563
5564    Value::Null
5565}
5566
5567    fn safe_market(&self, optional_args: &[Value]) -> Value {
5568        let mut marketId = get_arg(optional_args, 0, Value::Null);
5569        let mut market = get_arg(optional_args, 1, Value::Null);
5570        let mut delimiter = get_arg(optional_args, 2, Value::Null);
5571        let mut marketType = get_arg(optional_args, 3, Value::Null);
5572        if (marketId != Value::Null) {
5573            if (self.markets_by_id.clone() != Value::Null) && (in_op(&self.markets_by_id, &marketId)) {
5574                let mut markets: Value = get_value(&self.markets_by_id, &marketId);
5575                let mut numMarkets: Value = get_array_length(&markets);
5576                if is_equal(&numMarkets, &Value::Int(1)) {
5577                    return get_value(&markets, &Value::Int(0));
5578                }  else {
5579                    if (marketType == Value::Null) {
5580                        if (market == Value::Null) {
5581                            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() requires a fourth argument for ".into())).into()), marketId).into()), Value::Str(" to disambiguate between different markets with the same market id".into()))));
5582                        }  else {
5583                            marketType = market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null);
5584                        }
5585                    }
5586                    {
5587                                                let mut i: Value = Value::Int(0);
5588                        let mut __for_first_132: bool = true;
5589                        while { if !__for_first_132 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_132 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
5590                        let mut currentMarket: Value = get_value(&markets, &i);
5591                        let mut currentMarket: Value = get_value(&markets, &i);
5592                        if is_equal(&get_value(&currentMarket, &marketType), &Value::Bool(true)) {
5593                            return currentMarket;
5594                        }
5595                    }
5596                    }
5597                }
5598            }  else if (delimiter != Value::Null) && (delimiter.as_str() != Some("")) {
5599                let mut parts: Value = split(&marketId, &delimiter);
5600                let mut partsLength: f64 = ((parts.len() as i64) as f64);
5601                let mut result: Value = self.safe_market_structure(&[Value::Map({
5602    let mut m = indexmap::IndexMap::new();
5603        m.insert("symbol".to_string(), marketId.clone());
5604        m.insert("marketId".to_string(), marketId.clone());
5605    m
5606})]);
5607                if (result == Value::Null) {
5608                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5609                }
5610                if (partsLength == 2.0) {
5611                    let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
5612                    let mut quoteId: Value = self.safe_string(parts, Value::Int(1), &[]);
5613                    let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
5614                    let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
5615                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("baseId".into(), baseId); }
5616                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quoteId); }
5617                    if (base != Value::Null) {
5618                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("base".into(), base.clone()); }
5619                    }
5620                    if (quote != Value::Null) {
5621                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quote".into(), quote.clone()); }
5622                    }
5623                    if (base != Value::Null) && (quote != Value::Null) {
5624                        add_element_to_object(&mut result, &Value::Str("symbol".into()), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
5625                    }
5626                }
5627                return result;
5628            }
5629        }
5630        if (market != Value::Null) {
5631            return market;
5632        }
5633        let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5634    let mut m = indexmap::IndexMap::new();
5635        m.insert("symbol".to_string(), marketId.clone());
5636        m.insert("marketId".to_string(), marketId);
5637    m
5638})]);
5639        if (emptyMarket == Value::Null) {
5640            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5641        }
5642        return emptyMarket;
5643
5644    Value::Null
5645}
5646
5647    fn market_or_null(&self, optional_args: &[Value]) -> Value {
5648        let mut symbol = get_arg(optional_args, 0, Value::Null);
5649        if (symbol == Value::Null) {
5650            return Value::Null;
5651        }
5652        return self.market(symbol);
5653
5654    Value::Null
5655}
5656
5657    fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5658        let mut error = get_arg(optional_args, 0, Value::Bool(true));
5659        /*
5660         * @ignore
5661         * @method
5662         * @param {boolean} error throw an error that a credential is required if true
5663         * @returns {boolean} true if all required credentials have been set, otherwise false or an error is thrown is param error=true
5664         */
5665        let mut keys: Value = object_keys(&self.requiredCredentials);
5666        {
5667                        let mut i: Value = Value::Int(0);
5668            let mut __for_first_133: bool = true;
5669            while { if !__for_first_133 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_133 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
5670            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5671            let mut credentialValue: Value = self.prop(&key);
5672            let mut credentialMissing: bool = (credentialValue == Value::Null) || (credentialValue == Value::Null) || (is_equal(&credentialValue, &Value::Bool(false))) || (credentialValue.as_str() == Some(""));
5673            if (get_value(&self.requiredCredentials, &key).as_bool() == Some(true)) && credentialMissing {
5674                if is_true(&error) {
5675                    panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" requires \"".into())).into()), key).into()), Value::Str("\" credential".into()))));
5676                }  else {
5677                    return Value::Bool(false);
5678                }
5679            }
5680        }
5681        }
5682        return Value::Bool(true);
5683
5684    Value::Null
5685}
5686
5687    fn oath(&self) -> Value {
5688        if (self.twofa.clone() != Value::Null) {
5689            return totp(self.twofa.clone());
5690        }  else {
5691            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".into()))));
5692        }
5693
5694    Value::Null
5695}
5696
5697    fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5698        // async-virtual: try the derived exchange first
5699        if let Some(__v) = self.dispatch_to_derived("fetch_balance", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
5700            if !matches!(__v, crate::Value::Null) { return __v; }
5701        }
5702
5703        let mut params = get_arg(optional_args, 0, Value::Map({
5704    let mut m = indexmap::IndexMap::new();
5705    m
5706}));
5707        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalance() is not supported yet".into()))));
5708
5709    Value::Null
5710} }
5711
5712    fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5713        let mut params = get_arg(optional_args, 0, Value::Map({
5714    let mut m = indexmap::IndexMap::new();
5715    m
5716}));
5717        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalanceWs() is not supported yet".into()))));
5718
5719    Value::Null
5720} }
5721
5722    fn parse_balance(&self, mut response: Value) -> Value {
5723        // virtual-dispatch (static: DerivedExchange::parse_balance(self, ...))
5724        { let __v = crate::exchange::DerivedExchange::parse_balance(self, response); if !matches!(__v, crate::Value::Null) { return __v; } }
5725
5726        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBalance() is not supported yet".into()))));
5727
5728    Value::Null
5729}
5730
5731    fn watch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5732        let mut params = get_arg(optional_args, 0, Value::Map({
5733    let mut m = indexmap::IndexMap::new();
5734    m
5735}));
5736        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBalance() is not supported yet".into()))));
5737
5738    Value::Null
5739} }
5740
5741    fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5742        let mut params = get_arg(optional_args, 0, Value::Map({
5743    let mut m = indexmap::IndexMap::new();
5744    m
5745}));
5746        let mut balance: Value = self.fetch_balance(&[params]).await;
5747        return get_value(&balance, &part);
5748
5749    Value::Null
5750} }
5751
5752    fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5753        let mut params = get_arg(optional_args, 0, Value::Map({
5754    let mut m = indexmap::IndexMap::new();
5755    m
5756}));
5757        return self.fetch_partial_balance(Value::Str("free".into()), &[params]).await;
5758
5759    Value::Null
5760} }
5761
5762    fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5763        let mut params = get_arg(optional_args, 0, Value::Map({
5764    let mut m = indexmap::IndexMap::new();
5765    m
5766}));
5767        return self.fetch_partial_balance(Value::Str("used".into()), &[params]).await;
5768
5769    Value::Null
5770} }
5771
5772    fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5773        let mut params = get_arg(optional_args, 0, Value::Map({
5774    let mut m = indexmap::IndexMap::new();
5775    m
5776}));
5777        return self.fetch_partial_balance(Value::Str("total".into()), &[params]).await;
5778
5779    Value::Null
5780} }
5781
5782    fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5783        // async-virtual: try the derived exchange first
5784        if let Some(__v) = self.dispatch_to_derived("fetch_status", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
5785            if !matches!(__v, crate::Value::Null) { return __v; }
5786        }
5787
5788        let mut params = get_arg(optional_args, 0, Value::Map({
5789    let mut m = indexmap::IndexMap::new();
5790    m
5791}));
5792        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchStatus() is not supported yet".into()))));
5793
5794    Value::Null
5795} }
5796
5797    fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5798        let mut params = get_arg(optional_args, 0, Value::Map({
5799    let mut m = indexmap::IndexMap::new();
5800    m
5801}));
5802        if (self.has.as_map().and_then(|__m| __m.get("fetchTransactionFees")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchTransactionFees")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
5803            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFee() is not supported yet".into()))));
5804        }
5805        return self.fetch_transaction_fees(&[Value::from(vec![code]), params]).await;
5806
5807    Value::Null
5808} }
5809
5810    fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5811        let mut codes = get_arg(optional_args, 0, Value::Null);
5812        let mut params = get_arg(optional_args, 1, Value::Map({
5813    let mut m = indexmap::IndexMap::new();
5814    m
5815}));
5816        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFees() is not supported yet".into()))));
5817
5818    Value::Null
5819} }
5820
5821    fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5822        // async-virtual: try the derived exchange first
5823        if let Some(__v) = self.dispatch_to_derived("fetch_deposit_withdraw_fees", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
5824            if !matches!(__v, crate::Value::Null) { return __v; }
5825        }
5826
5827        let mut codes = get_arg(optional_args, 0, Value::Null);
5828        let mut params = get_arg(optional_args, 1, Value::Map({
5829    let mut m = indexmap::IndexMap::new();
5830    m
5831}));
5832        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFees() is not supported yet".into()))));
5833
5834    Value::Null
5835} }
5836
5837    fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5838        // async-virtual: try the derived exchange first
5839        if let Some(__v) = self.dispatch_to_derived("fetch_deposit_withdraw_fee", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.extend_from_slice(optional_args); __args }).await {
5840            if !matches!(__v, crate::Value::Null) { return __v; }
5841        }
5842
5843        let mut params = get_arg(optional_args, 0, Value::Map({
5844    let mut m = indexmap::IndexMap::new();
5845    m
5846}));
5847        if (self.has.as_map().and_then(|__m| __m.get("fetchDepositWithdrawFees")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchDepositWithdrawFees")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
5848            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFee() is not supported yet".into()))));
5849        }
5850        let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::from(vec![code.clone()]), params]).await;
5851        return self.safe_value(fees, code, &[]);
5852
5853    Value::Null
5854} }
5855
5856    fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
5857        let mut mapping = get_arg(optional_args, 0, Value::Map({
5858    let mut m = indexmap::IndexMap::new();
5859    m
5860}));
5861        if (in_op(&mapping, &key)) {
5862            return get_value(&mapping, &key);
5863        }  else {
5864            let mut keys: Value = object_keys(&mapping);
5865            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", add(&Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), &key), Value::Str(" does not have a value in mapping".into())).into()), Value::Str(", must be one of ".into())).into()), join(&keys, &Value::Str(", ".into())))));
5866        }
5867
5868    Value::Null
5869}
5870
5871    fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5872        let mut params = get_arg(optional_args, 0, Value::Map({
5873    let mut m = indexmap::IndexMap::new();
5874    m
5875}));
5876        self.load_markets(&[]).await;
5877        if (self.has.as_map().and_then(|__m| __m.get("fetchBorrowRates")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchBorrowRates")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
5878            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() is not supported yet".into()))));
5879        }
5880        let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params]).await;
5881        let mut rate: Value = self.safe_value(borrowRates, code.clone(), &[]);
5882        if (rate == Value::Null) {
5883            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() could not find the borrow rate for currency code ".into())).into()), code)));
5884        }
5885        return rate;
5886
5887    Value::Null
5888} }
5889
5890    fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5891        let mut params = get_arg(optional_args, 0, Value::Map({
5892    let mut m = indexmap::IndexMap::new();
5893    m
5894}));
5895        self.load_markets(&[]).await;
5896        if (self.has.as_map().and_then(|__m| __m.get("fetchBorrowRates")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchBorrowRates")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
5897            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() is not supported yet".into()))));
5898        }
5899        let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params]).await;
5900        let mut rate: Value = self.safe_dict(borrowRates, symbol.clone(), &[]);
5901        if (rate == Value::Null) {
5902            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ".into())).into()), symbol)));
5903        }
5904        return rate;
5905
5906    Value::Null
5907} }
5908
5909/* eslint-disable no-unused-vars */
5910/* eslint-enable no-unused-vars */
5911    fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
5912        let mut message = get_arg(optional_args, 0, Value::Null);
5913        if (value == Value::Null) {
5914            let mut errorMessage: Value = (if (message != Value::Null) { message } else { Value::Str("value is required".into()) });
5915            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), errorMessage)));
5916        }
5917        return value;
5918
5919    Value::Null
5920}
5921
5922/* eslint-disable no-unused-vars */
5923/* eslint-enable no-unused-vars */
5924    fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5925        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5926        // This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
5927        let mut defaultOptionName: Value = Value::Str(format!("{}{}", Value::Str("default".into()), self.capitalize(optionName.clone())).into()); // we also need to check the 'defaultXyzWhatever'
5928        // check if params contain the key
5929        let mut value: Value = self.safe_value2(params.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
5930        if (value != Value::Null) {
5931            params = self.omit(params.clone(), Value::from(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
5932        }  else {
5933            // handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
5934            { let __destr_tmp = self.handle_param_string(params.clone(), Value::Str("callerMethodName".into()), &[methodName.clone()]); methodName = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
5935            // check if exchange has properties for this method
5936            let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), methodName, &[]);
5937            if (exchangeWideMethodOptions != Value::Null) {
5938                // check if the option is defined inside this method's props
5939                value = self.safe_value2(exchangeWideMethodOptions, optionName.clone(), defaultOptionName.clone(), &[]);
5940            }
5941            if (value == Value::Null) {
5942                // if it's still undefined, check if global exchange-wide option exists
5943                value = self.safe_value2(self.options.clone(), optionName, defaultOptionName, &[]);
5944            }
5945            // if it's still undefined, use the default value
5946            value = (if (value != Value::Null) { value.clone() } else { defaultValue });
5947        }
5948        return Value::from(vec![value, params]);
5949
5950    Value::Null
5951}
5952
5953/* eslint-disable no-unused-vars */
5954/* eslint-enable no-unused-vars */
5955    fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
5956        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5957        let mut value: Value = Value::Null;
5958        { let __destr_tmp = self.handle_option_and_params(params.clone(), methodName1.clone(), optionName1, &[]); value = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
5959        if (value != Value::Null) {
5960            // omit optionName2 too from params
5961            params = self.omit(params.clone(), optionName2.clone(), &[]);
5962            return Value::from(vec![value, params.clone()]);
5963        }
5964        // if still undefined, try optionName2
5965        let mut value2: Value = Value::Null;
5966        { let __destr_tmp = self.handle_option_and_params(params.clone(), methodName1, optionName2, &[defaultValue]); value2 = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
5967        return Value::from(vec![value2, params]);
5968
5969    Value::Null
5970}
5971
5972    fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5973        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5974        let mut res: Value = self.handle_option_and_params(Value::Map({
5975    let mut m = indexmap::IndexMap::new();
5976    m
5977}), methodName, optionName, &[defaultValue]);
5978        return self.safe_value(res, Value::Int(0), &[]);
5979
5980    Value::Null
5981}
5982
5983    fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
5984        let mut market = get_arg(optional_args, 0, Value::Null);
5985        let mut params = get_arg(optional_args, 1, Value::Map({
5986    let mut m = indexmap::IndexMap::new();
5987    m
5988}));
5989        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
5990        /*
5991         * @ignore
5992         * @method
5993         * @name exchange#handleMarketTypeAndParams
5994         * @param methodName the method calling handleMarketTypeAndParams
5995         * @param {Market} market
5996         * @param {object} params
5997         * @param {string} [params.type] type assigned by user
5998         * @param {string} [params.defaultType] same as params.type
5999         * @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
6000         * @returns {[string, object]} the market type and params with type and defaultType omitted
6001         */
6002        // type from param
6003        let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6004        if (type_var != Value::Null) {
6005            params = self.omit(params.clone(), Value::from(vec![Value::Str("defaultType".into()), Value::Str("type".into())]), &[]);
6006            return Value::from(vec![type_var, params.clone()]);
6007        }
6008        // type from market
6009        if (market != Value::Null) {
6010            return Value::from(vec![market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), params.clone()]);
6011        }
6012        // type from default-argument
6013        if (defaultValue != Value::Null) {
6014            return Value::from(vec![defaultValue, params.clone()]);
6015        }
6016        let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName, &[]);
6017        if (methodOptions != Value::Null) {
6018            if matches!(&methodOptions, Value::Str(_)) {
6019                return Value::from(vec![methodOptions.clone(), params.clone()]);
6020            }  else {
6021                let mut typeFromMethod: Value = self.safe_string2(methodOptions, Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6022                if (typeFromMethod != Value::Null) {
6023                    return Value::from(vec![typeFromMethod, params.clone()]);
6024                }
6025            }
6026        }
6027        let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[Value::Str("spot".into())]);
6028        return Value::from(vec![defaultType, params]);
6029
6030    Value::Null
6031}
6032
6033    fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6034        let mut market = get_arg(optional_args, 0, Value::Null);
6035        let mut params = get_arg(optional_args, 1, Value::Map({
6036    let mut m = indexmap::IndexMap::new();
6037    m
6038}));
6039        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6040        let mut subType: Value = Value::Null;
6041        // if set in params, it takes precedence
6042        let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".into()), Value::Str("defaultSubType".into()), &[]);
6043        // avoid omitting if it's not present
6044        if (subTypeInParams != Value::Null) {
6045            if (subTypeInParams.as_str() == Some("linear")) || (subTypeInParams.as_str() == Some("inverse")) {
6046                subType = subTypeInParams;
6047            }
6048            params = self.omit(params.clone(), Value::from(vec![Value::Str("subType".into()), Value::Str("defaultSubType".into())]), &[]);
6049        }  else {
6050            // at first, check from market object
6051            if (market != Value::Null) {
6052                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6053                    subType = Value::Str("linear".into());
6054                }  else if (market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6055                    subType = Value::Str("inverse".into());
6056                }
6057            }
6058            // if it was not defined in market object
6059            if (subType == Value::Null) {
6060                let mut values: Value = self.handle_option_and_params(Value::Map({
6061    let mut m = indexmap::IndexMap::new();
6062    m
6063}), methodName, Value::Str("subType".into()), &[defaultValue]); // no need to re-test params here
6064                subType = values.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6065            }
6066        }
6067        return Value::from(vec![subType, params]);
6068
6069    Value::Null
6070}
6071
6072    fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6073        let mut params = get_arg(optional_args, 0, Value::Map({
6074    let mut m = indexmap::IndexMap::new();
6075    m
6076}));
6077        let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6078        return self.handle_option_and_params(params, methodName, Value::Str("marginMode".into()), &[defaultValue]);
6079
6080    Value::Null
6081}
6082
6083    fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6084        if (string == Value::Null) {
6085            return;
6086        }
6087        if (in_op(&exact, &string)) {
6088            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
6089        }
6090}
6091
6092    fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6093        let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string);
6094        if (broadKey != Value::Null) {
6095            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
6096        }
6097}
6098
6099    fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6100        // a helper for matching error strings exactly vs broadly
6101        let mut keys: Value = object_keys(&broad);
6102        {
6103                        let mut i: Value = Value::Int(0);
6104            let mut __for_first_134: bool = true;
6105            while { if !__for_first_134 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_134 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
6106            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
6107            if (string != Value::Null) {
6108                if get_index_of(&string, &key).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
6109                    return key;
6110                }
6111            }
6112        }
6113        }
6114        return Value::Null;
6115
6116    Value::Null
6117}
6118
6119    fn handle_errors(&self, mut statusCode: Value, mut statusText: Value, mut url: Value, mut method: Value, mut responseHeaders: Value, mut responseBody: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
6120        // virtual-dispatch (static: DerivedExchange::handle_errors(self, ...))
6121        { let __v = crate::exchange::DerivedExchange::handle_errors(self, statusCode, statusText, url, method, responseHeaders, responseBody, response, requestHeaders, requestBody); if !matches!(__v, crate::Value::Null) { return __v; } }
6122
6123        return Value::Null;
6124
6125    Value::Null
6126}
6127
6128    fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6129        let mut config = get_arg(optional_args, 0, Value::Map({
6130    let mut m = indexmap::IndexMap::new();
6131    m
6132}));
6133        return self.safe_value_k(config, "cost", &[Value::Int(1)]);
6134
6135    Value::Null
6136}
6137
6138    fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6139        let mut symbols = get_arg(optional_args, 0, Value::Null);
6140        let mut params = get_arg(optional_args, 1, Value::Map({
6141    let mut m = indexmap::IndexMap::new();
6142    m
6143}));
6144        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotTickers() is not supported yet".into()))));
6145
6146    Value::Null
6147} }
6148
6149    fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6150        let mut symbols = get_arg(optional_args, 0, Value::Null);
6151        let mut params = get_arg(optional_args, 1, Value::Map({
6152    let mut m = indexmap::IndexMap::new();
6153    m
6154}));
6155        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractTickers() is not supported yet".into()))));
6156
6157    Value::Null
6158} }
6159
6160    fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6161        let mut symbols = get_arg(optional_args, 0, Value::Null);
6162        let mut limit = get_arg(optional_args, 1, Value::Null);
6163        let mut params = get_arg(optional_args, 2, Value::Map({
6164    let mut m = indexmap::IndexMap::new();
6165    m
6166}));
6167        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBooks() is not supported yet".into()))));
6168
6169    Value::Null
6170} }
6171
6172    fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6173        let mut symbols = get_arg(optional_args, 0, Value::Null);
6174        let mut params = get_arg(optional_args, 1, Value::Map({
6175    let mut m = indexmap::IndexMap::new();
6176    m
6177}));
6178        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTickers() is not supported yet".into()))));
6179
6180    Value::Null
6181} }
6182
6183    fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6184        let mut params = get_arg(optional_args, 0, Value::Map({
6185    let mut m = indexmap::IndexMap::new();
6186    m
6187}));
6188        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRate() is not supported yet".into()))));
6189
6190    Value::Null
6191} }
6192
6193    fn create_twap_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut duration: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6194        let mut params = get_arg(optional_args, 0, Value::Map({
6195    let mut m = indexmap::IndexMap::new();
6196    m
6197}));
6198        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTwapOrder() is not supported yet".into()))));
6199
6200    Value::Null
6201} }
6202
6203    fn create_convert_trade(&mut self, mut id: Value, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6204        let mut amount = get_arg(optional_args, 0, Value::Null);
6205        let mut params = get_arg(optional_args, 1, Value::Map({
6206    let mut m = indexmap::IndexMap::new();
6207    m
6208}));
6209        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() is not supported yet".into()))));
6210
6211    Value::Null
6212} }
6213
6214    fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6215        let mut code = get_arg(optional_args, 0, Value::Null);
6216        let mut params = get_arg(optional_args, 1, Value::Map({
6217    let mut m = indexmap::IndexMap::new();
6218    m
6219}));
6220        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTrade() is not supported yet".into()))));
6221
6222    Value::Null
6223} }
6224
6225    fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6226        let mut code = get_arg(optional_args, 0, Value::Null);
6227        let mut since = get_arg(optional_args, 1, Value::Null);
6228        let mut limit = get_arg(optional_args, 2, Value::Null);
6229        let mut params = get_arg(optional_args, 3, Value::Map({
6230    let mut m = indexmap::IndexMap::new();
6231    m
6232}));
6233        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTradeHistory() is not supported yet".into()))));
6234
6235    Value::Null
6236} }
6237
6238    fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6239        // async-virtual: try the derived exchange first
6240        if let Some(__v) = self.dispatch_to_derived("fetch_position_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
6241            if !matches!(__v, crate::Value::Null) { return __v; }
6242        }
6243
6244        let mut symbol = get_arg(optional_args, 0, Value::Null);
6245        let mut params = get_arg(optional_args, 1, Value::Map({
6246    let mut m = indexmap::IndexMap::new();
6247    m
6248}));
6249        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionMode() is not supported yet".into()))));
6250
6251    Value::Null
6252} }
6253
6254    fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6255        let mut params = get_arg(optional_args, 0, Value::Map({
6256    let mut m = indexmap::IndexMap::new();
6257    m
6258}));
6259        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchADLRank() is not supported yet".into()))));
6260
6261    Value::Null
6262} }
6263
6264    fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6265        // async-virtual: try the derived exchange first
6266        if let Some(__v) = self.dispatch_to_derived("fetch_positions_adl_rank", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
6267            if !matches!(__v, crate::Value::Null) { return __v; }
6268        }
6269
6270        let mut symbols = get_arg(optional_args, 0, Value::Null);
6271        let mut params = get_arg(optional_args, 1, Value::Map({
6272    let mut m = indexmap::IndexMap::new();
6273    m
6274}));
6275        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6276
6277    Value::Null
6278} }
6279
6280    fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6281        // async-virtual: try the derived exchange first
6282        if let Some(__v) = self.dispatch_to_derived("fetch_position_adl_rank", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
6283            if !matches!(__v, crate::Value::Null) { return __v; }
6284        }
6285
6286        let mut params = get_arg(optional_args, 0, Value::Map({
6287    let mut m = indexmap::IndexMap::new();
6288    m
6289}));
6290        if (self.has.as_map().and_then(|__m| __m.get("fetchPositionsADLRank")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchPositionsADLRank")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
6291            self.load_markets(&[]).await;
6292            let mut market: Value = self.market(symbol.clone());
6293            symbol = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
6294            let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::from(vec![symbol.clone()]), params]).await;
6295            let mut rank: Value = self.safe_dict(ranks, Value::Int(0), &[]);
6296            if (rank == Value::Null) {
6297                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() could not find a rank for ".into())).into()), symbol)));
6298            }  else {
6299                return rank;
6300            }
6301        }  else {
6302            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6303        }
6304
6305    Value::Null
6306} }
6307
6308    fn set_take_profit_and_stop_loss_params(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
6309        let mut price = get_arg(optional_args, 0, Value::Null);
6310        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6311        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6312        let mut params = get_arg(optional_args, 3, Value::Map({
6313    let mut m = indexmap::IndexMap::new();
6314    m
6315}));
6316        if (takeProfit == Value::Null) && (stopLoss == Value::Null) {
6317            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".into()))));
6318        }
6319        if (takeProfit != Value::Null) {
6320            add_element_to_object(&mut params, &Value::Str("takeProfit".into()), Value::Map({
6321    let mut m = indexmap::IndexMap::new();
6322        m.insert("triggerPrice".to_string(), takeProfit);
6323    m
6324}));
6325        }
6326        if (stopLoss != Value::Null) {
6327            add_element_to_object(&mut params, &Value::Str("stopLoss".into()), Value::Map({
6328    let mut m = indexmap::IndexMap::new();
6329        m.insert("triggerPrice".to_string(), stopLoss);
6330    m
6331}));
6332        }
6333        let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
6334        let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
6335        let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
6336        let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
6337        let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
6338        let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
6339        let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
6340        let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
6341        if (takeProfitType != Value::Null) {
6342            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("type".into()), takeProfitType);
6343        }
6344        if (takeProfitPriceType != Value::Null) {
6345            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("priceType".into()), takeProfitPriceType);
6346        }
6347        if (takeProfitLimitPrice != Value::Null) {
6348            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("price".into()), self.parse_to_numeric(takeProfitLimitPrice));
6349        }
6350        if (takeProfitAmount != Value::Null) {
6351            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("amount".into()), self.parse_to_numeric(takeProfitAmount));
6352        }
6353        if (stopLossType != Value::Null) {
6354            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("type".into()), stopLossType);
6355        }
6356        if (stopLossPriceType != Value::Null) {
6357            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("priceType".into()), stopLossPriceType);
6358        }
6359        if (stopLossLimitPrice != Value::Null) {
6360            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("price".into()), self.parse_to_numeric(stopLossLimitPrice));
6361        }
6362        if (stopLossAmount != Value::Null) {
6363            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("amount".into()), self.parse_to_numeric(stopLossAmount));
6364        }
6365        params = self.omit(params.clone(), Value::from(vec![Value::Str("takeProfitType".into()), Value::Str("takeProfitPriceType".into()), Value::Str("takeProfitLimitPrice".into()), Value::Str("takeProfitAmount".into()), Value::Str("stopLossType".into()), Value::Str("stopLossPriceType".into()), Value::Str("stopLossLimitPrice".into()), Value::Str("stopLossAmount".into())]), &[]);
6366        return params;
6367
6368    Value::Null
6369}
6370
6371    fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6372        let mut params = get_arg(optional_args, 0, Value::Map({
6373    let mut m = indexmap::IndexMap::new();
6374    m
6375}));
6376        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSpotOrders() is not supported yet".into()))));
6377
6378    Value::Null
6379} }
6380
6381    fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6382        let mut params = get_arg(optional_args, 0, Value::Map({
6383    let mut m = indexmap::IndexMap::new();
6384    m
6385}));
6386        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createContractOrders() is not supported yet".into()))));
6387
6388    Value::Null
6389} }
6390
6391    fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6392        let mut symbol = get_arg(optional_args, 0, Value::Null);
6393        let mut params = get_arg(optional_args, 1, Value::Map({
6394    let mut m = indexmap::IndexMap::new();
6395    m
6396}));
6397        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelSpotOrder() is not supported yet".into()))));
6398
6399    Value::Null
6400} }
6401
6402    fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6403        let mut symbol = get_arg(optional_args, 0, Value::Null);
6404        let mut params = get_arg(optional_args, 1, Value::Map({
6405    let mut m = indexmap::IndexMap::new();
6406    m
6407}));
6408        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelContractOrder() is not supported yet".into()))));
6409
6410    Value::Null
6411} }
6412
6413    fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6414        let mut symbol = get_arg(optional_args, 0, Value::Null);
6415        let mut params = get_arg(optional_args, 1, Value::Map({
6416    let mut m = indexmap::IndexMap::new();
6417    m
6418}));
6419        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllSpotOrders() is not supported yet".into()))));
6420
6421    Value::Null
6422} }
6423
6424    fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6425        let mut symbol = get_arg(optional_args, 0, Value::Null);
6426        let mut params = get_arg(optional_args, 1, Value::Map({
6427    let mut m = indexmap::IndexMap::new();
6428    m
6429}));
6430        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllContractOrders() is not supported yet".into()))));
6431
6432    Value::Null
6433} }
6434
6435    fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6436        let mut params = get_arg(optional_args, 0, Value::Map({
6437    let mut m = indexmap::IndexMap::new();
6438    m
6439}));
6440        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersAfter() is not supported yet".into()))));
6441
6442    Value::Null
6443} }
6444
6445    fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6446        let mut params = get_arg(optional_args, 0, Value::Map({
6447    let mut m = indexmap::IndexMap::new();
6448    m
6449}));
6450        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersForSymbols() is not supported yet".into()))));
6451
6452    Value::Null
6453} }
6454
6455    fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6456        let mut symbol = get_arg(optional_args, 0, Value::Null);
6457        let mut since = get_arg(optional_args, 1, Value::Null);
6458        let mut limit = get_arg(optional_args, 2, Value::Null);
6459        let mut params = get_arg(optional_args, 3, Value::Map({
6460    let mut m = indexmap::IndexMap::new();
6461    m
6462}));
6463        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() is not supported yet".into()))));
6464
6465    Value::Null
6466} }
6467
6468    fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6469        let mut since = get_arg(optional_args, 0, Value::Null);
6470        let mut limit = get_arg(optional_args, 1, Value::Null);
6471        let mut params = get_arg(optional_args, 2, Value::Map({
6472    let mut m = indexmap::IndexMap::new();
6473    m
6474}));
6475        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLiquidations() is not supported yet".into()))));
6476
6477    Value::Null
6478} }
6479
6480    fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6481        let mut params = get_arg(optional_args, 0, Value::Map({
6482    let mut m = indexmap::IndexMap::new();
6483    m
6484}));
6485        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchGreeks() is not supported yet".into()))));
6486
6487    Value::Null
6488} }
6489
6490    fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6491        let mut symbols = get_arg(optional_args, 0, Value::Null);
6492        let mut params = get_arg(optional_args, 1, Value::Map({
6493    let mut m = indexmap::IndexMap::new();
6494    m
6495}));
6496        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAllGreeks() is not supported yet".into()))));
6497
6498    Value::Null
6499} }
6500
6501    fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6502        let mut params = get_arg(optional_args, 0, Value::Map({
6503    let mut m = indexmap::IndexMap::new();
6504    m
6505}));
6506        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOptionChain() is not supported yet".into()))));
6507
6508    Value::Null
6509} }
6510
6511    fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6512        let mut params = get_arg(optional_args, 0, Value::Map({
6513    let mut m = indexmap::IndexMap::new();
6514    m
6515}));
6516        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOption() is not supported yet".into()))));
6517
6518    Value::Null
6519} }
6520
6521    fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6522        let mut amount = get_arg(optional_args, 0, Value::Null);
6523        let mut params = get_arg(optional_args, 1, Value::Map({
6524    let mut m = indexmap::IndexMap::new();
6525    m
6526}));
6527        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertQuote() is not supported yet".into()))));
6528
6529    Value::Null
6530} }
6531
6532    fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6533        // async-virtual: try the derived exchange first
6534        if let Some(__v) = self.dispatch_to_derived("fetch_deposits_withdrawals", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
6535            if !matches!(__v, crate::Value::Null) { return __v; }
6536        }
6537
6538        let mut code = get_arg(optional_args, 0, Value::Null);
6539        let mut since = get_arg(optional_args, 1, Value::Null);
6540        let mut limit = get_arg(optional_args, 2, Value::Null);
6541        let mut params = get_arg(optional_args, 3, Value::Map({
6542    let mut m = indexmap::IndexMap::new();
6543    m
6544}));
6545        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWithdrawals() is not supported yet".into()))));
6546
6547    Value::Null
6548} }
6549
6550    fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6551        // async-virtual: try the derived exchange first
6552        if let Some(__v) = self.dispatch_to_derived("fetch_deposits", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
6553            if !matches!(__v, crate::Value::Null) { return __v; }
6554        }
6555
6556        let mut code = get_arg(optional_args, 0, Value::Null);
6557        let mut since = get_arg(optional_args, 1, Value::Null);
6558        let mut limit = get_arg(optional_args, 2, Value::Null);
6559        let mut params = get_arg(optional_args, 3, Value::Map({
6560    let mut m = indexmap::IndexMap::new();
6561    m
6562}));
6563        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposits() is not supported yet".into()))));
6564
6565    Value::Null
6566} }
6567
6568    fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6569        // async-virtual: try the derived exchange first
6570        if let Some(__v) = self.dispatch_to_derived("fetch_withdrawals", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
6571            if !matches!(__v, crate::Value::Null) { return __v; }
6572        }
6573
6574        let mut code = get_arg(optional_args, 0, Value::Null);
6575        let mut since = get_arg(optional_args, 1, Value::Null);
6576        let mut limit = get_arg(optional_args, 2, Value::Null);
6577        let mut params = get_arg(optional_args, 3, Value::Map({
6578    let mut m = indexmap::IndexMap::new();
6579    m
6580}));
6581        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawals() is not supported yet".into()))));
6582
6583    Value::Null
6584} }
6585
6586    fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6587        let mut code = get_arg(optional_args, 0, Value::Null);
6588        let mut since = get_arg(optional_args, 1, Value::Null);
6589        let mut limit = get_arg(optional_args, 2, Value::Null);
6590        let mut params = get_arg(optional_args, 3, Value::Map({
6591    let mut m = indexmap::IndexMap::new();
6592    m
6593}));
6594        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWs() is not supported yet".into()))));
6595
6596    Value::Null
6597} }
6598
6599    fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6600        let mut code = get_arg(optional_args, 0, Value::Null);
6601        let mut since = get_arg(optional_args, 1, Value::Null);
6602        let mut limit = get_arg(optional_args, 2, Value::Null);
6603        let mut params = get_arg(optional_args, 3, Value::Map({
6604    let mut m = indexmap::IndexMap::new();
6605    m
6606}));
6607        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawalsWs() is not supported yet".into()))));
6608
6609    Value::Null
6610} }
6611
6612    fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6613        // async-virtual: try the derived exchange first
6614        if let Some(__v) = self.dispatch_to_derived("fetch_funding_rate_history", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
6615            if !matches!(__v, crate::Value::Null) { return __v; }
6616        }
6617
6618        let mut symbol = get_arg(optional_args, 0, Value::Null);
6619        let mut since = get_arg(optional_args, 1, Value::Null);
6620        let mut limit = get_arg(optional_args, 2, Value::Null);
6621        let mut params = get_arg(optional_args, 3, Value::Map({
6622    let mut m = indexmap::IndexMap::new();
6623    m
6624}));
6625        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() is not supported yet".into()))));
6626
6627    Value::Null
6628} }
6629
6630    fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6631        let mut symbol = get_arg(optional_args, 0, Value::Null);
6632        let mut since = get_arg(optional_args, 1, Value::Null);
6633        let mut limit = get_arg(optional_args, 2, Value::Null);
6634        let mut params = get_arg(optional_args, 3, Value::Map({
6635    let mut m = indexmap::IndexMap::new();
6636    m
6637}));
6638        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() is not supported yet".into()))));
6639
6640    Value::Null
6641} }
6642
6643    fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
6644        // virtual-dispatch (static: DerivedExchange::parse_last_price(self, ...))
6645        { let __v = crate::exchange::DerivedExchange::parse_last_price(self, price, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
6646
6647        let mut market = get_arg(optional_args, 0, Value::Null);
6648        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLastPrice() is not supported yet".into()))));
6649
6650    Value::Null
6651}
6652
6653    fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6654        // async-virtual: try the derived exchange first
6655        if let Some(__v) = self.dispatch_to_derived("fetch_deposit_address", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.extend_from_slice(optional_args); __args }).await {
6656            if !matches!(__v, crate::Value::Null) { return __v; }
6657        }
6658
6659        let mut params = get_arg(optional_args, 0, Value::Map({
6660    let mut m = indexmap::IndexMap::new();
6661    m
6662}));
6663        if (self.has.as_map().and_then(|__m| __m.get("fetchDepositAddresses")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchDepositAddresses")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
6664            let mut depositAddresses: Value = self.fetch_deposit_addresses(&[Value::from(vec![code.clone()]), params.clone()]).await;
6665            let mut depositAddress: Value = self.safe_value(depositAddresses, code.clone(), &[]);
6666            if (depositAddress == Value::Null) {
6667                panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() could not find a deposit address for ".into())).into()), code).into()), Value::Str(", make sure you have created a corresponding deposit address in your wallet on the exchange website".into()))));
6668            }  else {
6669                return depositAddress;
6670            }
6671        }  else if (self.has.as_map().and_then(|__m| __m.get("fetchDepositAddressesByNetwork")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchDepositAddressesByNetwork")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
6672            let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
6673            params = self.omit(params.clone(), Value::Str("network".into()), &[]);
6674            let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code, &[params]).await;
6675            if (network != Value::Null) {
6676                return self.safe_dict(addressStructures.clone(), network, &[]);
6677            }  else {
6678                let mut keys: Value = object_keys(&addressStructures);
6679                let mut key: Value = keys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6680                return self.safe_dict(addressStructures, key, &[]);
6681            }
6682        }  else {
6683            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() is not supported yet".into()))));
6684        }
6685
6686    Value::Null
6687} }
6688
6689    fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6690        let mut params = get_arg(optional_args, 0, Value::Map({
6691    let mut m = indexmap::IndexMap::new();
6692    m
6693}));
6694        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractDepositAddress() is not supported yet".into()))));
6695
6696    Value::Null
6697} }
6698
6699    fn account(&self) -> Value {
6700        return Value::Map({
6701    let mut m = indexmap::IndexMap::new();
6702        m.insert("free".to_string(), Value::Null);
6703        m.insert("used".to_string(), Value::Null);
6704        m.insert("total".to_string(), Value::Null);
6705    m
6706});
6707
6708    Value::Null
6709}
6710
6711/*
6712 * @ignore
6713 * @method
6714 * @description merges a per-market (isolated margin) account into a flat code-keyed balance dict, summing string fields when the code recurs across markets
6715 * @param {object} result the code-keyed balance dict being built
6716 * @param {string} code unified currency code
6717 * @param {object} account a balance account with string free/used/total/debt
6718 * @returns {object} result — callers MUST reassign (`result = this.mergeBalanceAccount (result, ...)`): PHP arrays are passed by value, so the mutation is not visible through the argument
6719 */
6720    fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
6721        if !(in_op(&result, &code)) {
6722            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
6723            return result;
6724        }
6725        let mut fields: Value = Value::from(vec![Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into()), Value::Str("debt".into())]);
6726        {
6727                        let mut i: Value = Value::Int(0);
6728            let mut __for_first_135: bool = true;
6729            while { if !__for_first_135 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_135 = false; i.as_f64().unwrap_or(f64::NAN) < ((fields.len() as i64) as f64) } {
6730            let mut field: Value = fields.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
6731            let mut current: Value = self.safe_string(result.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), field.clone(), &[]);
6732            let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
6733            if (current == Value::Null) {
6734                add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
6735            }  else if (incoming != Value::Null) {
6736                add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(&current, &incoming));
6737            }
6738        }
6739        }
6740        return result;
6741
6742    Value::Null
6743}
6744
6745    fn common_currency_code(&self, mut code: Value) -> Value {
6746        if !is_true(&self.substituteCommonCurrencyCodes) {
6747            return code;
6748        }
6749        return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
6750
6751    Value::Null
6752}
6753
6754    fn currency(&self, mut code: Value) -> Value {
6755        if (code == Value::Null) {
6756            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currency() requires a code argument".into()))));
6757        }
6758        let mut keys: Value = object_keys(&self.currencies);
6759        let mut numCurrencies: f64 = ((keys.len() as i64) as f64);
6760        if (numCurrencies == 0.0) {
6761            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" currencies not loaded".into()))));
6762        }
6763        if matches!(&code, Value::Str(_)) {
6764            let mut currencies: Value = self.currencies.clone();
6765            let mut currenciesById: Value = self.currencies_by_id.clone();
6766            if (in_op(&currencies, &code)) {
6767                return currencies.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6768            }  else if (currenciesById != Value::Null) && (in_op(&currenciesById, &code)) {
6769                return currenciesById.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6770            }
6771        }
6772        panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have currency code ".into())).into()), code)));
6773
6774    Value::Null
6775}
6776
6777    fn market(&self, mut symbol: Value) -> Value {
6778        if (symbol == Value::Null) {
6779            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" market() requires a symbol argument".into()))));
6780        }
6781        let mut markets: Value = self.markets.clone();
6782        if (markets == Value::Null) {
6783            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
6784        }
6785        let mut marketsById: Value = self.markets_by_id.clone();
6786        if (in_op(&markets, &symbol)) {
6787            return get_value(&markets, &symbol);
6788        }  else if (marketsById != Value::Null) && (in_op(&marketsById, &symbol)) {
6789            let mut marketsList: Value = get_value(&marketsById, &symbol);
6790            let mut marketsList: Value = get_value(&marketsById, &symbol);
6791            let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("defaultSubType".into()), &[Value::Str("spot".into())]);
6792            {
6793                                let mut i: Value = Value::Int(0);
6794                let mut __for_first_136: bool = true;
6795                while { if !__for_first_136 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_136 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&marketsList).as_f64().unwrap_or(f64::NAN) } {
6796                let mut market: Value = get_value(&marketsList, &i);
6797                let mut market: Value = get_value(&marketsList, &i);
6798                if is_equal(&get_value(&market, &defaultType), &Value::Bool(true)) {
6799                    return market;
6800                }
6801            }
6802            }
6803            return get_value(&marketsList, &Value::Int(0));
6804        }  else if (ends_with(&symbol, &Value::Str("-C".into()))) || (ends_with(&symbol, &Value::Str("-P".into()))) || (starts_with(&symbol, &Value::Str("C-".into()))) || (starts_with(&symbol, &Value::Str("P-".into()))) {
6805            return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
6806        }
6807        panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have market symbol ".into())).into()), symbol)));
6808
6809    Value::Null
6810}
6811
6812    fn create_expired_option_market(&self, mut symbol: Value) -> Value {
6813        // virtual-dispatch (static: DerivedExchange::create_expired_option_market(self, ...))
6814        { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol); if !matches!(__v, crate::Value::Null) { return __v; } }
6815
6816        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createExpiredOptionMarket () is not supported yet".into()))));
6817
6818    Value::Null
6819}
6820
6821    fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
6822        let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
6823        let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
6824        let mut leverageSuffixes: Value = Value::from(vec![Value::Str("2L".into()), Value::Str("2S".into()), Value::Str("3L".into()), Value::Str("3S".into()), Value::Str("4L".into()), Value::Str("4S".into()), Value::Str("5L".into()), Value::Str("5S".into()), Value::Str("UP".into()), Value::Str("DOWN".into()), Value::Str("BULL".into()), Value::Str("BEAR".into())]);
6825        {
6826                        let mut i: Value = Value::Int(0);
6827            let mut __for_first_137: bool = true;
6828            while { if !__for_first_137 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_137 = false; i.as_f64().unwrap_or(f64::NAN) < ((leverageSuffixes.len() as i64) as f64) } {
6829            let mut leverageSuffix: Value = leverageSuffixes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
6830            let mut endsWithSuffix: bool = ends_with(&currencyCode, &leverageSuffix);
6831            if endsWithSuffix {
6832                if !is_true(&checkBaseCoin) {
6833                    return Value::Bool(true);
6834                }  else {
6835                    // check if base currency is inside dict
6836                    let mut baseCurrencyCode: Value = replace_str(&currencyCode, &leverageSuffix, &Value::Str("".into()));
6837                    if (existingCurrencies != Value::Null) && (in_op(&existingCurrencies, &baseCurrencyCode)) {
6838                        return Value::Bool(true);
6839                    }
6840                }
6841            }
6842        }
6843        }
6844        return Value::Bool(false);
6845
6846    Value::Null
6847}
6848
6849    fn handle_withdraw_tag_and_params(&self, mut tag: Value, mut params: Value) -> Value {
6850        if is_true(&self.is_dictionary(tag.clone())) {
6851            params = self.extend(tag.clone(), &[params.clone()]);
6852            tag = Value::Null;
6853        }
6854        if (tag == Value::Null) {
6855            tag = self.safe_string_k(params.clone(), "tag", &[]);
6856            if (tag != Value::Null) {
6857                params = self.omit(params.clone(), Value::Str("tag".into()), &[]);
6858            }
6859        }
6860        return Value::from(vec![tag, params]);
6861
6862    Value::Null
6863}
6864
6865    fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
6866        if (cost == Value::Null) {
6867            return Value::Null;
6868        }
6869        let mut market: Value = self.market(symbol);
6870        return self.decimal_to_precision(cost, Value::Int(crate::runtime::TRUNCATE), self.safe_string2(market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null), Value::Str("cost".into()), Value::Str("price".into()), &[]), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6871
6872    Value::Null
6873}
6874
6875    fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
6876        if (price == Value::Null) {
6877            return Value::Null;
6878        }
6879        let mut market: Value = self.market(symbol);
6880        let mut result: Value = self.decimal_to_precision(price, Value::Int(crate::runtime::ROUND), market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6881        if (result.as_str() == Some("0")) {
6882            panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" price of ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" must be greater than minimum price precision of ".into())).into()), self.number_to_string(market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null)))));
6883        }
6884        return result;
6885
6886    Value::Null
6887}
6888
6889    fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
6890        if (amount == Value::Null) {
6891            return Value::Null;
6892        }
6893        let mut market: Value = self.market(symbol);
6894        let mut result: Value = self.decimal_to_precision(amount, Value::Int(crate::runtime::TRUNCATE), market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6895        if (result.as_str() == Some("0")) {
6896            panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" amount of ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" must be greater than minimum amount precision of ".into())).into()), self.number_to_string(market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null)))));
6897        }
6898        return result;
6899
6900    Value::Null
6901}
6902
6903    fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
6904        if (fee == Value::Null) {
6905            return Value::Null;
6906        }
6907        let mut market: Value = self.market(symbol);
6908        return self.decimal_to_precision(fee, Value::Int(crate::runtime::ROUND), market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6909
6910    Value::Null
6911}
6912
6913    fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
6914        let mut networkCode = get_arg(optional_args, 0, Value::Null);
6915        if (code == Value::Null) {
6916            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currencyToPrecision() requires a code argument".into()))));
6917        }
6918        let mut currency: Value = get_value(&self.currencies, &code);
6919        let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
6920        if (networkCode != Value::Null) {
6921            let mut networks: Value = self.safe_dict_k(currency, "networks", &[Value::Map({
6922    let mut m = indexmap::IndexMap::new();
6923    m
6924})]);
6925            let mut networkItem: Value = self.safe_dict(networks, networkCode, &[Value::Map({
6926    let mut m = indexmap::IndexMap::new();
6927    m
6928})]);
6929            precision = self.safe_value_k(networkItem, "precision", &[precision.clone()]);
6930        }
6931        if (precision == Value::Null) {
6932            return self.force_string(fee.clone());
6933        }  else {
6934            let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
6935            return self.decimal_to_precision(fee, roundingMode, precision, &[self.precisionMode.clone(), self.paddingMode.clone()]);
6936        }
6937
6938    Value::Null
6939}
6940
6941    fn force_string(&self, mut value: Value) -> Value {
6942        if !matches!(&value, Value::Str(_)) {
6943            return self.number_to_string(value.clone());
6944        }
6945        return value;
6946
6947    Value::Null
6948}
6949
6950    fn is_tick_precision(&self) -> Value {
6951        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64());
6952
6953    Value::Null
6954}
6955
6956    fn is_decimal_precision(&self) -> Value {
6957        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::DECIMAL_PLACES).as_f64());
6958
6959    Value::Null
6960}
6961
6962    fn is_significant_precision(&self) -> Value {
6963        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::SIGNIFICANT_DIGITS).as_f64());
6964
6965    Value::Null
6966}
6967
6968    fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
6969        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
6970        let mut value: Value = self.safe_string(obj, key, &[]);
6971        return self.parse_number(value, &[defaultNumber]);
6972
6973    Value::Null
6974}
6975
6976    fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
6977        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
6978        let mut value: Value = self.safe_string_n(obj, arr, &[]);
6979        return self.parse_number(value, &[defaultNumber]);
6980
6981    Value::Null
6982}
6983
6984    fn parse_precision(&self, optional_args: &[Value]) -> Value {
6985        let mut precision = get_arg(optional_args, 0, Value::Null);
6986        /*
6987         * @ignore
6988         * @method
6989         * @param {string} precision The number of digits to the right of the decimal
6990         * @returns {string} a string number equal to 1e-precision
6991         */
6992        if (precision == Value::Null) {
6993            return Value::Null;
6994        }
6995        let mut precisionNumber: Value = (match &precision { Value::Str(__parse_s) => __parse_s.trim().parse::<i64>().map(Value::Int).unwrap_or(Value::Null), Value::Int(__parse_n) => Value::Int(*__parse_n), Value::Float(__parse_f) => Value::Int(*__parse_f as i64), _ => Value::Null });
6996        if (precisionNumber.as_f64() == Some(0.0)) {
6997            return Value::Str("1".into());
6998        }
6999        if precisionNumber.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
7000            let mut parsedPrecision: Value = Value::Str("0.".into());
7001            {
7002                                let mut i: Value = Value::Int(0);
7003                let mut __for_first_138: bool = true;
7004                while { if !__for_first_138 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_138 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(precisionNumber), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7005                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7006            }
7007            }
7008            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("1".into())).into());
7009        }  else {
7010            let mut parsedPrecision: Value = Value::Str("1".into());
7011            {
7012                                let mut i: Value = Value::Int(0);
7013                let mut __for_first_139: bool = true;
7014                while { if !__for_first_139 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_139 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&((match (&(precisionNumber), &(Value::Int(-1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7015                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7016            }
7017            }
7018            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7019        }
7020
7021    Value::Null
7022}
7023
7024    fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7025        /*
7026         * @ignore
7027         * @method
7028         * @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
7029         * @param {string} precision The number of digits to the right of the decimal
7030         * @returns {string} a string number equal to 1e-precision
7031         */
7032        if (precision == Value::Null) {
7033            return Value::Null;
7034        }
7035        if is_true(&crate::precise::Precise::stringGe(&precision, &Value::Str("0".into()))) {
7036            return self.parse_precision(&[precision.clone()]);
7037        }  else {
7038            let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7039            if (positivePrecisionString == Value::Null) {
7040                return Value::Null;
7041            }
7042            let mut positivePrecision: Value = (match &positivePrecisionString { Value::Str(__parse_s) => __parse_s.trim().parse::<i64>().map(Value::Int).unwrap_or(Value::Null), Value::Int(__parse_n) => Value::Int(*__parse_n), Value::Float(__parse_f) => Value::Int(*__parse_f as i64), _ => Value::Null });
7043            let mut parsedPrecision: Value = Value::Str("1".into());
7044            {
7045                                let mut i: Value = Value::Int(0);
7046                let mut __for_first_140: bool = true;
7047                while { if !__for_first_140 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_140 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(positivePrecision), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7048                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7049            }
7050            }
7051            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7052        }
7053}
7054
7055    fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7056        let mut params = get_arg(optional_args, 0, Value::Map({
7057    let mut m = indexmap::IndexMap::new();
7058    m
7059}));
7060        let mut serverTime: Value = self.fetch_time(&[params]).await;
7061        let mut after: Value = self.milliseconds();
7062        if (serverTime == Value::Null) {
7063            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" loadTimeDifference() missing serverTime".into()))));
7064        }
7065        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("timeDifference".into(), (match (&(after), &(serverTime)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
7066        return self.options.as_map().and_then(|__m| __m.get("timeDifference")).cloned().unwrap_or(Value::Null);
7067
7068    Value::Null
7069} }
7070
7071    fn implode_hostname(&self, mut url: Value) -> Value {
7072        return self.implode_params(url, Value::Map({
7073    let mut m = indexmap::IndexMap::new();
7074        m.insert("hostname".to_string(), self.hostname.clone());
7075    m
7076}));
7077
7078    Value::Null
7079}
7080
7081    fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7082        // async-virtual: try the derived exchange first
7083        if let Some(__v) = self.dispatch_to_derived("fetch_market_leverage_tiers", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
7084            if !matches!(__v, crate::Value::Null) { return __v; }
7085        }
7086
7087        let mut params = get_arg(optional_args, 0, Value::Map({
7088    let mut m = indexmap::IndexMap::new();
7089    m
7090}));
7091        if (self.has.as_map().and_then(|__m| __m.get("fetchLeverageTiers")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchLeverageTiers")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
7092            let mut market: Value = self.market(symbol.clone());
7093            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7094                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() supports contract markets only".into()))));
7095            }
7096            let mut tiers: Value = self.fetch_leverage_tiers(&[Value::from(vec![symbol.clone()])]).await;
7097            return self.safe_value(tiers, symbol, &[]);
7098        }  else {
7099            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() is not supported yet".into()))));
7100        }
7101
7102    Value::Null
7103} }
7104
7105    fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7106        let mut params = get_arg(optional_args, 0, Value::Map({
7107    let mut m = indexmap::IndexMap::new();
7108    m
7109}));
7110        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSubAccount() is not supported yet".into()))));
7111
7112    Value::Null
7113} }
7114
7115    fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7116        let mut currency = get_arg(optional_args, 0, Value::Null);
7117        currency = self.safe_currency(currencyId, &[currency.clone()]);
7118        return currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
7119
7120    Value::Null
7121}
7122
7123    fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7124        let mut symbol = get_arg(optional_args, 0, Value::Null);
7125        let mut since = get_arg(optional_args, 1, Value::Null);
7126        let mut limit = get_arg(optional_args, 2, Value::Null);
7127        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7128        return self.filter_by_value_since_limit(array, Value::Str("symbol".into()), &[symbol, since, limit, Value::Str("timestamp".into()), tail]);
7129
7130    Value::Null
7131}
7132
7133    fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7134        let mut code = get_arg(optional_args, 0, Value::Null);
7135        let mut since = get_arg(optional_args, 1, Value::Null);
7136        let mut limit = get_arg(optional_args, 2, Value::Null);
7137        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7138        return self.filter_by_value_since_limit(array, Value::Str("currency".into()), &[code, since, limit, Value::Str("timestamp".into()), tail]);
7139
7140    Value::Null
7141}
7142
7143    fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7144        let mut symbols = get_arg(optional_args, 0, Value::Null);
7145        let mut since = get_arg(optional_args, 1, Value::Null);
7146        let mut limit = get_arg(optional_args, 2, Value::Null);
7147        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7148        let mut result: Value = self.filter_by_array(array, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
7149        return self.filter_by_since_limit(result, &[since, limit, Value::Str("timestamp".into()), tail]);
7150
7151    Value::Null
7152}
7153
7154    fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7155        let mut symbols = get_arg(optional_args, 0, Value::Null);
7156        let mut params = get_arg(optional_args, 1, Value::Map({
7157    let mut m = indexmap::IndexMap::new();
7158    m
7159}));
7160        //
7161        // the value of tickers is either a dict or a list
7162        //
7163        // dict
7164        //
7165        //     {
7166        //         'marketId1': { ... },
7167        //         'marketId2': { ... },
7168        //         ...
7169        //     }
7170        //
7171        // list
7172        //
7173        //     [
7174        //         { 'market': 'marketId1', ... },
7175        //         { 'market': 'marketId2', ... },
7176        //         ...
7177        //     ]
7178        //
7179        let mut results: Value = Value::from(vec![]);
7180        if (matches!(&pricesData, Value::Arr(_))) {
7181            {
7182                                let mut i: Value = Value::Int(0);
7183                let mut __for_first_141: bool = true;
7184                while { if !__for_first_141 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_141 = false; i.as_f64().unwrap_or(f64::NAN) < ((pricesData.len() as i64) as f64) } {
7185                let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, pricesData.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
7186                append_to_array(&mut results, priceData.clone());
7187            }
7188            }
7189        }  else {
7190            let mut marketIds: Value = object_keys(&pricesData);
7191            {
7192                                let mut i: Value = Value::Int(0);
7193                let mut __for_first_142: bool = true;
7194                while { if !__for_first_142 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_142 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
7195                let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
7196                let mut market: Value = self.safe_market(&[marketId.clone()]);
7197                let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market]), &[params.clone()]);
7198                append_to_array(&mut results, priceData);
7199            }
7200            }
7201        }
7202        symbols = self.market_symbols(&[symbols.clone()]);
7203        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbols]);
7204
7205    Value::Null
7206}
7207
7208    fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7209        let mut symbols = get_arg(optional_args, 0, Value::Null);
7210        let mut params = get_arg(optional_args, 1, Value::Map({
7211    let mut m = indexmap::IndexMap::new();
7212    m
7213}));
7214        //
7215        // the value of tickers is either a dict or a list
7216        //
7217        //
7218        // dict
7219        //
7220        //     {
7221        //         'marketId1': { ... },
7222        //         'marketId2': { ... },
7223        //         'marketId3': { ... },
7224        //         ...
7225        //     }
7226        //
7227        // list
7228        //
7229        //     [
7230        //         { 'market': 'marketId1', ... },
7231        //         { 'market': 'marketId2', ... },
7232        //         { 'market': 'marketId3', ... },
7233        //         ...
7234        //     ]
7235        //
7236        let mut results: Value = Value::from(vec![]);
7237        if (matches!(&tickers, Value::Arr(_))) {
7238            {
7239                                let mut i: Value = Value::Int(0);
7240                let mut __for_first_143: bool = true;
7241                while { if !__for_first_143 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_143 = false; i.as_f64().unwrap_or(f64::NAN) < ((tickers.len() as i64) as f64) } {
7242                let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, tickers.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]);
7243                let mut ticker: Value = self.extend(parsedTicker, &[params.clone()]);
7244                append_to_array(&mut results, ticker.clone());
7245            }
7246            }
7247        }  else {
7248            let mut marketIds: Value = object_keys(&tickers);
7249            {
7250                                let mut i: Value = Value::Int(0);
7251                let mut __for_first_144: bool = true;
7252                while { if !__for_first_144 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_144 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
7253                let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
7254                let mut market: Value = self.safe_market(&[marketId.clone()]);
7255                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market]);
7256                let mut ticker: Value = self.extend(parsed, &[params.clone()]);
7257                append_to_array(&mut results, ticker);
7258            }
7259            }
7260        }
7261        symbols = self.market_symbols(&[symbols.clone()]);
7262        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbols]);
7263
7264    Value::Null
7265}
7266
7267    fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7268        let mut codes = get_arg(optional_args, 0, Value::Null);
7269        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7270        let mut params = get_arg(optional_args, 2, Value::Map({
7271    let mut m = indexmap::IndexMap::new();
7272    m
7273}));
7274        let mut result: Value = Value::from(vec![]);
7275        {
7276                        let mut i: Value = Value::Int(0);
7277            let mut __for_first_145: bool = true;
7278            while { if !__for_first_145 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_145 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&addresses).as_f64().unwrap_or(f64::NAN) } {
7279            let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7280            append_to_array(&mut result, address);
7281        }
7282        }
7283        if (codes != Value::Null) {
7284            result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[codes, Value::Bool(false)]);
7285        }
7286        if is_true(&indexed) {
7287            result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[Value::Null, indexed.clone()]);
7288        }
7289        return result;
7290
7291    Value::Null
7292}
7293
7294    fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7295        let mut market = get_arg(optional_args, 0, Value::Null);
7296        let mut interests: Value = Value::from(vec![]);
7297        {
7298                        let mut i: Value = Value::Int(0);
7299            let mut __for_first_146: bool = true;
7300            while { if !__for_first_146 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_146 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7301            let mut row: Value = get_value(&response, &i);
7302            let mut row: Value = get_value(&response, &i);
7303            append_to_array(&mut interests, <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row, &[market.clone()]));
7304        }
7305        }
7306        return interests;
7307
7308    Value::Null
7309}
7310
7311    fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7312        // virtual-dispatch (static: DerivedExchange::parse_borrow_rate(self, ...))
7313        { let __v = crate::exchange::DerivedExchange::parse_borrow_rate(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7314
7315        let mut currency = get_arg(optional_args, 0, Value::Null);
7316        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowRate() is not supported yet".into()))));
7317
7318    Value::Null
7319}
7320
7321    fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7322        let mut result: Value = Value::from(vec![]);
7323        {
7324                        let mut i: Value = Value::Int(0);
7325            let mut __for_first_147: bool = true;
7326            while { if !__for_first_147 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_147 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7327            let mut item: Value = get_value(&response, &i);
7328            let mut item: Value = get_value(&response, &i);
7329            let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item, &[]);
7330            append_to_array(&mut result, borrowRate);
7331        }
7332        }
7333        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
7334        return self.filter_by_currency_since_limit(sorted, &[code, since, limit]);
7335
7336    Value::Null
7337}
7338
7339    fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7340        let mut result: Value = Value::Map({
7341            let mut m = indexmap::IndexMap::new();
7342            m
7343        });
7344        {
7345                        let mut i: Value = Value::Int(0);
7346            let mut __for_first_148: bool = true;
7347            while { if !__for_first_148 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_148 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&info).as_f64().unwrap_or(f64::NAN) } {
7348            let mut item: Value = get_value(&info, &i);
7349            let mut item: Value = get_value(&info, &i);
7350            let mut borrowRate: Value = self.parse_isolated_borrow_rate(item, &[]);
7351            let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
7352            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), borrowRate); }
7353        }
7354        }
7355        return result;
7356
7357    Value::Null
7358}
7359
7360    fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7361        let mut market = get_arg(optional_args, 0, Value::Null);
7362        let mut since = get_arg(optional_args, 1, Value::Null);
7363        let mut limit = get_arg(optional_args, 2, Value::Null);
7364        let mut rates: Value = Value::from(vec![]);
7365        {
7366                        let mut i: Value = Value::Int(0);
7367            let mut __for_first_149: bool = true;
7368            while { if !__for_first_149 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_149 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7369            let mut entry: Value = get_value(&response, &i);
7370            let mut entry: Value = get_value(&response, &i);
7371            append_to_array(&mut rates, <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry, &[market.clone()]));
7372        }
7373        }
7374        let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7375        let mut symbol: Value = (if (market == Value::Null) { Value::Null } else { market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) });
7376        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7377
7378    Value::Null
7379}
7380
7381    fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7382        let mut market = get_arg(optional_args, 0, Value::Null);
7383        let mut delimiter = get_arg(optional_args, 1, Value::Null);
7384        let mut marketType = get_arg(optional_args, 2, Value::Null);
7385        market = self.safe_market(&[marketId, market.clone(), delimiter, marketType]);
7386        return market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7387
7388    Value::Null
7389}
7390
7391    fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7392        // virtual-dispatch (static: DerivedExchange::parse_funding_rate(self, ...))
7393        { let __v = crate::exchange::DerivedExchange::parse_funding_rate(self, contract, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7394
7395        let mut market = get_arg(optional_args, 0, Value::Null);
7396        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRate() is not supported yet".into()))));
7397
7398    Value::Null
7399}
7400
7401    fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7402        let mut symbols = get_arg(optional_args, 0, Value::Null);
7403        let mut fundingRates: Value = Value::Map({
7404            let mut m = indexmap::IndexMap::new();
7405            m
7406        });
7407        {
7408                        let mut i: Value = Value::Int(0);
7409            let mut __for_first_150: bool = true;
7410            while { if !__for_first_150 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_150 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7411            let mut entry: Value = get_value(&response, &i);
7412            let mut entry: Value = get_value(&response, &i);
7413            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry, &[]);
7414            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7415                add_element_to_object(&mut fundingRates, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7416            }
7417        }
7418        }
7419        return self.filter_by_array(fundingRates, Value::Str("symbol".into()), &[symbols]);
7420
7421    Value::Null
7422}
7423
7424    fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7425        let mut market = get_arg(optional_args, 0, Value::Null);
7426        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLongShortRatio() is not supported yet".into()))));
7427
7428    Value::Null
7429}
7430
7431    fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7432        let mut market = get_arg(optional_args, 0, Value::Null);
7433        let mut since = get_arg(optional_args, 1, Value::Null);
7434        let mut limit = get_arg(optional_args, 2, Value::Null);
7435        let mut rates: Value = Value::from(vec![]);
7436        {
7437                        let mut i: Value = Value::Int(0);
7438            let mut __for_first_151: bool = true;
7439            while { if !__for_first_151 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_151 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7440            let mut entry: Value = get_value(&response, &i);
7441            let mut entry: Value = get_value(&response, &i);
7442            append_to_array(&mut rates, self.parse_long_short_ratio(entry, &[market.clone()]));
7443        }
7444        }
7445        let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7446        let mut symbol: Value = (if (market == Value::Null) { Value::Null } else { market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) });
7447        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7448
7449    Value::Null
7450}
7451
7452    fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7453        let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7454        //
7455        let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
7456        let mut triggerPriceStr: Value = Value::Null;
7457        let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7458        let mut stopLossPriceStr: Value = Value::Null;
7459        let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7460        let mut takeProfitPriceStr: Value = Value::Null;
7461        //
7462        if (triggerPrice != Value::Null) {
7463            if is_true(&omitParams) {
7464                params = self.omit(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stopPrice".into())]), &[]);
7465            }
7466            triggerPriceStr = self.price_to_precision(symbol.clone(), (match &triggerPrice { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null }));
7467        }
7468        if (stopLossPrice != Value::Null) {
7469            if is_true(&omitParams) {
7470                params = self.omit(params.clone(), Value::Str("stopLossPrice".into()), &[]);
7471            }
7472            stopLossPriceStr = self.price_to_precision(symbol.clone(), (match &stopLossPrice { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null }));
7473        }
7474        if (takeProfitPrice != Value::Null) {
7475            if is_true(&omitParams) {
7476                params = self.omit(params.clone(), Value::Str("takeProfitPrice".into()), &[]);
7477            }
7478            takeProfitPriceStr = self.price_to_precision(symbol, (match &takeProfitPrice { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null }));
7479        }
7480        return Value::from(vec![triggerPriceStr, stopLossPriceStr, takeProfitPriceStr, params]);
7481
7482    Value::Null
7483}
7484
7485    fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7486        let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7487        let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7488        /*
7489         * @ignore
7490         * @method
7491         * @returns {[string, object]} the trigger-direction value and omited params
7492         */
7493        let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7494        let mut exchangeSpecificDefined: bool = (exchangeSpecificKey != Value::Null) && (in_op(&params, &exchangeSpecificKey));
7495        if (triggerDirection != Value::Null) {
7496            params = self.omit(params.clone(), Value::Str("triggerDirection".into()), &[]);
7497        }
7498        // throw exception if:
7499        // A) if provided value is not unified (support old "up/down" strings too)
7500        // B) if exchange specific "trigger direction key" (eg. "stopPriceSide") was not provided
7501        if !(self.in_array(triggerDirection.clone(), Value::from(vec![Value::Str("ascending".into()), Value::Str("descending".into()), Value::Str("up".into()), Value::Str("down".into()), Value::Str("above".into()), Value::Str("below".into())])).as_bool() == Some(true)) && !exchangeSpecificDefined && !is_true(&allowEmpty) {
7502            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() : trigger orders require params[\"triggerDirection\"] to be either \"ascending\" or \"descending\"".into()))));
7503        }
7504        // if old format was provided, overwrite to new
7505        if (triggerDirection.as_str() == Some("up")) || (triggerDirection.as_str() == Some("above")) {
7506            triggerDirection = Value::Str("ascending".into());
7507        }  else if (triggerDirection.as_str() == Some("down")) || (triggerDirection.as_str() == Some("below")) {
7508            triggerDirection = Value::Str("descending".into());
7509        }
7510        return Value::from(vec![triggerDirection, params]);
7511
7512    Value::Null
7513}
7514
7515    fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7516        let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[]);
7517        if (isTrigger.as_bool() == Some(true)) {
7518            params = self.omit(params.clone(), Value::from(vec![Value::Str("trigger".into()), Value::Str("stop".into())]), &[]);
7519        }
7520        return Value::from(vec![isTrigger, params]);
7521
7522    Value::Null
7523}
7524
7525    fn is_trigger_order(&self, mut params: Value) -> Value {
7526        return self.handle_trigger_and_params(params);
7527
7528    Value::Null
7529}
7530
7531    fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7532        let mut params = get_arg(optional_args, 0, Value::Map({
7533    let mut m = indexmap::IndexMap::new();
7534    m
7535}));
7536        /*
7537         * @ignore
7538         * @method
7539         * @param {string} type Order type
7540         * @param {boolean} exchangeSpecificParam exchange specific postOnly
7541         * @param {object} [params] exchange specific params
7542         * @returns {boolean} true if a post only order, false otherwise
7543         */
7544        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7545        let mut postOnly: Value = self.safe_bool2(params, Value::Str("postOnly".into()), Value::Str("post_only".into()), &[Value::Bool(false)]);
7546        // we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
7547        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7548        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7549        let mut timeInForcePostOnly: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7550        if (postOnly.as_bool() != Some(true)) {
7551            postOnly = timeInForcePostOnly;
7552        }
7553        if (postOnly.as_bool() != Some(true)) {
7554            postOnly = exchangeSpecificParam;
7555        }
7556        if (postOnly.as_bool() == Some(true)) {
7557            if ioc || fok {
7558                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" postOnly orders cannot have timeInForce equal to ".into())).into()), timeInForce)));
7559            }  else if is_true(&isMarketOrder) {
7560                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7561            }  else {
7562                return Value::Bool(true);
7563            }
7564        }  else {
7565            return Value::Bool(false);
7566        }
7567
7568    Value::Null
7569}
7570
7571    fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7572        let mut params = get_arg(optional_args, 0, Value::Map({
7573    let mut m = indexmap::IndexMap::new();
7574    m
7575}));
7576        /*
7577         * @ignore
7578         * @method
7579         * @param {string} type Order type
7580         * @param {boolean} exchangeSpecificBoolean exchange specific postOnly
7581         * @param {object} [params] exchange specific params
7582         * @returns {Array}
7583         */
7584        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7585        let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
7586        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7587        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7588        let mut po: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7589        if (postOnly.as_bool() != Some(true)) {
7590            postOnly = po.clone();
7591        }
7592        if (postOnly.as_bool() != Some(true)) {
7593            postOnly = exchangeSpecificPostOnlyOption;
7594        }
7595        if (postOnly.as_bool() == Some(true)) {
7596            if ioc || fok {
7597                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" postOnly orders cannot have timeInForce equal to ".into())).into()), timeInForce)));
7598            }  else if is_true(&isMarketOrder) {
7599                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7600            }  else {
7601                if matches!(&po, Value::Bool(true)) {
7602                    params = self.omit(params.clone(), Value::Str("timeInForce".into()), &[]);
7603                }
7604                params = self.omit(params.clone(), Value::Str("postOnly".into()), &[]);
7605                return Value::from(vec![Value::Bool(true), params.clone()]);
7606            }
7607        }
7608        return Value::from(vec![Value::Bool(false), params]);
7609
7610    Value::Null
7611}
7612
7613    fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7614        let mut symbols = get_arg(optional_args, 0, Value::Null);
7615        let mut params = get_arg(optional_args, 1, Value::Map({
7616    let mut m = indexmap::IndexMap::new();
7617    m
7618}));
7619        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLastPrices() is not supported yet".into()))));
7620
7621    Value::Null
7622} }
7623
7624    fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7625        // async-virtual: try the derived exchange first
7626        if let Some(__v) = self.dispatch_to_derived("fetch_trading_fees", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
7627            if !matches!(__v, crate::Value::Null) { return __v; }
7628        }
7629
7630        let mut params = get_arg(optional_args, 0, Value::Map({
7631    let mut m = indexmap::IndexMap::new();
7632    m
7633}));
7634        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFees() is not supported yet".into()))));
7635
7636    Value::Null
7637} }
7638
7639    fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7640        let mut params = get_arg(optional_args, 0, Value::Map({
7641    let mut m = indexmap::IndexMap::new();
7642    m
7643}));
7644        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFeesWs() is not supported yet".into()))));
7645
7646    Value::Null
7647} }
7648
7649    fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7650        let mut params = get_arg(optional_args, 0, Value::Map({
7651    let mut m = indexmap::IndexMap::new();
7652    m
7653}));
7654        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertCurrencies() is not supported yet".into()))));
7655
7656    Value::Null
7657} }
7658
7659    fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
7660        // virtual-dispatch (static: DerivedExchange::parse_open_interest(self, ...))
7661        { let __v = crate::exchange::DerivedExchange::parse_open_interest(self, interest, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7662
7663        let mut market = get_arg(optional_args, 0, Value::Null);
7664        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOpenInterest () is not supported yet".into()))));
7665
7666    Value::Null
7667}
7668
7669    fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7670        let mut symbols = get_arg(optional_args, 0, Value::Null);
7671        let mut result: Value = Value::Map({
7672            let mut m = indexmap::IndexMap::new();
7673            m
7674        });
7675        {
7676                        let mut i: Value = Value::Int(0);
7677            let mut __for_first_152: bool = true;
7678            while { if !__for_first_152 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_152 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7679            let mut entry: Value = get_value(&response, &i);
7680            let mut entry: Value = get_value(&response, &i);
7681            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[]);
7682            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7683                add_element_to_object(&mut result, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7684            }
7685        }
7686        }
7687        return self.filter_by_array(result, Value::Str("symbol".into()), &[symbols]);
7688
7689    Value::Null
7690}
7691
7692    fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7693        let mut market = get_arg(optional_args, 0, Value::Null);
7694        let mut since = get_arg(optional_args, 1, Value::Null);
7695        let mut limit = get_arg(optional_args, 2, Value::Null);
7696        let mut interests: Value = Value::from(vec![]);
7697        {
7698                        let mut i: Value = Value::Int(0);
7699            let mut __for_first_153: bool = true;
7700            while { if !__for_first_153 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_153 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7701            let mut entry: Value = get_value(&response, &i);
7702            let mut entry: Value = get_value(&response, &i);
7703            let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[market.clone()]);
7704            append_to_array(&mut interests, interest);
7705        }
7706        }
7707        let mut sorted: Value = self.sort_by(interests, Value::Str("timestamp".into()), &[]);
7708        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
7709        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7710
7711    Value::Null
7712}
7713
7714    fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7715        // async-virtual: try the derived exchange first
7716        if let Some(__v) = self.dispatch_to_derived("fetch_funding_rate", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
7717            if !matches!(__v, crate::Value::Null) { return __v; }
7718        }
7719
7720        let mut params = get_arg(optional_args, 0, Value::Map({
7721    let mut m = indexmap::IndexMap::new();
7722    m
7723}));
7724        if (self.has.as_map().and_then(|__m| __m.get("fetchFundingRates")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchFundingRates")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
7725            self.load_markets(&[]).await;
7726            let mut market: Value = self.market(symbol.clone());
7727            symbol = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7728            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7729                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports contract markets only".into()))));
7730            }
7731            let mut rates: Value = self.fetch_funding_rates(&[Value::from(vec![symbol.clone()]), params]).await;
7732            let mut rate: Value = self.safe_value(rates, symbol.clone(), &[]);
7733            if (rate == Value::Null) {
7734                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () returned no data for ".into())).into()), symbol)));
7735            }  else {
7736                return rate;
7737            }
7738        }  else {
7739            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () is not supported yet".into()))));
7740        }
7741
7742    Value::Null
7743} }
7744
7745    fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7746        // async-virtual: try the derived exchange first
7747        if let Some(__v) = self.dispatch_to_derived("fetch_funding_interval", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
7748            if !matches!(__v, crate::Value::Null) { return __v; }
7749        }
7750
7751        let mut params = get_arg(optional_args, 0, Value::Map({
7752    let mut m = indexmap::IndexMap::new();
7753    m
7754}));
7755        if (self.has.as_map().and_then(|__m| __m.get("fetchFundingIntervals")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchFundingIntervals")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
7756            self.load_markets(&[]).await;
7757            let mut market: Value = self.market(symbol.clone());
7758            symbol = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7759            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7760                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() supports contract markets only".into()))));
7761            }
7762            let mut rates: Value = self.fetch_funding_intervals(&[Value::from(vec![symbol.clone()]), params]).await;
7763            let mut rate: Value = self.safe_value(rates, symbol.clone(), &[]);
7764            if (rate == Value::Null) {
7765                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() returned no data for ".into())).into()), symbol)));
7766            }  else {
7767                return rate;
7768            }
7769        }  else {
7770            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() is not supported yet".into()))));
7771        }
7772
7773    Value::Null
7774} }
7775
7776    fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7777        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7778        let mut since = get_arg(optional_args, 1, Value::Null);
7779        let mut limit = get_arg(optional_args, 2, Value::Null);
7780        let mut params = get_arg(optional_args, 3, Value::Map({
7781    let mut m = indexmap::IndexMap::new();
7782    m
7783}));
7784        /*
7785         * @method
7786         * @name exchange#fetchMarkOHLCV
7787         * @description fetches historical mark price candlestick data containing the open, high, low, and close price of a market
7788         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7789         * @param {string} timeframe the length of time each candle represents
7790         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7791         * @param {int} [limit] the maximum amount of candles to fetch
7792         * @param {object} [params] extra parameters specific to the exchange API endpoint
7793         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
7794         */
7795        if (self.has.as_map().and_then(|__m| __m.get("fetchMarkOHLCV")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchMarkOHLCV")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
7796            let mut request: Value = Value::Map({
7797                let mut m = indexmap::IndexMap::new();
7798                    m.insert("price".to_string(), Value::Str("mark".into()));
7799                m
7800            });
7801            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7802        }  else {
7803            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkOHLCV () is not supported yet".into()))));
7804        }
7805} }
7806
7807    fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7808        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7809        let mut since = get_arg(optional_args, 1, Value::Null);
7810        let mut limit = get_arg(optional_args, 2, Value::Null);
7811        let mut params = get_arg(optional_args, 3, Value::Map({
7812    let mut m = indexmap::IndexMap::new();
7813    m
7814}));
7815        /*
7816         * @method
7817         * @name exchange#fetchIndexOHLCV
7818         * @description fetches historical index price candlestick data containing the open, high, low, and close price of a market
7819         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7820         * @param {string} timeframe the length of time each candle represents
7821         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7822         * @param {int} [limit] the maximum amount of candles to fetch
7823         * @param {object} [params] extra parameters specific to the exchange API endpoint
7824         * @returns {} A list of candles ordered as timestamp, open, high, low, close, undefined
7825         */
7826        if (self.has.as_map().and_then(|__m| __m.get("fetchIndexOHLCV")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchIndexOHLCV")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
7827            let mut request: Value = Value::Map({
7828                let mut m = indexmap::IndexMap::new();
7829                    m.insert("price".to_string(), Value::Str("index".into()));
7830                m
7831            });
7832            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7833        }  else {
7834            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIndexOHLCV () is not supported yet".into()))));
7835        }
7836} }
7837
7838    fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7839        // async-virtual: try the derived exchange first
7840        if let Some(__v) = self.dispatch_to_derived("fetch_premium_index_ohlcv", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
7841            if !matches!(__v, crate::Value::Null) { return __v; }
7842        }
7843
7844        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7845        let mut since = get_arg(optional_args, 1, Value::Null);
7846        let mut limit = get_arg(optional_args, 2, Value::Null);
7847        let mut params = get_arg(optional_args, 3, Value::Map({
7848    let mut m = indexmap::IndexMap::new();
7849    m
7850}));
7851        /*
7852         * @method
7853         * @name exchange#fetchPremiumIndexOHLCV
7854         * @description fetches historical premium index price candlestick data containing the open, high, low, and close price of a market
7855         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7856         * @param {string} timeframe the length of time each candle represents
7857         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7858         * @param {int} [limit] the maximum amount of candles to fetch
7859         * @param {object} [params] extra parameters specific to the exchange API endpoint
7860         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
7861         */
7862        if (self.has.as_map().and_then(|__m| __m.get("fetchPremiumIndexOHLCV")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchPremiumIndexOHLCV")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
7863            let mut request: Value = Value::Map({
7864                let mut m = indexmap::IndexMap::new();
7865                    m.insert("price".to_string(), Value::Str("premiumIndex".into()));
7866                m
7867            });
7868            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7869        }  else {
7870            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".into()))));
7871        }
7872} }
7873
7874    fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
7875        let mut params = get_arg(optional_args, 0, Value::Map({
7876    let mut m = indexmap::IndexMap::new();
7877    m
7878}));
7879        /*
7880         * @ignore
7881         * @method
7882         * Must add timeInForce to this.options to use this method
7883         * @returns {string} returns the exchange specific value for timeInForce
7884         */
7885        let mut timeInForce: Value = self.safe_string_upper_k(params, "timeInForce", &[]); // supported values GTC, IOC, PO
7886        if (timeInForce != Value::Null) {
7887            let mut exchangeValue: Value = self.safe_string(self.options.as_map().and_then(|__m| __m.get("timeInForce")).cloned().unwrap_or(Value::Null), timeInForce.clone(), &[]);
7888            if (exchangeValue == Value::Null) {
7889                panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not support timeInForce \"".into())).into()), timeInForce).into()), Value::Str("\"".into()))));
7890            }
7891            return exchangeValue;
7892        }
7893        return Value::Null;
7894
7895    Value::Null
7896}
7897
7898    fn convert_type_to_account(&self, mut account: Value) -> Value {
7899        /*
7900         * @ignore
7901         * @method
7902         * Must add accountsByType to this.options to use this method
7903         * @param {string} account key for account name in this.options['accountsByType']
7904         * @returns the exchange specific account name or the isolated margin id for transfers
7905         */
7906        let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
7907    let mut m = indexmap::IndexMap::new();
7908    m
7909})]);
7910        let mut lowercaseAccount: Value = to_lower(&account);
7911        if (in_op(&accountsByType, &lowercaseAccount)) {
7912            return get_value(&accountsByType, &lowercaseAccount);
7913        }
7914        let mut markets: Value = self.markets.clone();
7915        let mut marketsById: Value = self.markets_by_id.clone();
7916        if ((markets != Value::Null) && (in_op(&markets, &account))) || ((marketsById != Value::Null) && (in_op(&marketsById, &account))) {
7917            let mut market: Value = self.market(account.clone());
7918            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
7919        }  else {
7920            return account;
7921        }
7922
7923    Value::Null
7924}
7925
7926    fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
7927        let mut options = get_arg(optional_args, 0, Value::from(vec![]));
7928        /*
7929         * @ignore
7930         * @method
7931         * @param {string} methodName the name of the method that the argument is being checked for
7932         * @param {string} argument the argument's actual value provided
7933         * @param {string} argumentName the name of the argument being checked (for logging purposes)
7934         * @param {string[]} options a list of options that the argument can be
7935         * @returns {undefined}
7936         */
7937        let mut optionsLength: f64 = ((options.len() as i64) as f64);
7938        if (argument == Value::Null) || ((optionsLength > ((0i64) as f64)) && (!(self.in_array(argument, options.clone()).as_bool() == Some(true)))) {
7939            let mut messageOptions: Value = join(&options, &Value::Str(", ".into()));
7940            let mut message: Value = Value::Str(format!("{}{}", add(&Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), methodName).into()), Value::Str("() requires a ".into())).into()), &argumentName), Value::Str(" argument".into())).into());
7941            if (messageOptions.as_str() != Some("")) {
7942                message = Value::Str(format!("{}{}", message, Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(", one of ".into()), Value::Str("(".into())).into()), messageOptions).into()), Value::Str(")".into())).into())).into());
7943            }
7944            panic!("{}", crate::exchange_errors::arguments_required(message));
7945        }
7946}
7947
7948    fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
7949        /*
7950         * @ignore
7951         * @method
7952         * @param {string} symbol unified symbol of the market
7953         * @param {string} methodName name of the method that requires a symbol
7954         * @param {string} marginMode is either 'isolated' or 'cross'
7955         */
7956        if (marginMode.as_str() == Some("isolated")) && (symbol == Value::Null) {
7957            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), methodName).into()), Value::Str("() requires a symbol argument for isolated margin".into()))));
7958        }  else if (marginMode.as_str() == Some("cross")) && (symbol != Value::Null) {
7959            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), methodName).into()), Value::Str("() cannot have a symbol argument for cross margin".into()))));
7960        }
7961}
7962
7963    fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
7964        let mut codes = get_arg(optional_args, 0, Value::Null);
7965        let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
7966        /*
7967         * @ignore
7968         * @method
7969         * @param {object[]|object} response unparsed response from the exchange
7970         * @param {string[]|undefined} codes the unified currency codes to fetch transactions fees for, returns all currencies when undefined
7971         * @param {str} currencyIdKey *should only be undefined when response is a dictionary* the object key that corresponds to the currency id
7972         * @returns {object} objects with withdraw and deposit fees, indexed by currency codes
7973         */
7974        let mut depositWithdrawFees: Value = Value::Map({
7975            let mut m = indexmap::IndexMap::new();
7976            m
7977        });
7978        let mut isArray: bool = matches!(&response, Value::Arr(_));
7979        let mut responseKeys: Value = response.clone();
7980        if !isArray {
7981            responseKeys = object_keys(&response);
7982        }
7983        {
7984                        let mut i: Value = Value::Int(0);
7985            let mut __for_first_154: bool = true;
7986            while { if !__for_first_154 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_154 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&responseKeys).as_f64().unwrap_or(f64::NAN) } {
7987            let mut entry: Value = get_value(&responseKeys, &i);
7988            let mut entry: Value = get_value(&responseKeys, &i);
7989            let mut dictionary: Value = (if isArray { entry.clone() } else { get_value(&response, &entry) });
7990            let mut currencyId: Value = entry;
7991            if isArray {
7992                currencyId = (if (currencyIdKey == Value::Null) { Value::Null } else { self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]) });
7993            }
7994            let mut currency: Value = self.safe_currency(currencyId, &[]);
7995            let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
7996            if (codes == Value::Null) || self.in_array(code.clone(), codes.clone()).as_bool() == Some(true) {
7997                if let Value::Dict(__d) = &mut depositWithdrawFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, dictionary, &[currency])); }
7998            }
7999        }
8000        }
8001        return depositWithdrawFees;
8002
8003    Value::Null
8004}
8005
8006    fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8007        // virtual-dispatch (static: DerivedExchange::parse_deposit_withdraw_fee(self, ...))
8008        { let __v = crate::exchange::DerivedExchange::parse_deposit_withdraw_fee(self, fee, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8009
8010        let mut currency = get_arg(optional_args, 0, Value::Null);
8011        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositWithdrawFee() is not supported yet".into()))));
8012
8013    Value::Null
8014}
8015
8016    fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8017        return Value::Map({
8018    let mut m = indexmap::IndexMap::new();
8019        m.insert("info".to_string(), info);
8020        m.insert("withdraw".to_string(), Value::Map({
8021    let mut m = indexmap::IndexMap::new();
8022        m.insert("fee".to_string(), Value::Null);
8023        m.insert("percentage".to_string(), Value::Null);
8024    m
8025}));
8026        m.insert("deposit".to_string(), Value::Map({
8027    let mut m = indexmap::IndexMap::new();
8028        m.insert("fee".to_string(), Value::Null);
8029        m.insert("percentage".to_string(), Value::Null);
8030    m
8031}));
8032        m.insert("networks".to_string(), Value::Map({
8033    let mut m = indexmap::IndexMap::new();
8034    m
8035}));
8036    m
8037});
8038
8039    Value::Null
8040}
8041
8042    fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8043        let mut currency = get_arg(optional_args, 0, Value::Null);
8044        let __currency_empty = indexmap::IndexMap::new();
8045        let currency = currency.as_map().unwrap_or(&__currency_empty);
8046        /*
8047         * @ignore
8048         * @method
8049         * @description Takes a depositWithdrawFee structure and assigns the default values for withdraw and deposit
8050         * @param {object} fee A deposit withdraw fee structure
8051         * @param {object} currency A currency structure, the response from this.currency ()
8052         * @returns {object} A deposit withdraw fee structure
8053         */
8054        let mut networkKeys: Value = object_keys(&crate::value::get_value_k(&fee, "networks"));
8055        let mut numNetworks: f64 = ((networkKeys.len() as i64) as f64);
8056        if (numNetworks == 1.0) {
8057            { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)), "withdraw"); add_element_to_object(&mut fee, &Value::Str("withdraw".into()), __be_tmp); };
8058            { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)), "deposit"); add_element_to_object(&mut fee, &Value::Str("deposit".into()), __be_tmp); };
8059            return fee;
8060        }
8061        let mut currencyCode: Value = (match currency.get("code") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null });
8062        {
8063                        let mut i: Value = Value::Int(0);
8064            let mut __for_first_155: bool = true;
8065            while { if !__for_first_155 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_155 = false; i.as_f64().unwrap_or(f64::NAN) < numNetworks } {
8066            let mut network: Value = networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8067            if (network.as_str() == currencyCode.as_str()) {
8068                { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), "withdraw"); add_element_to_object(&mut fee, &Value::Str("withdraw".into()), __be_tmp); };
8069                { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), "deposit"); add_element_to_object(&mut fee, &Value::Str("deposit".into()), __be_tmp); };
8070            }
8071        }
8072        }
8073        return fee;
8074
8075    Value::Null
8076}
8077
8078    fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8079        // virtual-dispatch (static: DerivedExchange::parse_income(self, ...))
8080        { let __v = crate::exchange::DerivedExchange::parse_income(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8081
8082        let mut market = get_arg(optional_args, 0, Value::Null);
8083        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIncome () is not supported yet".into()))));
8084
8085    Value::Null
8086}
8087
8088    fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8089        let mut market = get_arg(optional_args, 0, Value::Null);
8090        let mut since = get_arg(optional_args, 1, Value::Null);
8091        let mut limit = get_arg(optional_args, 2, Value::Null);
8092        /*
8093         * @ignore
8094         * @method
8095         * @description parses funding fee info from exchange response
8096         * @param {object[]} incomes each item describes once instance of currency being received or paid
8097         * @param {object} market ccxt market
8098         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
8099         * @param {int} [limit] limits the number of items in the response
8100         * @returns {object[]} an array of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure}
8101         */
8102        let mut result: Value = Value::from(vec![]);
8103        {
8104                        let mut i: Value = Value::Int(0);
8105            let mut __for_first_156: bool = true;
8106            while { if !__for_first_156 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_156 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&incomes).as_f64().unwrap_or(f64::NAN) } {
8107            let mut entry: Value = get_value(&incomes, &i);
8108            let mut entry: Value = get_value(&incomes, &i);
8109            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry, &[market.clone()]);
8110            append_to_array(&mut result, parsed);
8111        }
8112        }
8113        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8114        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8115        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8116
8117    Value::Null
8118}
8119
8120    fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8121        let mut symbols = get_arg(optional_args, 0, Value::Null);
8122        /*
8123         * @param {string[]|undefined} symbols list of unified symbols (first element selects the market)
8124         * @returns {MarketInterface|undefined} market structure for the first symbol, or undefined if symbols is undefined
8125         * Overloads: non-null `string[]` input yields `MarketInterface`; optional input yields `Market`.
8126         */
8127        if (symbols == Value::Null) {
8128            return Value::Null;
8129        }
8130        let mut firstMarket: Value = self.safe_string(symbols, Value::Int(0), &[]);
8131        if (firstMarket == Value::Null) {
8132            return Value::Null;
8133        }
8134        let mut market: Value = self.market(firstMarket);
8135        return market;
8136
8137    Value::Null
8138}
8139
8140    fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8141        let mut market = get_arg(optional_args, 0, Value::Null);
8142        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
8143        let mut since = get_arg(optional_args, 2, Value::Null);
8144        let mut limit = get_arg(optional_args, 3, Value::Null);
8145        let mut results: Value = Value::from(vec![]);
8146        {
8147                        let mut i: Value = Value::Int(0);
8148            let mut __for_first_157: bool = true;
8149            while { if !__for_first_157 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_157 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
8150            append_to_array(&mut results, self.parse_ws_ohlcv(ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]));
8151        }
8152        }
8153        return results;
8154
8155    Value::Null
8156}
8157
8158    fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8159        let mut code = get_arg(optional_args, 0, Value::Null);
8160        let mut since = get_arg(optional_args, 1, Value::Null);
8161        let mut limit = get_arg(optional_args, 2, Value::Null);
8162        let mut params = get_arg(optional_args, 3, Value::Map({
8163    let mut m = indexmap::IndexMap::new();
8164    m
8165}));
8166        /*
8167         * @method
8168         * @name exchange#fetchTransactions
8169         * @deprecated
8170         * @description *DEPRECATED* use fetchDepositsWithdrawals instead
8171         * @param {string} code unified currency code for the currency of the deposit/withdrawals, default is undefined
8172         * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
8173         * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
8174         * @param {object} [params] extra parameters specific to the exchange API endpoint
8175         * @returns {object} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
8176         */
8177        if (self.has.as_map().and_then(|__m| __m.get("fetchDepositsWithdrawals")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchDepositsWithdrawals")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
8178            return self.fetch_deposits_withdrawals(&[code, since, limit, params]).await;
8179        }  else {
8180            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactions () is not supported yet".into()))));
8181        }
8182} }
8183
8184    fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8185        let mut values = get_arg(optional_args, 0, Value::Null);
8186        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8187        return self.filter_by_array(objects, key, &[values, indexed]);
8188
8189    Value::Null
8190}
8191
8192    fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8193        let mut values = get_arg(optional_args, 0, Value::Null);
8194        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8195        return self.filter_by_array(objects, key, &[values, indexed]);
8196
8197    Value::Null
8198}
8199
8200    fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8201        let mut values = get_arg(optional_args, 0, Value::Null);
8202        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8203        return self.filter_by_array(objects, key, &[values, indexed]);
8204
8205    Value::Null
8206}
8207
8208    fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8209        let mut res: Value = Value::Map({
8210            let mut m = indexmap::IndexMap::new();
8211            m
8212        });
8213        if let Value::Dict(__d) = &mut res { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
8214    let mut m = indexmap::IndexMap::new();
8215    m
8216})); }
8217        add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data);
8218        return res;
8219
8220    Value::Null
8221}
8222
8223    fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8224        let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8225        let mut params = get_arg(optional_args, 1, Value::Map({
8226    let mut m = indexmap::IndexMap::new();
8227    m
8228}));
8229        let mut newMaxEntriesPerRequest: Value = Value::Null;
8230        { let __destr_tmp = self.handle_option_and_params(params.clone(), method, Value::Str("maxEntriesPerRequest".into()), &[]); newMaxEntriesPerRequest = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8231        if (newMaxEntriesPerRequest != Value::Null) && (newMaxEntriesPerRequest.as_f64() != maxEntriesPerRequest.as_f64()) {
8232            maxEntriesPerRequest = newMaxEntriesPerRequest;
8233        }
8234        if (maxEntriesPerRequest == Value::Null) {
8235            maxEntriesPerRequest = Value::Int(1000); // default to 1000
8236        }
8237        return Value::from(vec![maxEntriesPerRequest, params]);
8238
8239    Value::Null
8240}
8241
8242    fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8243        let mut symbol = get_arg(optional_args, 0, Value::Null);
8244        let mut since = get_arg(optional_args, 1, Value::Null);
8245        let mut limit = get_arg(optional_args, 2, Value::Null);
8246        let mut params = get_arg(optional_args, 3, Value::Map({
8247    let mut m = indexmap::IndexMap::new();
8248    m
8249}));
8250        let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8251        let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8252        let mut maxCalls: Value = Value::Int(10);
8253        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".into()), &[maxCalls.clone()]); maxCalls = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8254        let mut maxRetries: Value = Value::Int(3);
8255        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".into()), &[maxRetries.clone()]); maxRetries = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8256        let mut paginationDirection: Value = Value::Null;
8257        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationDirection".into()), &[Value::Str("backward".into())]); paginationDirection = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8258        let mut paginationTimestamp: Value = Value::Null;
8259        let mut removeRepeatedOption: Value = removeRepeated.clone();
8260        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("removeRepeated".into()), &[removeRepeated]); removeRepeatedOption = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8261        let mut calls: Value = Value::Int(0);
8262        let mut result: Value = Value::from(vec![]);
8263        let mut errors: Value = Value::Int(0);
8264        let mut until: Value = self.safe_integer_n(params.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("untill".into()), Value::Str("till".into())]), &[]); // do not omit it from params here
8265        { let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8266        if (paginationDirection.as_str() == Some("forward")) {
8267            if (since == Value::Null) {
8268                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" pagination requires a since argument when paginationDirection set to forward".into()))));
8269            }
8270            paginationTimestamp = since.clone();
8271        }
8272        while (calls.as_f64().unwrap_or(f64::NAN) < maxCalls.as_f64().unwrap_or(f64::NAN)) {
8273            calls = (match (&(calls), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8274            {
8275                if (paginationDirection.as_str() == Some("backward")) {
8276                    // do it backwards, starting from the last
8277                    // UNTIL filtering is required in order to work
8278                    if (paginationTimestamp != Value::Null) {
8279                        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("until".into(), (match (&(paginationTimestamp), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
8280                    }
8281                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (Value::Null).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8282                    let mut responseLength: Value = get_array_length(&response);
8283                    if is_true(&self.verbose) {
8284                        let mut backwardMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Dynamic pagination call ".into()), self.number_to_string(calls.clone())).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), self.number_to_string(responseLength.clone())).into());
8285                        if (paginationTimestamp != Value::Null) {
8286                            backwardMessage = Value::Str(format!("{}{}", backwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8287                        }
8288                        self.log(backwardMessage);
8289                    }
8290                    if is_equal(&responseLength, &Value::Int(0)) {
8291                        break;
8292                    }
8293                    errors = Value::Int(0);
8294                    result = self.array_concat(result.clone(), response.clone());
8295                    let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
8296                    paginationTimestamp = self.safe_integer2(firstElement, Value::Str("timestamp".into()), Value::Int(0), &[]);
8297                    if (paginationTimestamp == Value::Null) {
8298                        break;
8299                    }
8300                    if (since != Value::Null) && (paginationTimestamp.as_f64().unwrap_or(f64::NAN) <= since.as_f64().unwrap_or(f64::NAN)) {
8301                        break;
8302                    }
8303                }  else {
8304                    // do it forwards, starting from the since
8305                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paginationTimestamp).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8306                    let mut responseLength: Value = get_array_length(&response);
8307                    if is_true(&self.verbose) {
8308                        let mut forwardMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Dynamic pagination call ".into()), self.number_to_string(calls.clone())).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), self.number_to_string(responseLength.clone())).into());
8309                        if (paginationTimestamp != Value::Null) {
8310                            forwardMessage = Value::Str(format!("{}{}", forwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8311                        }
8312                        self.log(forwardMessage);
8313                    }
8314                    if is_equal(&responseLength, &Value::Int(0)) {
8315                        break;
8316                    }
8317                    errors = Value::Int(0);
8318                    result = self.array_concat(result.clone(), response.clone());
8319                    let mut last: Value = self.safe_value(response, subtract(&responseLength, &Value::Int(1)), &[]);
8320                    let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[Value::Int(0)]);
8321                    if (lastTimestamp == Value::Null) {
8322                        break;
8323                    }
8324                    let mut nextPaginationTimestamp: Value = (match (&(lastTimestamp), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8325                    paginationTimestamp = nextPaginationTimestamp.clone();
8326                    if (until != Value::Null) && (nextPaginationTimestamp.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8327                        break;
8328                    }
8329                }
8330            }
8331        }
8332        let mut uniqueResults: Value = result.clone();
8333        if is_true(&removeRepeatedOption) {
8334            uniqueResults = self.remove_repeated_elements_from_array(result, &[]);
8335        }
8336        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8337        let mut sortedRes: Value = self.sort_by(uniqueResults, key.clone(), &[]);
8338        return self.filter_by_since_limit(sortedRes, &[since, limit, key]);
8339
8340    Value::Null
8341} }
8342
8343    fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8344        let mut symbol = get_arg(optional_args, 0, Value::Null);
8345        let mut since = get_arg(optional_args, 1, Value::Null);
8346        let mut limit = get_arg(optional_args, 2, Value::Null);
8347        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8348        let mut params = get_arg(optional_args, 4, Value::Map({
8349    let mut m = indexmap::IndexMap::new();
8350    m
8351}));
8352        let mut maxRetries: Value = Value::Int(3);
8353        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".into()), &[maxRetries.clone()]); maxRetries = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8354        let mut errors: Value = Value::Int(0);
8355        while errors.as_f64().unwrap_or(f64::NAN) <= maxRetries.as_f64().unwrap_or(f64::NAN) {
8356            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8357                if ((timeframe != Value::Null) && (timeframe.as_str() != Some(""))) && (method.as_str() != Some("fetchFundingRateHistory")) {
8358                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (limit).clone(), (params).clone()]).await;
8359                }  else {
8360                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (limit).clone(), (params).clone()]).await;
8361                }
8362             #[allow(unreachable_code)] { Value::Null }})).await;
8363match _try_result { Ok(__try_ok) => { if !matches!(__try_ok, Value::Null) { return __try_ok; } return Value::Null; } Err(_try_err) => { let e: Value = panic_to_value(_try_err); 
8364                if matches!(&e, Value::Str(__s) if __s.contains("[RateLimitExceeded]")) {
8365                    panic!("{}", e);
8366                }
8367                errors = (match (&(errors), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8368                if errors.as_f64().unwrap_or(f64::NAN) > maxRetries.as_f64().unwrap_or(f64::NAN) {
8369                    panic!("{}", e);
8370                }
8371             } }
8372        }
8373        return Value::from(vec![]);
8374
8375    Value::Null
8376} }
8377
8378    fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8379        let mut symbol = get_arg(optional_args, 0, Value::Null);
8380        let mut since = get_arg(optional_args, 1, Value::Null);
8381        let mut limit = get_arg(optional_args, 2, Value::Null);
8382        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8383        let mut params = get_arg(optional_args, 4, Value::Map({
8384    let mut m = indexmap::IndexMap::new();
8385    m
8386}));
8387        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8388        let mut maxCalls: Value = Value::Int(10);
8389        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".into()), &[maxCalls.clone()]); maxCalls = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8390        { let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8391        // paginationDirection is only relevant to fetchPaginatedCallDynamic/Cursor; deterministic
8392        // pagination always walks forward internally, so strip it here to avoid leaking an
8393        // unrecognized param into the underlying exchange request (e.g. binance -1104 errors)
8394        params = self.omit(params.clone(), Value::Str("paginationDirection".into()), &[]);
8395        let mut current: Value = self.milliseconds();
8396        let mut tasks: Value = Value::from(vec![]);
8397        let mut time: Value = (match (&(self.parse_timeframe(timeframe.clone())), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
8398        maxEntriesPerRequest = self.require_value(maxEntriesPerRequest.clone(), &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".into())]);
8399        let mut step: Value = multiply(&time, &maxEntriesPerRequest);
8400        let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]); // do not omit it here
8401        let mut currentSince: Value = (match (&((match (&(current), &(((match (&(maxCalls), &(step)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8402        if (since != Value::Null) {
8403            if (until != Value::Null) {
8404                // the recent-window floor below would jump past a fully-historical [ since, until ]
8405                // range and return an empty result - requiredCalls is validated against maxCalls
8406                // further down, so anchoring at since directly is safe here,
8407                // see https://github.com/ccxt/ccxt/issues/26252
8408                currentSince = since.clone();
8409            }  else {
8410                currentSince = crate::runtime::Math::max(&currentSince, &since);
8411            }
8412        }  else {
8413            currentSince = crate::runtime::Math::max(&currentSince, &Value::Int(1241440531000)); // avoid timestamps older than 2009
8414        }
8415        if (until != Value::Null) {
8416            if (since == Value::Null) {
8417                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".into()))));
8418            }
8419            let mut requiredCalls: Value = math_ceil(&(match ((((match (&(until), &(since)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }))).as_f64(), (step).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
8420            if requiredCalls.as_f64().unwrap_or(f64::NAN) > maxCalls.as_f64().unwrap_or(f64::NAN) {
8421                panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is ".into())).into()), to_string_val(&maxCalls)).into()), Value::Str(" required calls is ".into())).into()), to_string_val(&requiredCalls))));
8422            }
8423        }
8424        {
8425                        let mut i: Value = Value::Int(0);
8426            let mut __for_first_158: bool = true;
8427            while { if !__for_first_158 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_158 = false; i.as_f64().unwrap_or(f64::NAN) < maxCalls.as_f64().unwrap_or(f64::NAN) } {
8428            if (until != Value::Null) && (currentSince.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8429                break;
8430            }
8431            if currentSince.as_f64().unwrap_or(f64::NAN) >= current.as_f64().unwrap_or(f64::NAN) {
8432                break;
8433            }
8434            append_to_array(&mut tasks, self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequest.clone(), timeframe.clone(), params.clone()]).await);
8435            currentSince = subtract(&self.sum(&[currentSince.clone(), step.clone()]), &Value::Int(1));
8436        }
8437        }
8438        let mut results: Value = promise_all(&tasks).await;
8439        let mut result: Value = Value::from(vec![]);
8440        {
8441                        let mut i: Value = Value::Int(0);
8442            let mut __for_first_159: bool = true;
8443            while { if !__for_first_159 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_159 = false; i.as_f64().unwrap_or(f64::NAN) < ((results.len() as i64) as f64) } {
8444            result = self.array_concat(result.clone(), results.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
8445        }
8446        }
8447        let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result, &[]);
8448        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8449        return self.filter_by_since_limit(uniqueResults, &[since, limit, key]);
8450
8451    Value::Null
8452} }
8453
8454// the 'symbol' slot is forwarded to `this[method]` untouched and is only compared against
8455// undefined here, so fetchPositions/fetchPositionsHistory legitimately pass a symbol list
8456    fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8457        let mut symbol = get_arg(optional_args, 0, Value::Null);
8458        let mut since = get_arg(optional_args, 1, Value::Null);
8459        let mut limit = get_arg(optional_args, 2, Value::Null);
8460        let mut params = get_arg(optional_args, 3, Value::Map({
8461    let mut m = indexmap::IndexMap::new();
8462    m
8463}));
8464        let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8465        let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8466        let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8467        let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8468        let mut maxCalls: Value = Value::Int(10);
8469        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".into()), &[maxCalls.clone()]); maxCalls = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8470        let mut maxRetries: Value = Value::Int(3);
8471        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".into()), &[maxRetries.clone()]); maxRetries = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8472        { let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8473        let mut cursorValue: Value = Value::Null;
8474        let mut i: Value = Value::Int(0);
8475        let mut errors: Value = Value::Int(0);
8476        let mut result: Value = Value::from(vec![]);
8477        let mut timeframe: Value = self.safe_string_k(params.clone(), "timeframe", &[]);
8478        params = self.omit(params.clone(), Value::Str("timeframe".into()), &[]); // reading the timeframe from the method arguments to avoid changing the signature
8479        while i.as_f64().unwrap_or(f64::NAN) < maxCalls.as_f64().unwrap_or(f64::NAN) {
8480            {
8481                if (cursorValue != Value::Null) {
8482                    if (cursorIncrement != Value::Null) {
8483                        cursorValue = (match (&(self.parse_to_int(cursorValue.clone())), &(cursorIncrement)) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8484                    }
8485                    add_element_to_object(&mut params, &cursorSent, cursorValue.clone());
8486                }
8487                let mut response: Value = Value::Null;
8488                if (method.as_str() == Some("fetchAccounts")) {
8489                    response = self.call_dynamic_checked(method.clone(), vec![(params).clone()]).await;
8490                }  else if (method.as_str() == Some("getLeverageTiersPaginated")) || (method.as_str() == Some("fetchPositions")) {
8491                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (params).clone()]).await;
8492                }  else if (method.as_str() == Some("fetchOpenInterestHistory")) {
8493                    if !matches!(&symbol, Value::Str(_)) {
8494                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".into()))));
8495                    }
8496                    if (timeframe == Value::Null) {
8497                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".into()))));
8498                    }
8499                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8500                }  else {
8501                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8502                }
8503                errors = Value::Int(0);
8504                if (response == Value::Null) {
8505                    panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() returned empty response".into()))));
8506                }
8507                let mut responseLength: Value = Value::Int(response.len() as i64);
8508                if is_true(&self.verbose) {
8509                    let mut cursorString: Value = (if (cursorValue == Value::Null) { Value::Str("".into()) } else { cursorValue.clone() });
8510                    let mut iteration: Value = ((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }));
8511                    let mut cursorMessage: Value = add(&Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Cursor pagination call ".into()), to_string_val(&iteration)).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), to_string_val(&responseLength)).into()), Value::Str(" cursor ".into())).into()), &cursorString);
8512                    self.log(cursorMessage);
8513                }
8514                if (responseLength.as_f64() == Some(0.0)) {
8515                    break;
8516                }
8517                if (response != Value::Null) {
8518                    result = self.array_concat(result.clone(), response.clone());
8519                }
8520                let mut last: Value = self.safe_dict(response.clone(), (match (&(responseLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }), &[]);
8521                // cursorValue = this.safeValue (last['info'], cursorReceived);
8522                cursorValue = Value::Null; // search for the cursor
8523                {
8524                                        let mut j: Value = Value::Int(0);
8525                    let mut __for_first_160: bool = true;
8526                    while { if !__for_first_160 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_160 = false; j.as_f64().unwrap_or(f64::NAN) < responseLength.as_f64().unwrap_or(f64::NAN) } {
8527                    let mut index: Value = (match (&((match (&(responseLength), &(j)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8528                    let mut entry: Value = self.safe_dict(response.clone(), index, &[]);
8529                    let mut info: Value = self.safe_dict_k(entry, "info", &[]);
8530                    let mut cursor: Value = (if (cursorReceived == Value::Null) { Value::Null } else { self.safe_value(info, cursorReceived.clone(), &[]) });
8531                    if (cursor != Value::Null) {
8532                        cursorValue = cursor;
8533                        break;
8534                    }
8535                }
8536                }
8537                if (cursorValue == Value::Null) {
8538                    break;
8539                }
8540                let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[]);
8541                if (since == Value::Null) {
8542                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a since argument".into()))));
8543                }
8544                if (lastTimestamp != Value::Null) && lastTimestamp.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
8545                    break;
8546                }
8547            }
8548            i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8549        }
8550        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8551        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8552        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8553
8554    Value::Null
8555} }
8556
8557    fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8558        let mut symbol = get_arg(optional_args, 0, Value::Null);
8559        let mut since = get_arg(optional_args, 1, Value::Null);
8560        let mut limit = get_arg(optional_args, 2, Value::Null);
8561        let mut params = get_arg(optional_args, 3, Value::Map({
8562    let mut m = indexmap::IndexMap::new();
8563    m
8564}));
8565        let mut pageKey = get_arg(optional_args, 4, Value::Null);
8566        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8567        let mut maxCalls: Value = Value::Int(10);
8568        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".into()), &[maxCalls.clone()]); maxCalls = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8569        let mut maxRetries: Value = Value::Int(3);
8570        { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".into()), &[maxRetries.clone()]); maxRetries = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8571        { let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
8572        let mut i: Value = Value::Int(0);
8573        let mut errors: Value = Value::Int(0);
8574        let mut result: Value = Value::from(vec![]);
8575        while i.as_f64().unwrap_or(f64::NAN) < maxCalls.as_f64().unwrap_or(f64::NAN) {
8576            {
8577                if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&pageKey), (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })); }
8578                let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8579                errors = Value::Int(0);
8580                let mut responseLength: Value = get_array_length(&response);
8581                if is_true(&self.verbose) {
8582                    let mut iteration: Value = to_string_val(&((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })));
8583                    let mut incrementalMessage: Value = add(&Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Incremental pagination call ".into()), iteration).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), &to_string_val(&responseLength));
8584                    self.log(incrementalMessage);
8585                }
8586                if is_equal(&responseLength, &Value::Int(0)) {
8587                    break;
8588                }
8589                result = self.array_concat(result.clone(), response);
8590            }
8591            i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8592        }
8593        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8594        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8595        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8596
8597    Value::Null
8598} }
8599
8600    fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
8601        let mut first: Value = self.safe_value(result.clone(), Value::Int(0), &[]);
8602        if (first != Value::Null) {
8603            if (in_op(&first, &Value::Str("timestamp".into()))) {
8604                return self.sort_by(result.clone(), Value::Str("timestamp".into()), &[Value::Bool(true)]);
8605            }
8606            if (in_op(&first, &Value::Str("id".into()))) {
8607                return self.sort_by(result.clone(), Value::Str("id".into()), &[Value::Bool(true)]);
8608            }
8609        }
8610        return result;
8611
8612    Value::Null
8613}
8614
8615    fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
8616        let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
8617        let mut uniqueDic: Value = Value::Map({
8618            let mut m = indexmap::IndexMap::new();
8619            m
8620        });
8621        let mut uniqueResult: Value = Value::from(vec![]);
8622        {
8623                        let mut i: Value = Value::Int(0);
8624            let mut __for_first_161: bool = true;
8625            while { if !__for_first_161 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_161 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
8626            let mut entry: Value = get_value(&input, &i);
8627            let mut entry: Value = get_value(&input, &i);
8628            let mut uniqValue: Value = (if is_true(&fallbackToTimestamp) { self.safe_string_n(entry.clone(), Value::from(vec![Value::Str("id".into()), Value::Str("timestamp".into()), Value::Int(0)]), &[]) } else { self.safe_string_k(entry.clone(), "id", &[]) });
8629            if (uniqValue != Value::Null) && !(in_op(&uniqueDic, &uniqValue)) {
8630                if let Value::Dict(__d) = &mut uniqueDic { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&uniqValue), Value::Int(1)); }
8631                append_to_array(&mut uniqueResult, entry);
8632            }
8633        }
8634        }
8635        let mut valuesLength: f64 = ((uniqueResult.len() as i64) as f64);
8636        if valuesLength > ((0i64) as f64) {
8637            return uniqueResult;
8638        }
8639        return input;
8640
8641    Value::Null
8642}
8643
8644    fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
8645        let mut uniqueResult: Value = Value::Map({
8646            let mut m = indexmap::IndexMap::new();
8647            m
8648        });
8649        {
8650                        let mut i: Value = Value::Int(0);
8651            let mut __for_first_162: bool = true;
8652            while { if !__for_first_162 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_162 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
8653            let mut entry: Value = get_value(&input, &i);
8654            let mut entry: Value = get_value(&input, &i);
8655            let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
8656            if (id == Value::Null) {
8657                let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
8658                let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
8659                let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
8660                let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
8661                // unique trade identifier
8662                if (timestamp == Value::Null) {
8663                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" removeRepeatedTradesFromArray() missing timestamp".into()))));
8664                }
8665                id = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("t_".into()), to_string_val(&timestamp)).into()), Value::Str("_".into())).into()), side).into()), Value::Str("_".into())).into()), price).into()), Value::Str("_".into())).into()), amount).into());
8666            }
8667            if (id != Value::Null) && !(in_op(&uniqueResult, &id)) {
8668                if let Value::Dict(__d) = &mut uniqueResult { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&id), entry); }
8669            }
8670        }
8671        }
8672        let mut values: Value = object_values(&uniqueResult);
8673        return values;
8674
8675    Value::Null
8676}
8677
8678    fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
8679        let mut keys: Value = object_keys(&dict);
8680        let mut newDict: Value = Value::Map({
8681            let mut m = indexmap::IndexMap::new();
8682            m
8683        });
8684        {
8685                        let mut i: Value = Value::Int(0);
8686            let mut __for_first_163: bool = true;
8687            while { if !__for_first_163 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_163 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
8688            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8689            if !(self.in_array(key.clone(), removeKeys.clone()).as_bool() == Some(true)) {
8690                if let Value::Dict(__d) = &mut newDict { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&key), dict.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null)); }
8691            }
8692        }
8693        }
8694        return newDict;
8695
8696    Value::Null
8697}
8698
8699    fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
8700        let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
8701        let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]);
8702        if (until != Value::Null) {
8703            add_element_to_object(&mut request, &key, self.parse_to_int((match (&(until), &(multiplier)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })));
8704            params = self.omit(params.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("till".into())]), &[]);
8705        }
8706        return Value::from(vec![request, params]);
8707
8708    Value::Null
8709}
8710
8711    fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
8712        let mut market = get_arg(optional_args, 0, Value::Null);
8713        let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
8714        if (symbol == Value::Null) {
8715            symbol = self.safe_string_k(market, "symbol", &[]);
8716        }
8717        return self.extend(interest.clone(), &[Value::Map({
8718    let mut m = indexmap::IndexMap::new();
8719        m.insert("symbol".to_string(), symbol);
8720        m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
8721        m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
8722        m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
8723        m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
8724        m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
8725        m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
8726        m.insert("info".to_string(), self.safe_value_k(interest, "info", &[]));
8727    m
8728})]);
8729
8730    Value::Null
8731}
8732
8733    fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
8734        // virtual-dispatch (static: DerivedExchange::parse_liquidation(self, ...))
8735        { let __v = crate::exchange::DerivedExchange::parse_liquidation(self, liquidation, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8736
8737        let mut market = get_arg(optional_args, 0, Value::Null);
8738        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLiquidation () is not supported yet".into()))));
8739
8740    Value::Null
8741}
8742
8743    fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
8744        let mut market = get_arg(optional_args, 0, Value::Null);
8745        let mut since = get_arg(optional_args, 1, Value::Null);
8746        let mut limit = get_arg(optional_args, 2, Value::Null);
8747        /*
8748         * @ignore
8749         * @method
8750         * @description parses liquidation info from the exchange response
8751         * @param {object[]} liquidations each item describes an instance of a liquidation event
8752         * @param {object} market ccxt market
8753         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
8754         * @param {int} [limit] limits the number of items in the response
8755         * @returns {object[]} an array of [liquidation structures]{@link https://docs.ccxt.com/?id=liquidation-structure}
8756         */
8757        let mut result: Value = Value::from(vec![]);
8758        {
8759                        let mut i: Value = Value::Int(0);
8760            let mut __for_first_164: bool = true;
8761            while { if !__for_first_164 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_164 = false; i.as_f64().unwrap_or(f64::NAN) < ((liquidations.len() as i64) as f64) } {
8762            let mut entry: Value = liquidations.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8763            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry, &[market.clone()]);
8764            append_to_array(&mut result, parsed);
8765        }
8766        }
8767        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8768        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8769        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8770
8771    Value::Null
8772}
8773
8774    fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8775        // virtual-dispatch (static: DerivedExchange::parse_greeks(self, ...))
8776        { let __v = crate::exchange::DerivedExchange::parse_greeks(self, greeks, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8777
8778        let mut market = get_arg(optional_args, 0, Value::Null);
8779        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseGreeks () is not supported yet".into()))));
8780
8781    Value::Null
8782}
8783
8784    fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8785        let mut symbols = get_arg(optional_args, 0, Value::Null);
8786        let mut params = get_arg(optional_args, 1, Value::Map({
8787    let mut m = indexmap::IndexMap::new();
8788    m
8789}));
8790        //
8791        // the value of greeks is either a dict or a list
8792        //
8793        let mut results: Value = Value::from(vec![]);
8794        if (matches!(&greeks, Value::Arr(_))) {
8795            {
8796                                let mut i: Value = Value::Int(0);
8797                let mut __for_first_165: bool = true;
8798                while { if !__for_first_165 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_165 = false; i.as_f64().unwrap_or(f64::NAN) < ((greeks.len() as i64) as f64) } {
8799                let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, greeks.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]);
8800                let mut greek: Value = self.extend(parsedTicker, &[params.clone()]);
8801                append_to_array(&mut results, greek.clone());
8802            }
8803            }
8804        }  else {
8805            let mut marketIds: Value = object_keys(&greeks);
8806            {
8807                                let mut i: Value = Value::Int(0);
8808                let mut __for_first_166: bool = true;
8809                while { if !__for_first_166 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_166 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
8810                let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8811                let mut market: Value = self.safe_market(&[marketId.clone()]);
8812                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market]);
8813                let mut greek: Value = self.extend(parsed, &[params.clone()]);
8814                append_to_array(&mut results, greek);
8815            }
8816            }
8817        }
8818        symbols = self.market_symbols(&[symbols.clone()]);
8819        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbols]);
8820
8821    Value::Null
8822}
8823
8824    fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
8825        let mut currency = get_arg(optional_args, 0, Value::Null);
8826        let mut market = get_arg(optional_args, 1, Value::Null);
8827        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOption () is not supported yet".into()))));
8828
8829    Value::Null
8830}
8831
8832    fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
8833        let mut currencyKey = get_arg(optional_args, 0, Value::Null);
8834        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8835        let mut optionStructures: Value = Value::Map({
8836            let mut m = indexmap::IndexMap::new();
8837            m
8838        });
8839        {
8840                        let mut i: Value = Value::Int(0);
8841            let mut __for_first_167: bool = true;
8842            while { if !__for_first_167 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_167 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
8843            let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8844            let mut currencyId: Value = (if (currencyKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), currencyKey.clone(), &[]) });
8845            let mut currency: Value = self.safe_currency(currencyId, &[]);
8846            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
8847            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("option".into())]);
8848            add_element_to_object(&mut optionStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), self.parse_option(info, &[currency, market.clone()]));
8849        }
8850        }
8851        return optionStructures;
8852
8853    Value::Null
8854}
8855
8856    fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
8857        let mut symbols = get_arg(optional_args, 0, Value::Null);
8858        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8859        let mut marketType = get_arg(optional_args, 2, Value::Null);
8860        let mut marginModeStructures: Value = Value::Map({
8861            let mut m = indexmap::IndexMap::new();
8862            m
8863        });
8864        if (marketType == Value::Null) {
8865            marketType = Value::Str("swap".into()); // default to swap
8866        }
8867        {
8868                        let mut i: Value = Value::Int(0);
8869            let mut __for_first_168: bool = true;
8870            while { if !__for_first_168 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_168 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
8871            let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8872            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
8873            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
8874            if (symbols == Value::Null) || self.in_array(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), symbols.clone()).as_bool() == Some(true) {
8875                add_element_to_object(&mut marginModeStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, info, &[market.clone()]));
8876            }
8877        }
8878        }
8879        return marginModeStructures;
8880
8881    Value::Null
8882}
8883
8884    fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
8885        // virtual-dispatch (static: DerivedExchange::parse_margin_mode(self, ...))
8886        { let __v = crate::exchange::DerivedExchange::parse_margin_mode(self, marginMode, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8887
8888        let mut market = get_arg(optional_args, 0, Value::Null);
8889        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginMode () is not supported yet".into()))));
8890
8891    Value::Null
8892}
8893
8894    fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
8895        let mut symbols = get_arg(optional_args, 0, Value::Null);
8896        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8897        let mut marketType = get_arg(optional_args, 2, Value::Null);
8898        let mut leverageStructures: Value = Value::Map({
8899            let mut m = indexmap::IndexMap::new();
8900            m
8901        });
8902        if (marketType == Value::Null) {
8903            marketType = Value::Str("swap".into()); // default to swap
8904        }
8905        {
8906                        let mut i: Value = Value::Int(0);
8907            let mut __for_first_169: bool = true;
8908            while { if !__for_first_169 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_169 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
8909            let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8910            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
8911            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
8912            if (symbols == Value::Null) || self.in_array(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), symbols.clone()).as_bool() == Some(true) {
8913                add_element_to_object(&mut leverageStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, info, &[market.clone()]));
8914            }
8915        }
8916        }
8917        return leverageStructures;
8918
8919    Value::Null
8920}
8921
8922    fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
8923        // virtual-dispatch (static: DerivedExchange::parse_leverage(self, ...))
8924        { let __v = crate::exchange::DerivedExchange::parse_leverage(self, leverage, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8925
8926        let mut market = get_arg(optional_args, 0, Value::Null);
8927        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLeverage () is not supported yet".into()))));
8928
8929    Value::Null
8930}
8931
8932    fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
8933        let mut code = get_arg(optional_args, 0, Value::Null);
8934        let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
8935        let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
8936        let mut since = get_arg(optional_args, 3, Value::Null);
8937        let mut limit = get_arg(optional_args, 4, Value::Null);
8938        let mut params = get_arg(optional_args, 5, Value::Map({
8939    let mut m = indexmap::IndexMap::new();
8940    m
8941}));
8942        let mut conversionsArray: Value = self.to_array(conversions);
8943        let mut result: Value = Value::from(vec![]);
8944        let mut fromCurrency: Value = Value::Null;
8945        let mut toCurrency: Value = Value::Null;
8946        {
8947                        let mut i: Value = Value::Int(0);
8948            let mut __for_first_170: bool = true;
8949            while { if !__for_first_170 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_170 = false; i.as_f64().unwrap_or(f64::NAN) < ((conversionsArray.len() as i64) as f64) } {
8950            let mut entry: Value = conversionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8951            let mut fromId: Value = (if (fromCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]) });
8952            let mut toId: Value = (if (toCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]) });
8953            if (fromId != Value::Null) {
8954                fromCurrency = self.safe_currency(fromId, &[]);
8955            }
8956            if (toId != Value::Null) {
8957                toCurrency = self.safe_currency(toId, &[]);
8958            }
8959            let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry, &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
8960            append_to_array(&mut result, conversion);
8961        }
8962        }
8963        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8964        let mut currency: Value = Value::Null;
8965        if (code != Value::Null) {
8966            currency = self.safe_currency(code.clone(), &[]);
8967            if (currency == Value::Null) {
8968                panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseConversions() could not resolve currency".into()))));
8969            }
8970            code = currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
8971        }
8972        if (code == Value::Null) {
8973            return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
8974        }
8975        let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".into()), code.clone(), &[]);
8976        let mut toConversion: Value = self.filter_by(sorted, Value::Str("toCurrency".into()), code, &[]);
8977        let mut both: Value = self.array_concat(fromConversion, toConversion);
8978        return self.filter_by_since_limit(both, &[since, limit]);
8979
8980    Value::Null
8981}
8982
8983    fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
8984        // virtual-dispatch (static: DerivedExchange::parse_conversion(self, ...))
8985        { let __v = crate::exchange::DerivedExchange::parse_conversion(self, conversion.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8986
8987        let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
8988        let mut toCurrency = get_arg(optional_args, 1, Value::Null);
8989        if (conversion == Value::Null) {
8990            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
8991        }
8992        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
8993
8994    Value::Null
8995}
8996
8997    fn convert_expire_date(&self, mut date: Value) -> Value {
8998        if (date == Value::Null) {
8999            return Value::Null;
9000        }
9001        // parse YYMMDD to datetime string
9002        let mut year: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9003        let mut month: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9004        let mut day: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(4); let __j = __l.min(6); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9005        // the milliseconds are spelled out because every caller writes the result into
9006        // expiryDatetime, which types.ts documents in the ISO 8601 form with them
9007        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("20".into()), year).into()), Value::Str("-".into())).into()), month).into()), Value::Str("-".into())).into()), day).into()), Value::Str("T00:00:00.000Z".into())).into());
9008        return reconstructedDate;
9009
9010    Value::Null
9011}
9012
9013    fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9014        if (date == Value::Null) {
9015            return Value::Null;
9016        }
9017        // parse 240119 to 19JAN24
9018        let mut year: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9019        let mut monthRaw: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9020        let mut month: Value = Value::Null;
9021        let mut day: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(4); let __j = __l.min(6); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9022        if (monthRaw.as_str() == Some("01")) {
9023            month = Value::Str("JAN".into());
9024        }  else if (monthRaw.as_str() == Some("02")) {
9025            month = Value::Str("FEB".into());
9026        }  else if (monthRaw.as_str() == Some("03")) {
9027            month = Value::Str("MAR".into());
9028        }  else if (monthRaw.as_str() == Some("04")) {
9029            month = Value::Str("APR".into());
9030        }  else if (monthRaw.as_str() == Some("05")) {
9031            month = Value::Str("MAY".into());
9032        }  else if (monthRaw.as_str() == Some("06")) {
9033            month = Value::Str("JUN".into());
9034        }  else if (monthRaw.as_str() == Some("07")) {
9035            month = Value::Str("JUL".into());
9036        }  else if (monthRaw.as_str() == Some("08")) {
9037            month = Value::Str("AUG".into());
9038        }  else if (monthRaw.as_str() == Some("09")) {
9039            month = Value::Str("SEP".into());
9040        }  else if (monthRaw.as_str() == Some("10")) {
9041            month = Value::Str("OCT".into());
9042        }  else if (monthRaw.as_str() == Some("11")) {
9043            month = Value::Str("NOV".into());
9044        }  else if (monthRaw.as_str() == Some("12")) {
9045            month = Value::Str("DEC".into());
9046        }
9047        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9048        return reconstructedDate;
9049
9050    Value::Null
9051}
9052
9053    fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9054        if (date == Value::Null) {
9055            return Value::Null;
9056        }
9057        // parse 03JAN24 to 240103.
9058        let mut monthMappping: Value = Value::Map({
9059            let mut m = indexmap::IndexMap::new();
9060                m.insert("JAN".to_string(), Value::Str("01".into()));
9061                m.insert("FEB".to_string(), Value::Str("02".into()));
9062                m.insert("MAR".to_string(), Value::Str("03".into()));
9063                m.insert("APR".to_string(), Value::Str("04".into()));
9064                m.insert("MAY".to_string(), Value::Str("05".into()));
9065                m.insert("JUN".to_string(), Value::Str("06".into()));
9066                m.insert("JUL".to_string(), Value::Str("07".into()));
9067                m.insert("AUG".to_string(), Value::Str("08".into()));
9068                m.insert("SEP".to_string(), Value::Str("09".into()));
9069                m.insert("OCT".to_string(), Value::Str("10".into()));
9070                m.insert("NOV".to_string(), Value::Str("11".into()));
9071                m.insert("DEC".to_string(), Value::Str("12".into()));
9072            m
9073        });
9074        // if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
9075        if (Value::Int(date.len() as i64).as_f64() == Some(6.0)) {
9076            date = Value::Str(format!("{}{}", Value::Str("0".into()), date).into());
9077        }
9078        let mut year: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9079        let mut monthName: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(5); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9080        let mut month: Value = self.safe_string(monthMappping, monthName, &[]);
9081        let mut day: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(5); let __j = __l.min(7); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9082        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9083        return reconstructedDate;
9084
9085    Value::Null
9086}
9087
9088    fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9089        promise_all(&Value::from(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9090
9091    Value::Null
9092} }
9093
9094    fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9095        // virtual-dispatch (static: DerivedExchange::parse_margin_modification(self, ...))
9096        { let __v = crate::exchange::DerivedExchange::parse_margin_modification(self, data.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
9097
9098        let mut market = get_arg(optional_args, 0, Value::Null);
9099        if (data == Value::Null) {
9100            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9101        }
9102        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9103
9104    Value::Null
9105}
9106
9107    fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9108        let mut symbols = get_arg(optional_args, 0, Value::Null);
9109        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9110        let mut marketType = get_arg(optional_args, 2, Value::Null);
9111        let mut marginModifications: Value = Value::from(vec![]);
9112        if (response == Value::Null) {
9113            return marginModifications;
9114        }
9115        {
9116                        let mut i: Value = Value::Int(0);
9117            let mut __for_first_171: bool = true;
9118            while { if !__for_first_171 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_171 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9119            let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9120            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9121            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
9122            if (symbols == Value::Null) || self.in_array(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), symbols.clone()).as_bool() == Some(true) {
9123                append_to_array(&mut marginModifications, <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info, &[market]));
9124            }
9125        }
9126        }
9127        return marginModifications;
9128
9129    Value::Null
9130}
9131
9132    fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9133        let mut code = get_arg(optional_args, 0, Value::Null);
9134        let mut params = get_arg(optional_args, 1, Value::Map({
9135    let mut m = indexmap::IndexMap::new();
9136    m
9137}));
9138        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfer () is not supported yet".into()))));
9139
9140    Value::Null
9141} }
9142
9143    fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9144        let mut code = get_arg(optional_args, 0, Value::Null);
9145        let mut since = get_arg(optional_args, 1, Value::Null);
9146        let mut limit = get_arg(optional_args, 2, Value::Null);
9147        let mut params = get_arg(optional_args, 3, Value::Map({
9148    let mut m = indexmap::IndexMap::new();
9149    m
9150}));
9151        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfers () is not supported yet".into()))));
9152
9153    Value::Null
9154} }
9155
9156    fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9157        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
9158        let mut params = get_arg(optional_args, 1, Value::Map({
9159    let mut m = indexmap::IndexMap::new();
9160    m
9161}));
9162        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCV () is not supported yet".into()))));
9163
9164    Value::Null
9165} }
9166
9167    fn withdraw_ws(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9168        let mut tag = get_arg(optional_args, 0, Value::Null);
9169        let mut params = get_arg(optional_args, 1, Value::Map({
9170    let mut m = indexmap::IndexMap::new();
9171    m
9172}));
9173        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdrawWs () is not supported yet".into()))));
9174
9175    Value::Null
9176} }
9177
9178    fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9179        let mut symbol = get_arg(optional_args, 0, Value::Null);
9180        let mut params = get_arg(optional_args, 1, Value::Map({
9181    let mut m = indexmap::IndexMap::new();
9182    m
9183}));
9184        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMyTrades () is not supported yet".into()))));
9185
9186    Value::Null
9187} }
9188
9189    fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9190        let mut symbol = get_arg(optional_args, 0, Value::Null);
9191        let mut since = get_arg(optional_args, 1, Value::Null);
9192        let mut limit = get_arg(optional_args, 2, Value::Null);
9193        let mut params = get_arg(optional_args, 3, Value::Map({
9194    let mut m = indexmap::IndexMap::new();
9195    m
9196}));
9197        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersByStatusWs () is not supported yet".into()))));
9198
9199    Value::Null
9200} }
9201
9202    fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9203        let mut symbols = get_arg(optional_args, 0, Value::Null);
9204        let mut params = get_arg(optional_args, 1, Value::Map({
9205    let mut m = indexmap::IndexMap::new();
9206    m
9207}));
9208        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchBidsAsks () is not supported yet".into()))));
9209
9210    Value::Null
9211} }
9212
9213    fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9214        let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9215        if (unsubHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &unsubHash)) {
9216            remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &unsubHash);
9217        }
9218        if !is_true(&subHashIsPrefix) {
9219            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &subHash)) {
9220                remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &subHash);
9221            }
9222            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("futures".into())), &subHash)) {
9223                let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), subHash));
9224                client.reject(&[Value::from(error.clone()), subHash.clone()]);
9225            }
9226        }  else {
9227            let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".into())));
9228            {
9229                                let mut i: Value = Value::Int(0);
9230                let mut __for_first_172: bool = true;
9231                while { if !__for_first_172 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_172 = false; i.as_f64().unwrap_or(f64::NAN) < ((clientSubscriptions.len() as i64) as f64) } {
9232                let mut sub: Value = clientSubscriptions.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9233                if (sub != Value::Null) && (subHash != Value::Null) && (starts_with(&sub, &subHash)) {
9234                    remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &sub);
9235                }
9236            }
9237            }
9238            let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
9239            {
9240                                let mut i: Value = Value::Int(0);
9241                let mut __for_first_173: bool = true;
9242                while { if !__for_first_173 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_173 = false; i.as_f64().unwrap_or(f64::NAN) < ((clientFutures.len() as i64) as f64) } {
9243                let mut future: Value = clientFutures.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9244                if (future != Value::Null) && (subHash != Value::Null) && (starts_with(&future, &subHash)) {
9245                    let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), future));
9246                    client.reject(&[Value::from(error), future.clone()]);
9247                }
9248            }
9249            }
9250        }
9251        client.resolve(&[Value::Bool(true), unsubHash]);
9252}
9253
9254    fn clean_cache(&mut self, mut subscription: Value) {
9255        let __subscription_empty = indexmap::IndexMap::new();
9256        let subscription = subscription.as_map().unwrap_or(&__subscription_empty);
9257        let mut topic: Option<String> = (match subscription.get("topic") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null }).as_str().map(str::to_owned);
9258        let mut symbols: Value = (match subscription.get("symbols") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9259        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
9260        if (topic.as_deref() == Some("ohlcv")) {
9261            let mut symbolsAndTimeframes: Value = (match subscription.get("symbolsAndTimeframes") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9262            {
9263                                let mut i: Value = Value::Int(0);
9264                let mut __for_first_174: bool = true;
9265                while { if !__for_first_174 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_174 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbolsAndTimeframes.len() as i64) as f64) } {
9266                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9267                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9268                let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9269                let mut timeframe: Value = self.safe_string(symbolAndTimeFrame, Value::Int(1), &[]);
9270                if (symbol == Value::Null) {
9271                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a symbol argument".into()))));
9272                }
9273                if (timeframe == Value::Null) {
9274                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a timeframe argument".into()))));
9275                }
9276                if (self.ohlcvs.clone() != Value::Null) && (in_op(&self.ohlcvs, &symbol)) {
9277                    if (in_op(&get_value(&self.ohlcvs, &symbol), &timeframe)) {
9278                        remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
9279                    }
9280                }
9281            }
9282            }
9283        }  else if symbolsLength > ((0i64) as f64) {
9284            {
9285                                let mut i: Value = Value::Int(0);
9286                let mut __for_first_175: bool = true;
9287                while { if !__for_first_175 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_175 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
9288                let mut symbol: Value = get_value(&symbols, &i);
9289                let mut symbol: Value = get_value(&symbols, &i);
9290                if (topic.as_deref() == Some("trades")) {
9291                    if (in_op(&self.trades, &symbol)) {
9292                        remove(&mut self.trades.clone(), &symbol);
9293                    }
9294                }  else if (topic.as_deref() == Some("orderbook")) {
9295                    if (in_op(&self.orderbooks, &symbol)) {
9296                        remove(&mut self.orderbooks.clone(), &symbol);
9297                    }
9298                }  else if (topic.as_deref() == Some("ticker")) {
9299                    if (in_op(&self.tickers, &symbol)) {
9300                        remove(&mut self.tickers.clone(), &symbol);
9301                    }
9302                }  else if (topic.as_deref() == Some("bidsasks")) {
9303                    if (in_op(&self.bidsasks, &symbol)) {
9304                        remove(&mut self.bidsasks.clone(), &symbol);
9305                    }
9306                }
9307            }
9308            }
9309        }  else {
9310            if (topic.as_deref() == Some("myTrades")) && (self.myTrades.clone() != Value::Null) {
9311                self.myTrades = Value::Null;
9312            }  else if (topic.as_deref() == Some("orders")) && (self.orders.clone() != Value::Null) {
9313                self.orders = Value::Null;
9314            }  else if (topic.as_deref() == Some("positions")) && (self.positions.clone() != Value::Null) {
9315                self.positions = Value::Null;
9316                let mut clients: Value = object_values(&self.clients);
9317                {
9318                                        let mut i: Value = Value::Int(0);
9319                    let mut __for_first_176: bool = true;
9320                    while { if !__for_first_176 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_176 = false; i.as_f64().unwrap_or(f64::NAN) < ((clients.len() as i64) as f64) } {
9321                    let mut client: Value = clients.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9322                    let mut futures: Value = get_value(&client, &Value::Str("futures".into()));
9323                    if (futures != Value::Null) && (matches!(&futures, Value::Dict(__d) if __d.contains_key("fetchPositionsSnapshot"))) {
9324                        remove(&mut futures, &Value::Str("fetchPositionsSnapshot".into()));
9325                    }
9326                }
9327                }
9328            }  else if ((topic.as_deref() == Some("ticker")) || (topic.as_deref() == Some("markPrice"))) && (self.tickers.clone() != Value::Null) {
9329                let mut tickerSymbols: Value = object_keys(&self.tickers);
9330                {
9331                                        let mut i: Value = Value::Int(0);
9332                    let mut __for_first_177: bool = true;
9333                    while { if !__for_first_177 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_177 = false; i.as_f64().unwrap_or(f64::NAN) < ((tickerSymbols.len() as i64) as f64) } {
9334                    let mut tickerSymbol: Value = tickerSymbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9335                    if (in_op(&self.tickers, &tickerSymbol)) {
9336                        remove(&mut self.tickers.clone(), &tickerSymbol);
9337                    }
9338                }
9339                }
9340            }  else if (topic.as_deref() == Some("bidsasks")) && (self.bidsasks.clone() != Value::Null) {
9341                let mut bidsaskSymbols: Value = object_keys(&self.bidsasks);
9342                {
9343                                        let mut i: Value = Value::Int(0);
9344                    let mut __for_first_178: bool = true;
9345                    while { if !__for_first_178 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_178 = false; i.as_f64().unwrap_or(f64::NAN) < ((bidsaskSymbols.len() as i64) as f64) } {
9346                    let mut bidsaskSymbol: Value = bidsaskSymbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9347                    if (in_op(&self.bidsasks, &bidsaskSymbol)) {
9348                        remove(&mut self.bidsasks.clone(), &bidsaskSymbol);
9349                    }
9350                }
9351                }
9352            }
9353        }
9354}
9355
9356    fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9357        if ms.as_f64().unwrap_or(f64::NAN) <= ((0i64) as f64) {
9358            return Value::Str("".into());
9359        }
9360        let mut second: Value = Value::Int(1000);
9361        let mut minute: Value = (match (&(Value::Int(60)), &(second)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
9362        let mut hour: Value = (match (&(Value::Int(60)), &(minute)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
9363        let mut day: Value = (match (&(Value::Int(24)), &(hour)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
9364        let mut week: Value = (match (&(Value::Int(7)), &(day)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
9365        if (mod_val(&ms, &week).as_f64() == Some(0.0)) {
9366            return add(&((match ((ms).as_f64(), (week).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("w".into()));
9367        }
9368        if (mod_val(&ms, &day).as_f64() == Some(0.0)) {
9369            return add(&((match ((ms).as_f64(), (day).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("d".into()));
9370        }
9371        if (mod_val(&ms, &hour).as_f64() == Some(0.0)) {
9372            return add(&((match ((ms).as_f64(), (hour).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("h".into()));
9373        }
9374        if (mod_val(&ms, &minute).as_f64() == Some(0.0)) {
9375            return add(&((match ((ms).as_f64(), (minute).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("m".into()));
9376        }
9377        if (mod_val(&ms, &second).as_f64() == Some(0.0)) {
9378            return add(&((match ((ms).as_f64(), (second).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("s".into()));
9379        }
9380        return Value::Str("".into());
9381
9382    Value::Null
9383}
9384
9385    fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9386        let mut params = get_arg(optional_args, 0, Value::Map({
9387    let mut m = indexmap::IndexMap::new();
9388    m
9389}));
9390        return Value::Bool(false);
9391
9392    Value::Null
9393} }
9394    fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9395        let mut side = get_arg(optional_args, 0, Value::Null);
9396        let mut params = get_arg(optional_args, 1, Value::Map({
9397    let mut m = indexmap::IndexMap::new();
9398    m
9399}));
9400        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closePosition() is not supported yet".into()))));
9401
9402    Value::Null
9403} }
9404
9405    fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9406        let mut params = get_arg(optional_args, 0, Value::Map({
9407    let mut m = indexmap::IndexMap::new();
9408    m
9409}));
9410        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closeAllPositions() is not supported yet".into()))));
9411
9412    Value::Null
9413} }
9414
9415    fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9416        let mut params = get_arg(optional_args, 0, Value::Map({
9417    let mut m = indexmap::IndexMap::new();
9418    m
9419}));
9420        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" editOrders() is not supported yet".into()))));
9421
9422    Value::Null
9423} }
9424
9425    fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9426        let mut symbol = get_arg(optional_args, 0, Value::Null);
9427        let mut since = get_arg(optional_args, 1, Value::Null);
9428        let mut limit = get_arg(optional_args, 2, Value::Null);
9429        let mut params = get_arg(optional_args, 3, Value::Map({
9430    let mut m = indexmap::IndexMap::new();
9431    m
9432}));
9433        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".into()))));
9434
9435    Value::Null
9436} }
9437
9438    fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9439        // async-virtual: try the derived exchange first
9440        if let Some(__v) = self.dispatch_to_derived("fetch_position_history", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
9441            if !matches!(__v, crate::Value::Null) { return __v; }
9442        }
9443
9444        let mut since = get_arg(optional_args, 0, Value::Null);
9445        let mut limit = get_arg(optional_args, 1, Value::Null);
9446        let mut params = get_arg(optional_args, 2, Value::Map({
9447    let mut m = indexmap::IndexMap::new();
9448    m
9449}));
9450        /*
9451         * @method
9452         * @name exchange#fetchPositionHistory
9453         * @description fetches the history of margin added or reduced from contract isolated positions
9454         * @param {string} [symbol] unified market symbol
9455         * @param {int} [since] timestamp in ms of the position
9456         * @param {int} [limit] the maximum amount of candles to fetch, default=1000
9457         * @param {object} params extra parameters specific to the exchange api endpoint
9458         * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
9459         */
9460        if (self.has.as_map().and_then(|__m| __m.get("fetchPositionsHistory")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchPositionsHistory")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
9461            let mut positions: Value = self.fetch_positions_history(&[Value::from(vec![symbol]), since, limit, params]).await;
9462            return positions;
9463        }  else {
9464            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionHistory () is not supported yet".into()))));
9465        }
9466} }
9467
9468    fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9469        // async-virtual: try the derived exchange first
9470        if let Some(__v) = self.dispatch_to_derived("fetch_positions_history", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
9471            if !matches!(__v, crate::Value::Null) { return __v; }
9472        }
9473
9474        let mut symbols = get_arg(optional_args, 0, Value::Null);
9475        let mut since = get_arg(optional_args, 1, Value::Null);
9476        let mut limit = get_arg(optional_args, 2, Value::Null);
9477        let mut params = get_arg(optional_args, 3, Value::Map({
9478    let mut m = indexmap::IndexMap::new();
9479    m
9480}));
9481        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsHistory () is not supported yet".into()))));
9482
9483    Value::Null
9484} }
9485
9486    fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9487        let mut symbols = get_arg(optional_args, 0, Value::Null);
9488        let mut params = get_arg(optional_args, 1, Value::Map({
9489    let mut m = indexmap::IndexMap::new();
9490    m
9491}));
9492        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsRisk() is not supported yet".into()))));
9493
9494    Value::Null
9495} }
9496
9497    fn fetch_positions_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9498        let mut params = get_arg(optional_args, 0, Value::Map({
9499    let mut m = indexmap::IndexMap::new();
9500    m
9501}));
9502        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9503
9504    Value::Null
9505} }
9506
9507    fn fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9508        let mut params = get_arg(optional_args, 0, Value::Map({
9509    let mut m = indexmap::IndexMap::new();
9510    m
9511}));
9512        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9513
9514    Value::Null
9515} }
9516
9517    fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9518        let mut symbol = get_arg(optional_args, 0, Value::Null);
9519        let mut params = get_arg(optional_args, 1, Value::Map({
9520    let mut m = indexmap::IndexMap::new();
9521    m
9522}));
9523        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPosition() is not supported yet".into()))));
9524
9525    Value::Null
9526} }
9527
9528    fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9529        let mut since = get_arg(optional_args, 0, Value::Null);
9530        let mut limit = get_arg(optional_args, 1, Value::Null);
9531        let mut params = get_arg(optional_args, 2, Value::Map({
9532    let mut m = indexmap::IndexMap::new();
9533    m
9534}));
9535        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTradesForSymbols() is not supported yet".into()))));
9536
9537    Value::Null
9538} }
9539
9540    fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9541        let mut since = get_arg(optional_args, 0, Value::Null);
9542        let mut limit = get_arg(optional_args, 1, Value::Null);
9543        let mut params = get_arg(optional_args, 2, Value::Map({
9544    let mut m = indexmap::IndexMap::new();
9545    m
9546}));
9547        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTradesForSymbols() is not supported yet".into()))));
9548
9549    Value::Null
9550} }
9551
9552    fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9553        let mut symbols = get_arg(optional_args, 0, Value::Null);
9554        let mut params = get_arg(optional_args, 1, Value::Map({
9555    let mut m = indexmap::IndexMap::new();
9556    m
9557}));
9558        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBidsAsks() is not supported yet".into()))));
9559
9560    Value::Null
9561} }
9562
9563    fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9564        let mut params = get_arg(optional_args, 0, Value::Map({
9565    let mut m = indexmap::IndexMap::new();
9566    m
9567}));
9568        if (self.has.as_map().and_then(|__m| __m.get("fetchMarkPrices")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchMarkPrices")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
9569            self.load_markets(&[]).await;
9570            let mut market: Value = self.market(symbol.clone());
9571            symbol = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
9572            let mut tickers: Value = self.fetch_mark_prices(&[Value::from(vec![symbol.clone()]), params]).await;
9573            let mut ticker: Value = self.safe_dict(tickers, symbol.clone(), &[]);
9574            if (ticker == Value::Null) {
9575                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() could not find a ticker for ".into())).into()), symbol)));
9576            }  else {
9577                return ticker;
9578            }
9579        }  else {
9580            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9581        }
9582
9583    Value::Null
9584} }
9585
9586    fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9587        let mut symbols = get_arg(optional_args, 0, Value::Null);
9588        let mut params = get_arg(optional_args, 1, Value::Map({
9589    let mut m = indexmap::IndexMap::new();
9590    m
9591}));
9592        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9593
9594    Value::Null
9595} }
9596
9597    fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9598        let mut symbols = get_arg(optional_args, 0, Value::Null);
9599        let mut params = get_arg(optional_args, 1, Value::Map({
9600    let mut m = indexmap::IndexMap::new();
9601    m
9602}));
9603        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBidsAsks() is not supported yet".into()))));
9604
9605    Value::Null
9606} }
9607
9608    fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9609        let mut params = get_arg(optional_args, 0, Value::Map({
9610    let mut m = indexmap::IndexMap::new();
9611    m
9612}));
9613        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrice () is not supported yet".into()))));
9614
9615    Value::Null
9616} }
9617
9618    fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9619        let mut symbols = get_arg(optional_args, 0, Value::Null);
9620        let mut params = get_arg(optional_args, 1, Value::Map({
9621    let mut m = indexmap::IndexMap::new();
9622    m
9623}));
9624        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrices () is not supported yet".into()))));
9625
9626    Value::Null
9627} }
9628
9629    fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9630        let mut limit = get_arg(optional_args, 0, Value::Null);
9631        let mut params = get_arg(optional_args, 1, Value::Map({
9632    let mut m = indexmap::IndexMap::new();
9633    m
9634}));
9635        panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchL3OrderBook() is not supported yet".into()))));
9636
9637    Value::Null
9638} }
9639
9640    fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9641        let mut limit = get_arg(optional_args, 0, Value::Null);
9642        let mut params = get_arg(optional_args, 1, Value::Map({
9643    let mut m = indexmap::IndexMap::new();
9644    m
9645}));
9646        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBookForSymbols() is not supported yet".into()))));
9647
9648    Value::Null
9649} }
9650
9651    fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9652        let mut since = get_arg(optional_args, 0, Value::Null);
9653        let mut limit = get_arg(optional_args, 1, Value::Null);
9654        let mut params = get_arg(optional_args, 2, Value::Map({
9655    let mut m = indexmap::IndexMap::new();
9656    m
9657}));
9658        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrdersForSymbols() is not supported yet".into()))));
9659
9660    Value::Null
9661} }
9662
9663    fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9664        let mut symbol = get_arg(optional_args, 0, Value::Null);
9665        let mut params = get_arg(optional_args, 1, Value::Map({
9666    let mut m = indexmap::IndexMap::new();
9667    m
9668}));
9669        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersWs() is not supported yet".into()))));
9670
9671    Value::Null
9672} }
9673
9674    fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9675        let mut symbol = get_arg(optional_args, 0, Value::Null);
9676        let mut params = get_arg(optional_args, 1, Value::Map({
9677    let mut m = indexmap::IndexMap::new();
9678    m
9679}));
9680        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrderWs() is not supported yet".into()))));
9681
9682    Value::Null
9683} }
9684
9685    fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9686        let mut symbol = get_arg(optional_args, 0, Value::Null);
9687        let mut params = get_arg(optional_args, 1, Value::Map({
9688    let mut m = indexmap::IndexMap::new();
9689    m
9690}));
9691        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersWs() is not supported yet".into()))));
9692
9693    Value::Null
9694} }
9695
9696    fn create_limit_buy_order_ws(&mut self, mut symbol: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9697        let mut params = get_arg(optional_args, 0, Value::Map({
9698    let mut m = indexmap::IndexMap::new();
9699    m
9700}));
9701        return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
9702
9703    Value::Null
9704} }
9705
9706    fn create_limit_order_ws(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9707        let mut params = get_arg(optional_args, 0, Value::Map({
9708    let mut m = indexmap::IndexMap::new();
9709    m
9710}));
9711        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
9712
9713    Value::Null
9714} }
9715
9716    fn create_limit_sell_order_ws(&mut self, mut symbol: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9717        let mut params = get_arg(optional_args, 0, Value::Map({
9718    let mut m = indexmap::IndexMap::new();
9719    m
9720}));
9721        return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
9722
9723    Value::Null
9724} }
9725
9726    fn create_market_buy_order_ws(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9727        let mut params = get_arg(optional_args, 0, Value::Map({
9728    let mut m = indexmap::IndexMap::new();
9729    m
9730}));
9731        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
9732
9733    Value::Null
9734} }
9735
9736    fn create_market_order_with_cost_ws(&mut self, mut symbol: Value, mut side: Value, mut cost: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9737        let mut params = get_arg(optional_args, 0, Value::Map({
9738    let mut m = indexmap::IndexMap::new();
9739    m
9740}));
9741        /*
9742         * @method
9743         * @name createMarketOrderWithCostWs
9744         * @description create a market order by providing the symbol, side and cost
9745         * @param {string} symbol unified symbol of the market to create an order in
9746         * @param {string} side 'buy' or 'sell'
9747         * @param {float} cost how much you want to trade in units of the quote currency
9748         * @param {object} [params] extra parameters specific to the exchange API endpoint
9749         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
9750         */
9751        if ((self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) || (((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)))) {
9752            return self.create_order_ws(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
9753        }
9754        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCostWs() is not supported yet".into()))));
9755
9756    Value::Null
9757} }
9758
9759    fn create_market_order_ws(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9760        let mut price = get_arg(optional_args, 0, Value::Null);
9761        let mut params = get_arg(optional_args, 1, Value::Map({
9762    let mut m = indexmap::IndexMap::new();
9763    m
9764}));
9765        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
9766
9767    Value::Null
9768} }
9769
9770    fn create_market_sell_order_ws(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9771        let mut params = get_arg(optional_args, 0, Value::Map({
9772    let mut m = indexmap::IndexMap::new();
9773    m
9774}));
9775        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
9776
9777    Value::Null
9778} }
9779
9780    fn create_order_with_take_profit_and_stop_loss_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9781        let mut price = get_arg(optional_args, 0, Value::Null);
9782        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
9783        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
9784        let mut params = get_arg(optional_args, 3, Value::Map({
9785    let mut m = indexmap::IndexMap::new();
9786    m
9787}));
9788        /*
9789         * @method
9790         * @name createOrderWithTakeProfitAndStopLossWs
9791         * @description create an order with a stop loss or take profit attached (type 3)
9792         * @param {string} symbol unified symbol of the market to create an order in
9793         * @param {string} type 'market' or 'limit'
9794         * @param {string} side 'buy' or 'sell'
9795         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
9796         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
9797         * @param {float} [takeProfit] the take profit price, in units of the quote currency
9798         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
9799         * @param {object} [params] extra parameters specific to the exchange API endpoint
9800         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
9801         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
9802         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
9803         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
9804         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
9805         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
9806         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
9807         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
9808         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
9809         */
9810        params = self.set_take_profit_and_stop_loss_params(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), takeProfit.clone(), stopLoss.clone(), params.clone()]);
9811        if (self.has.as_map().and_then(|__m| __m.get("createOrderWithTakeProfitAndStopLossWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createOrderWithTakeProfitAndStopLossWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
9812            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
9813        }
9814        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".into()))));
9815
9816    Value::Null
9817} }
9818
9819    fn create_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9820        let mut price = get_arg(optional_args, 0, Value::Null);
9821        let mut params = get_arg(optional_args, 1, Value::Map({
9822    let mut m = indexmap::IndexMap::new();
9823    m
9824}));
9825        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWs() is not supported yet".into()))));
9826
9827    Value::Null
9828} }
9829
9830    fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9831        let mut params = get_arg(optional_args, 0, Value::Map({
9832    let mut m = indexmap::IndexMap::new();
9833    m
9834}));
9835        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrdersWs () is not supported yet".into()))));
9836
9837    Value::Null
9838} }
9839
9840    fn create_post_only_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9841        let mut price = get_arg(optional_args, 0, Value::Null);
9842        let mut params = get_arg(optional_args, 1, Value::Map({
9843    let mut m = indexmap::IndexMap::new();
9844    m
9845}));
9846        if (self.has.as_map().and_then(|__m| __m.get("createPostOnlyOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createPostOnlyOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
9847            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrderWs() is not supported yet".into()))));
9848        }
9849        let mut query: Value = self.extend(params, &[Value::Map({
9850            let mut m = indexmap::IndexMap::new();
9851                m.insert("postOnly".to_string(), Value::Bool(true));
9852            m
9853        })]);
9854        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
9855
9856    Value::Null
9857} }
9858
9859    fn create_reduce_only_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9860        let mut price = get_arg(optional_args, 0, Value::Null);
9861        let mut params = get_arg(optional_args, 1, Value::Map({
9862    let mut m = indexmap::IndexMap::new();
9863    m
9864}));
9865        if (self.has.as_map().and_then(|__m| __m.get("createReduceOnlyOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createReduceOnlyOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
9866            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrderWs() is not supported yet".into()))));
9867        }
9868        let mut query: Value = self.extend(params, &[Value::Map({
9869            let mut m = indexmap::IndexMap::new();
9870                m.insert("reduceOnly".to_string(), Value::Bool(true));
9871            m
9872        })]);
9873        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
9874
9875    Value::Null
9876} }
9877
9878    fn create_stop_limit_order_ws(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut price: Value, mut triggerPrice: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9879        let mut params = get_arg(optional_args, 0, Value::Map({
9880    let mut m = indexmap::IndexMap::new();
9881    m
9882}));
9883        if (self.has.as_map().and_then(|__m| __m.get("createStopLimitOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopLimitOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
9884            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrderWs() is not supported yet".into()))));
9885        }
9886        let mut query: Value = self.extend(params, &[Value::Map({
9887            let mut m = indexmap::IndexMap::new();
9888                m.insert("stopPrice".to_string(), triggerPrice);
9889            m
9890        })]);
9891        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
9892
9893    Value::Null
9894} }
9895
9896    fn create_stop_loss_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9897        let mut price = get_arg(optional_args, 0, Value::Null);
9898        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
9899        let mut params = get_arg(optional_args, 2, Value::Map({
9900    let mut m = indexmap::IndexMap::new();
9901    m
9902}));
9903        /*
9904         * @method
9905         * @name createStopLossOrderWs
9906         * @description create a trigger stop loss order (type 2)
9907         * @param {string} symbol unified symbol of the market to create an order in
9908         * @param {string} type 'market' or 'limit'
9909         * @param {string} side 'buy' or 'sell'
9910         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
9911         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
9912         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
9913         * @param {object} [params] extra parameters specific to the exchange API endpoint
9914         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
9915         */
9916        if (stopLossPrice == Value::Null) {
9917            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".into()))));
9918        }
9919        params = self.extend(params.clone(), &[Value::Map({
9920            let mut m = indexmap::IndexMap::new();
9921                m.insert("stopLossPrice".to_string(), stopLossPrice);
9922            m
9923        })]);
9924        if (self.has.as_map().and_then(|__m| __m.get("createStopLossOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createStopLossOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
9925            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
9926        }
9927        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() is not supported yet".into()))));
9928
9929    Value::Null
9930} }
9931
9932    fn create_stop_market_order_ws(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut triggerPrice: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9933        let mut params = get_arg(optional_args, 0, Value::Map({
9934    let mut m = indexmap::IndexMap::new();
9935    m
9936}));
9937        if (self.has.as_map().and_then(|__m| __m.get("createStopMarketOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopMarketOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
9938            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrderWs() is not supported yet".into()))));
9939        }
9940        let mut query: Value = self.extend(params, &[Value::Map({
9941            let mut m = indexmap::IndexMap::new();
9942                m.insert("stopPrice".to_string(), triggerPrice);
9943            m
9944        })]);
9945        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
9946
9947    Value::Null
9948} }
9949
9950    fn create_stop_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9951        let mut price = get_arg(optional_args, 0, Value::Null);
9952        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
9953        let mut params = get_arg(optional_args, 2, Value::Map({
9954    let mut m = indexmap::IndexMap::new();
9955    m
9956}));
9957        if (self.has.as_map().and_then(|__m| __m.get("createStopOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
9958            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() is not supported yet".into()))));
9959        }
9960        if (triggerPrice == Value::Null) {
9961            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() requires a stopPrice argument".into()))));
9962        }
9963        let mut query: Value = self.extend(params, &[Value::Map({
9964            let mut m = indexmap::IndexMap::new();
9965                m.insert("stopPrice".to_string(), triggerPrice);
9966            m
9967        })]);
9968        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
9969
9970    Value::Null
9971} }
9972
9973    fn create_take_profit_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9974        let mut price = get_arg(optional_args, 0, Value::Null);
9975        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
9976        let mut params = get_arg(optional_args, 2, Value::Map({
9977    let mut m = indexmap::IndexMap::new();
9978    m
9979}));
9980        /*
9981         * @method
9982         * @name createTakeProfitOrderWs
9983         * @description create a trigger take profit order (type 2)
9984         * @param {string} symbol unified symbol of the market to create an order in
9985         * @param {string} type 'market' or 'limit'
9986         * @param {string} side 'buy' or 'sell'
9987         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
9988         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
9989         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
9990         * @param {object} [params] extra parameters specific to the exchange API endpoint
9991         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
9992         */
9993        if (takeProfitPrice == Value::Null) {
9994            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".into()))));
9995        }
9996        params = self.extend(params.clone(), &[Value::Map({
9997            let mut m = indexmap::IndexMap::new();
9998                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
9999            m
10000        })]);
10001        if (self.has.as_map().and_then(|__m| __m.get("createTakeProfitOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTakeProfitOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10002            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10003        }
10004        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() is not supported yet".into()))));
10005
10006    Value::Null
10007} }
10008
10009    fn create_trailing_amount_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10010        let mut price = get_arg(optional_args, 0, Value::Null);
10011        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10012        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10013        let mut params = get_arg(optional_args, 3, Value::Map({
10014    let mut m = indexmap::IndexMap::new();
10015    m
10016}));
10017        /*
10018         * @method
10019         * @name createTrailingAmountOrderWs
10020         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
10021         * @param {string} symbol unified symbol of the market to create an order in
10022         * @param {string} type 'market' or 'limit'
10023         * @param {string} side 'buy' or 'sell'
10024         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10025         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10026         * @param {float} trailingAmount the quote amount to trail away from the current market price
10027         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10028         * @param {object} [params] extra parameters specific to the exchange API endpoint
10029         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10030         */
10031        if (trailingAmount == Value::Null) {
10032            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".into()))));
10033        }
10034        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10035        if (trailingTriggerPrice != Value::Null) {
10036            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10037        }
10038        if (self.has.as_map().and_then(|__m| __m.get("createTrailingAmountOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTrailingAmountOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10039            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10040        }
10041        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() is not supported yet".into()))));
10042
10043    Value::Null
10044} }
10045
10046    fn create_trailing_percent_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10047        let mut price = get_arg(optional_args, 0, Value::Null);
10048        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10049        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10050        let mut params = get_arg(optional_args, 3, Value::Map({
10051    let mut m = indexmap::IndexMap::new();
10052    m
10053}));
10054        /*
10055         * @method
10056         * @name createTrailingPercentOrderWs
10057         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
10058         * @param {string} symbol unified symbol of the market to create an order in
10059         * @param {string} type 'market' or 'limit'
10060         * @param {string} side 'buy' or 'sell'
10061         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10062         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10063         * @param {float} trailingPercent the percent to trail away from the current market price
10064         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10065         * @param {object} [params] extra parameters specific to the exchange API endpoint
10066         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10067         */
10068        if (trailingPercent == Value::Null) {
10069            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".into()))));
10070        }
10071        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10072        if (trailingTriggerPrice != Value::Null) {
10073            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10074        }
10075        if (self.has.as_map().and_then(|__m| __m.get("createTrailingPercentOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTrailingPercentOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10076            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10077        }
10078        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() is not supported yet".into()))));
10079
10080    Value::Null
10081} }
10082
10083    fn create_trigger_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10084        let mut price = get_arg(optional_args, 0, Value::Null);
10085        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10086        let mut params = get_arg(optional_args, 2, Value::Map({
10087    let mut m = indexmap::IndexMap::new();
10088    m
10089}));
10090        /*
10091         * @method
10092         * @name createTriggerOrderWs
10093         * @description create a trigger stop order (type 1)
10094         * @param {string} symbol unified symbol of the market to create an order in
10095         * @param {string} type 'market' or 'limit'
10096         * @param {string} side 'buy' or 'sell'
10097         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10098         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10099         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10100         * @param {object} [params] extra parameters specific to the exchange API endpoint
10101         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10102         */
10103        if (triggerPrice == Value::Null) {
10104            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".into()))));
10105        }
10106        params = self.extend(params.clone(), &[Value::Map({
10107            let mut m = indexmap::IndexMap::new();
10108                m.insert("triggerPrice".to_string(), triggerPrice);
10109            m
10110        })]);
10111        if (self.has.as_map().and_then(|__m| __m.get("createTriggerOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTriggerOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10112            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10113        }
10114        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() is not supported yet".into()))));
10115
10116    Value::Null
10117} }
10118
10119    fn edit_order_ws(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10120        let mut amount = get_arg(optional_args, 0, Value::Null);
10121        let mut price = get_arg(optional_args, 1, Value::Null);
10122        let mut params = get_arg(optional_args, 2, Value::Map({
10123    let mut m = indexmap::IndexMap::new();
10124    m
10125}));
10126        self.cancel_order_ws(id, &[symbol.clone()]).await;
10127        return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10128
10129    Value::Null
10130} }
10131
10132    fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10133        let mut symbol = get_arg(optional_args, 0, Value::Null);
10134        let mut since = get_arg(optional_args, 1, Value::Null);
10135        let mut limit = get_arg(optional_args, 2, Value::Null);
10136        let mut params = get_arg(optional_args, 3, Value::Map({
10137    let mut m = indexmap::IndexMap::new();
10138    m
10139}));
10140        if (self.has.as_map().and_then(|__m| __m.get("fetchOrdersWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOrdersWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10141            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10142            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
10143        }
10144        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrdersWs() is not supported yet".into()))));
10145
10146    Value::Null
10147} }
10148
10149    fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10150        let mut symbol = get_arg(optional_args, 0, Value::Null);
10151        let mut since = get_arg(optional_args, 1, Value::Null);
10152        let mut limit = get_arg(optional_args, 2, Value::Null);
10153        let mut params = get_arg(optional_args, 3, Value::Map({
10154    let mut m = indexmap::IndexMap::new();
10155    m
10156}));
10157        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTradesWs() is not supported yet".into()))));
10158
10159    Value::Null
10160} }
10161
10162    fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10163        let mut symbol = get_arg(optional_args, 0, Value::Null);
10164        let mut since = get_arg(optional_args, 1, Value::Null);
10165        let mut limit = get_arg(optional_args, 2, Value::Null);
10166        let mut params = get_arg(optional_args, 3, Value::Map({
10167    let mut m = indexmap::IndexMap::new();
10168    m
10169}));
10170        if (self.has.as_map().and_then(|__m| __m.get("fetchOrdersWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOrdersWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10171            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10172            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
10173        }
10174        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrdersWs() is not supported yet".into()))));
10175
10176    Value::Null
10177} }
10178
10179    fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10180        let mut limit = get_arg(optional_args, 0, Value::Null);
10181        let mut params = get_arg(optional_args, 1, Value::Map({
10182    let mut m = indexmap::IndexMap::new();
10183    m
10184}));
10185        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBookWs() is not supported yet".into()))));
10186
10187    Value::Null
10188} }
10189
10190    fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10191        let mut symbol = get_arg(optional_args, 0, Value::Null);
10192        let mut params = get_arg(optional_args, 1, Value::Map({
10193    let mut m = indexmap::IndexMap::new();
10194    m
10195}));
10196        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderWs() is not supported yet".into()))));
10197
10198    Value::Null
10199} }
10200
10201    fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10202        let mut symbol = get_arg(optional_args, 0, Value::Null);
10203        let mut since = get_arg(optional_args, 1, Value::Null);
10204        let mut limit = get_arg(optional_args, 2, Value::Null);
10205        let mut params = get_arg(optional_args, 3, Value::Map({
10206    let mut m = indexmap::IndexMap::new();
10207    m
10208}));
10209        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersWs() is not supported yet".into()))));
10210
10211    Value::Null
10212} }
10213
10214    fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10215        let mut params = get_arg(optional_args, 0, Value::Map({
10216    let mut m = indexmap::IndexMap::new();
10217    m
10218}));
10219        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionWs() is not supported yet".into()))));
10220
10221    Value::Null
10222} }
10223
10224    fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10225        let mut symbols = get_arg(optional_args, 0, Value::Null);
10226        let mut params = get_arg(optional_args, 1, Value::Map({
10227    let mut m = indexmap::IndexMap::new();
10228    m
10229}));
10230        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10231
10232    Value::Null
10233} }
10234
10235    fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10236        let mut params = get_arg(optional_args, 0, Value::Map({
10237    let mut m = indexmap::IndexMap::new();
10238    m
10239}));
10240        if (self.has.as_map().and_then(|__m| __m.get("fetchTickersWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTickersWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10241            self.load_markets(&[]).await;
10242            let mut market: Value = self.market(symbol.clone());
10243            symbol = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10244            let mut tickers: Value = self.fetch_tickers_ws(&[Value::from(vec![symbol.clone()]), params]).await;
10245            let mut ticker: Value = self.safe_dict(tickers, symbol.clone(), &[]);
10246            if (ticker == Value::Null) {
10247                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() could not find a ticker for ".into())).into()), symbol)));
10248            }  else {
10249                return ticker;
10250            }
10251        }  else {
10252            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() is not supported yet".into()))));
10253        }
10254
10255    Value::Null
10256} }
10257
10258    fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10259        let mut symbols = get_arg(optional_args, 0, Value::Null);
10260        let mut params = get_arg(optional_args, 1, Value::Map({
10261    let mut m = indexmap::IndexMap::new();
10262    m
10263}));
10264        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickersWs() is not supported yet".into()))));
10265
10266    Value::Null
10267} }
10268
10269    fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10270        let mut since = get_arg(optional_args, 0, Value::Null);
10271        let mut limit = get_arg(optional_args, 1, Value::Null);
10272        let mut params = get_arg(optional_args, 2, Value::Map({
10273    let mut m = indexmap::IndexMap::new();
10274    m
10275}));
10276        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradesWs() is not supported yet".into()))));
10277
10278    Value::Null
10279} }
10280
10281
10282    fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10283        // async-virtual: try the derived exchange first
10284        if let Some(__v) = self.dispatch_to_derived("fetch_trades", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.extend_from_slice(optional_args); __args }).await {
10285            if !matches!(__v, crate::Value::Null) { return __v; }
10286        }
10287
10288        let mut since = get_arg(optional_args, 0, Value::Null);
10289        let mut limit = get_arg(optional_args, 1, Value::Null);
10290        let mut params = get_arg(optional_args, 2, Value::Map({
10291    let mut m = indexmap::IndexMap::new();
10292    m
10293}));
10294        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() is not supported yet".into()))));
10295
10296    Value::Null
10297} }
10298
10299    fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10300        let mut since = get_arg(optional_args, 0, Value::Null);
10301        let mut limit = get_arg(optional_args, 1, Value::Null);
10302        let mut params = get_arg(optional_args, 2, Value::Map({
10303    let mut m = indexmap::IndexMap::new();
10304    m
10305}));
10306        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTrades() is not supported yet".into()))));
10307
10308    Value::Null
10309} }
10310
10311    fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10312        // async-virtual: try the derived exchange first
10313        if let Some(__v) = self.dispatch_to_derived("fetch_order_book", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.extend_from_slice(optional_args); __args }).await {
10314            if !matches!(__v, crate::Value::Null) { return __v; }
10315        }
10316
10317        let mut limit = get_arg(optional_args, 0, Value::Null);
10318        let mut params = get_arg(optional_args, 1, Value::Map({
10319    let mut m = indexmap::IndexMap::new();
10320    m
10321}));
10322        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() is not supported yet".into()))));
10323
10324    Value::Null
10325} }
10326
10327    fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10328        let mut limit = get_arg(optional_args, 0, Value::Null);
10329        let mut params = get_arg(optional_args, 1, Value::Map({
10330    let mut m = indexmap::IndexMap::new();
10331    m
10332}));
10333        let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".into()), Value::Str("maxRetries".into()), &[Value::Int(3)]);
10334        {
10335                        let mut i: Value = Value::Int(0);
10336            let mut __for_first_179: bool = true;
10337            while { if !__for_first_179 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_179 = false; i.as_f64().unwrap_or(f64::NAN) < fetchSnapshotMaxRetries.as_f64().unwrap_or(f64::NAN) } {
10338            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10339                let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10340                return orderBook;
10341             #[allow(unreachable_code)] { Value::Null }})).await;
10342match _try_result { Ok(__try_ok) => { if !matches!(__try_ok, Value::Null) { return __try_ok; } return Value::Null; } Err(_try_err) => { let e: Value = panic_to_value(_try_err); 
10343                if is_equal(&((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })), &fetchSnapshotMaxRetries) {
10344                    panic!("{}", e);
10345                }
10346             } }
10347        }
10348        }
10349        return Value::Null;
10350
10351    Value::Null
10352} }
10353
10354    fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10355        let mut limit = get_arg(optional_args, 0, Value::Null);
10356        let mut params = get_arg(optional_args, 1, Value::Map({
10357    let mut m = indexmap::IndexMap::new();
10358    m
10359}));
10360        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBook() is not supported yet".into()))));
10361
10362    Value::Null
10363} }
10364
10365    fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10366        // async-virtual: try the derived exchange first
10367        if let Some(__v) = self.dispatch_to_derived("fetch_open_interest", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
10368            if !matches!(__v, crate::Value::Null) { return __v; }
10369        }
10370
10371        let mut params = get_arg(optional_args, 0, Value::Map({
10372    let mut m = indexmap::IndexMap::new();
10373    m
10374}));
10375        if (self.has.as_map().and_then(|__m| __m.get("fetchOpenInterests")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOpenInterests")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10376            let mut openInterests: Value = self.fetch_open_interests(&[Value::from(vec![symbol.clone()]), params]).await;
10377            return self.safe_dict(openInterests, symbol, &[]);
10378        }  else {
10379            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterest() is not supported yet".into()))));
10380        }
10381
10382    Value::Null
10383} }
10384
10385    fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10386        let mut limit = get_arg(optional_args, 0, Value::Null);
10387        let mut params = get_arg(optional_args, 1, Value::Map({
10388    let mut m = indexmap::IndexMap::new();
10389    m
10390}));
10391        let mut orderbook: Value = self.fetch_order_book(symbol, &[limit, params]).await;
10392        return self.extend(orderbook.clone(), &[Value::Map({
10393    let mut m = indexmap::IndexMap::new();
10394        m.insert("asks".to_string(), self.sort_by(self.aggregate(orderbook.as_map().and_then(|__m| __m.get("asks")).cloned().unwrap_or(Value::Null)), Value::Int(0), &[]));
10395        m.insert("bids".to_string(), self.sort_by(self.aggregate(orderbook.as_map().and_then(|__m| __m.get("bids")).cloned().unwrap_or(Value::Null)), Value::Int(0), &[Value::Bool(true)]));
10396    m
10397})]);
10398
10399    Value::Null
10400} }
10401
10402    fn edit_limit_buy_order(&mut self, mut id: Value, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10403        let mut price = get_arg(optional_args, 0, Value::Null);
10404        let mut params = get_arg(optional_args, 1, Value::Map({
10405    let mut m = indexmap::IndexMap::new();
10406    m
10407}));
10408        return self.edit_limit_order(id, symbol, Value::Str("buy".into()), amount, &[price, params]).await;
10409
10410    Value::Null
10411} }
10412
10413    fn edit_limit_sell_order(&mut self, mut id: Value, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10414        let mut price = get_arg(optional_args, 0, Value::Null);
10415        let mut params = get_arg(optional_args, 1, Value::Map({
10416    let mut m = indexmap::IndexMap::new();
10417    m
10418}));
10419        return self.edit_limit_order(id, symbol, Value::Str("sell".into()), amount, &[price, params]).await;
10420
10421    Value::Null
10422} }
10423
10424    fn edit_limit_order(&mut self, mut id: Value, mut symbol: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10425        let mut price = get_arg(optional_args, 0, Value::Null);
10426        let mut params = get_arg(optional_args, 1, Value::Map({
10427    let mut m = indexmap::IndexMap::new();
10428    m
10429}));
10430        return self.edit_order(id, symbol, Value::Str("limit".into()), side, &[amount, price, params]).await;
10431
10432    Value::Null
10433} }
10434
10435    fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10436        // async-virtual: try the derived exchange first
10437        if let Some(__v) = self.dispatch_to_derived("edit_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(id.clone()); __args.push(symbol.clone()); __args.push(type_var.clone()); __args.push(side.clone()); __args.extend_from_slice(optional_args); __args }).await {
10438            if !matches!(__v, crate::Value::Null) { return __v; }
10439        }
10440
10441        let mut amount = get_arg(optional_args, 0, Value::Null);
10442        let mut price = get_arg(optional_args, 1, Value::Null);
10443        let mut params = get_arg(optional_args, 2, Value::Map({
10444    let mut m = indexmap::IndexMap::new();
10445    m
10446}));
10447        self.cancel_order(id, &[symbol.clone()]).await;
10448        return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10449
10450    Value::Null
10451} }
10452
10453    fn edit_order_with_client_order_id(&mut self, mut clientOrderId: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10454        let mut amount = get_arg(optional_args, 0, Value::Null);
10455        let mut price = get_arg(optional_args, 1, Value::Null);
10456        let mut params = get_arg(optional_args, 2, Value::Map({
10457    let mut m = indexmap::IndexMap::new();
10458    m
10459}));
10460        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10461            let mut m = indexmap::IndexMap::new();
10462                m.insert("clientOrderId".to_string(), clientOrderId);
10463            m
10464        })]);
10465        return self.edit_order(Value::Str("".into()), symbol, type_var, side, &[amount, price, extendedParams]).await;
10466
10467    Value::Null
10468} }
10469
10470    fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10471        // async-virtual: try the derived exchange first
10472        if let Some(__v) = self.dispatch_to_derived("fetch_position", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.extend_from_slice(optional_args); __args }).await {
10473            if !matches!(__v, crate::Value::Null) { return __v; }
10474        }
10475
10476        let mut params = get_arg(optional_args, 0, Value::Map({
10477    let mut m = indexmap::IndexMap::new();
10478    m
10479}));
10480        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPosition() is not supported yet".into()))));
10481
10482    Value::Null
10483} }
10484
10485    fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10486        let mut symbols = get_arg(optional_args, 0, Value::Null);
10487        let mut since = get_arg(optional_args, 1, Value::Null);
10488        let mut limit = get_arg(optional_args, 2, Value::Null);
10489        let mut params = get_arg(optional_args, 3, Value::Map({
10490    let mut m = indexmap::IndexMap::new();
10491    m
10492}));
10493        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPositions() is not supported yet".into()))));
10494
10495    Value::Null
10496} }
10497
10498    fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10499        let mut symbols = get_arg(optional_args, 0, Value::Null);
10500        let mut since = get_arg(optional_args, 1, Value::Null);
10501        let mut limit = get_arg(optional_args, 2, Value::Null);
10502        let mut params = get_arg(optional_args, 3, Value::Map({
10503    let mut m = indexmap::IndexMap::new();
10504    m
10505}));
10506        return self.watch_positions(&[symbols, since, limit, params]).await;
10507
10508    Value::Null
10509} }
10510
10511    fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10512        // async-virtual: try the derived exchange first
10513        if let Some(__v) = self.dispatch_to_derived("fetch_positions", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
10514            if !matches!(__v, crate::Value::Null) { return __v; }
10515        }
10516
10517        let mut symbols = get_arg(optional_args, 0, Value::Null);
10518        let mut params = get_arg(optional_args, 1, Value::Map({
10519    let mut m = indexmap::IndexMap::new();
10520    m
10521}));
10522        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10523
10524    Value::Null
10525} }
10526
10527    fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10528        // async-virtual: try the derived exchange first
10529        if let Some(__v) = self.dispatch_to_derived("fetch_ticker", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
10530            if !matches!(__v, crate::Value::Null) { return __v; }
10531        }
10532
10533        let mut params = get_arg(optional_args, 0, Value::Map({
10534    let mut m = indexmap::IndexMap::new();
10535    m
10536}));
10537        if (self.has.as_map().and_then(|__m| __m.get("fetchTickers")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTickers")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10538            self.load_markets(&[]).await;
10539            let mut market: Value = self.market(symbol.clone());
10540            symbol = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10541            let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbol.clone()]), params]).await;
10542            let mut ticker: Value = self.safe_dict(tickers, symbol.clone(), &[]);
10543            if (ticker == Value::Null) {
10544                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() could not find a ticker for ".into())).into()), symbol)));
10545            }  else {
10546                return ticker;
10547            }
10548        }  else {
10549            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() is not supported yet".into()))));
10550        }
10551
10552    Value::Null
10553} }
10554
10555    fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10556        let mut params = get_arg(optional_args, 0, Value::Map({
10557    let mut m = indexmap::IndexMap::new();
10558    m
10559}));
10560        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTicker() is not supported yet".into()))));
10561
10562    Value::Null
10563} }
10564
10565    fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10566        // async-virtual: try the derived exchange first
10567        if let Some(__v) = self.dispatch_to_derived("fetch_tickers", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
10568            if !matches!(__v, crate::Value::Null) { return __v; }
10569        }
10570
10571        let mut symbols = get_arg(optional_args, 0, Value::Null);
10572        let mut params = get_arg(optional_args, 1, Value::Map({
10573    let mut m = indexmap::IndexMap::new();
10574    m
10575}));
10576        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() is not supported yet".into()))));
10577
10578    Value::Null
10579} }
10580
10581    fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10582        let mut symbols = get_arg(optional_args, 0, Value::Null);
10583        let mut params = get_arg(optional_args, 1, Value::Map({
10584    let mut m = indexmap::IndexMap::new();
10585    m
10586}));
10587        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTickers() is not supported yet".into()))));
10588
10589    Value::Null
10590} }
10591
10592    fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10593        // async-virtual: try the derived exchange first
10594        if let Some(__v) = self.dispatch_to_derived("fetch_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(id.clone()); __args.extend_from_slice(optional_args); __args }).await {
10595            if !matches!(__v, crate::Value::Null) { return __v; }
10596        }
10597
10598        let mut symbol = get_arg(optional_args, 0, Value::Null);
10599        let mut params = get_arg(optional_args, 1, Value::Map({
10600    let mut m = indexmap::IndexMap::new();
10601    m
10602}));
10603        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() is not supported yet".into()))));
10604
10605    Value::Null
10606} }
10607
10608/*
10609 * @method
10610 * @name fetchOrderWithClientOrderId
10611 * @description create a market order by providing the symbol, side and cost
10612 * @param {string} clientOrderId client order Id
10613 * @param {string} symbol unified symbol of the market to create an order in
10614 * @param {object} [params] extra parameters specific to the exchange API endpoint
10615 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10616 */
10617    fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10618        let mut symbol = get_arg(optional_args, 0, Value::Null);
10619        let mut params = get_arg(optional_args, 1, Value::Map({
10620    let mut m = indexmap::IndexMap::new();
10621    m
10622}));
10623        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10624            let mut m = indexmap::IndexMap::new();
10625                m.insert("clientOrderId".to_string(), clientOrderId);
10626            m
10627        })]);
10628        return self.fetch_order(Value::Str("".into()), &[symbol, extendedParams]).await;
10629
10630    Value::Null
10631} }
10632
10633    fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10634        let mut symbol = get_arg(optional_args, 0, Value::Null);
10635        let mut params = get_arg(optional_args, 1, Value::Map({
10636    let mut m = indexmap::IndexMap::new();
10637    m
10638}));
10639        // TODO: TypeScript: change method signature by replacing
10640        // Promise<string> with Promise<Order['status']>.
10641        let mut order: Value = self.fetch_order(id, &[symbol, params]).await;
10642        return order.as_map().and_then(|__m| __m.get("status")).cloned().unwrap_or(Value::Null);
10643
10644    Value::Null
10645} }
10646
10647    fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10648        let mut params = get_arg(optional_args, 0, Value::Map({
10649    let mut m = indexmap::IndexMap::new();
10650    m
10651}));
10652        return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
10653
10654    Value::Null
10655} }
10656
10657    fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10658        // async-virtual: try the derived exchange first
10659        if let Some(__v) = self.dispatch_to_derived("create_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(type_var); __args.push(side); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
10660            if !matches!(__v, crate::Value::Null) { return __v; }
10661        }
10662
10663        let mut price = get_arg(optional_args, 0, Value::Null);
10664        let mut params = get_arg(optional_args, 1, Value::Map({
10665    let mut m = indexmap::IndexMap::new();
10666    m
10667}));
10668        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() is not supported yet".into()))));
10669
10670    Value::Null
10671} }
10672
10673    fn create_trailing_amount_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10674        let mut price = get_arg(optional_args, 0, Value::Null);
10675        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10676        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10677        let mut params = get_arg(optional_args, 3, Value::Map({
10678    let mut m = indexmap::IndexMap::new();
10679    m
10680}));
10681        /*
10682         * @method
10683         * @name createTrailingAmountOrder
10684         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
10685         * @param {string} symbol unified symbol of the market to create an order in
10686         * @param {string} type 'market' or 'limit'
10687         * @param {string} side 'buy' or 'sell'
10688         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10689         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10690         * @param {float} trailingAmount the quote amount to trail away from the current market price
10691         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10692         * @param {object} [params] extra parameters specific to the exchange API endpoint
10693         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10694         */
10695        if (trailingAmount == Value::Null) {
10696            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".into()))));
10697        }
10698        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10699        if (trailingTriggerPrice != Value::Null) {
10700            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10701        }
10702        if (self.has.as_map().and_then(|__m| __m.get("createTrailingAmountOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTrailingAmountOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10703            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10704        }
10705        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() is not supported yet".into()))));
10706
10707    Value::Null
10708} }
10709
10710    fn create_trailing_percent_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10711        let mut price = get_arg(optional_args, 0, Value::Null);
10712        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10713        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10714        let mut params = get_arg(optional_args, 3, Value::Map({
10715    let mut m = indexmap::IndexMap::new();
10716    m
10717}));
10718        /*
10719         * @method
10720         * @name createTrailingPercentOrder
10721         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
10722         * @param {string} symbol unified symbol of the market to create an order in
10723         * @param {string} type 'market' or 'limit'
10724         * @param {string} side 'buy' or 'sell'
10725         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10726         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10727         * @param {float} trailingPercent the percent to trail away from the current market price
10728         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10729         * @param {object} [params] extra parameters specific to the exchange API endpoint
10730         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10731         */
10732        if (trailingPercent == Value::Null) {
10733            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".into()))));
10734        }
10735        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10736        if (trailingTriggerPrice != Value::Null) {
10737            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10738        }
10739        if (self.has.as_map().and_then(|__m| __m.get("createTrailingPercentOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTrailingPercentOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10740            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10741        }
10742        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() is not supported yet".into()))));
10743
10744    Value::Null
10745} }
10746
10747    fn create_market_order_with_cost(&mut self, mut symbol: Value, mut side: Value, mut cost: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10748        let mut params = get_arg(optional_args, 0, Value::Map({
10749    let mut m = indexmap::IndexMap::new();
10750    m
10751}));
10752        /*
10753         * @method
10754         * @name createMarketOrderWithCost
10755         * @description create a market order by providing the symbol, side and cost
10756         * @param {string} symbol unified symbol of the market to create an order in
10757         * @param {string} side 'buy' or 'sell'
10758         * @param {float} cost how much you want to trade in units of the quote currency
10759         * @param {object} [params] extra parameters specific to the exchange API endpoint
10760         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10761         */
10762        if ((self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) || (((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)))) {
10763            return self.create_order(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
10764        }
10765        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCost() is not supported yet".into()))));
10766
10767    Value::Null
10768} }
10769
10770    fn create_market_buy_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10771        let mut params = get_arg(optional_args, 0, Value::Map({
10772    let mut m = indexmap::IndexMap::new();
10773    m
10774}));
10775        /*
10776         * @method
10777         * @name createMarketBuyOrderWithCost
10778         * @description create a market buy order by providing the symbol and cost
10779         * @param {string} symbol unified symbol of the market to create an order in
10780         * @param {float} cost how much you want to trade in units of the quote currency
10781         * @param {object} [params] extra parameters specific to the exchange API endpoint
10782         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10783         */
10784        if (is_equal(&self.options.as_map().and_then(|__m| __m.get("createMarketBuyOrderRequiresPrice")).cloned().unwrap_or(Value::Null), &Value::Bool(true))) || ((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
10785            return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Int(1), params]).await;
10786        }
10787        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() is not supported yet".into()))));
10788
10789    Value::Null
10790} }
10791
10792    fn create_market_sell_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10793        let mut params = get_arg(optional_args, 0, Value::Map({
10794    let mut m = indexmap::IndexMap::new();
10795    m
10796}));
10797        /*
10798         * @method
10799         * @name createMarketSellOrderWithCost
10800         * @description create a market sell order by providing the symbol and cost
10801         * @param {string} symbol unified symbol of the market to create an order in
10802         * @param {float} cost how much you want to trade in units of the quote currency
10803         * @param {object} [params] extra parameters specific to the exchange API endpoint
10804         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10805         */
10806        if (is_equal(&self.options.as_map().and_then(|__m| __m.get("createMarketSellOrderRequiresPrice")).cloned().unwrap_or(Value::Null), &Value::Bool(true))) || ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
10807            return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), cost, &[Value::Int(1), params]).await;
10808        }
10809        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketSellOrderWithCost() is not supported yet".into()))));
10810
10811    Value::Null
10812} }
10813
10814    fn create_trigger_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10815        let mut price = get_arg(optional_args, 0, Value::Null);
10816        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10817        let mut params = get_arg(optional_args, 2, Value::Map({
10818    let mut m = indexmap::IndexMap::new();
10819    m
10820}));
10821        /*
10822         * @method
10823         * @name createTriggerOrder
10824         * @description create a trigger stop order (type 1)
10825         * @param {string} symbol unified symbol of the market to create an order in
10826         * @param {string} type 'market' or 'limit'
10827         * @param {string} side 'buy' or 'sell'
10828         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10829         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10830         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10831         * @param {object} [params] extra parameters specific to the exchange API endpoint
10832         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10833         */
10834        if (triggerPrice == Value::Null) {
10835            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() requires a triggerPrice argument".into()))));
10836        }
10837        params = self.extend(params.clone(), &[Value::Map({
10838            let mut m = indexmap::IndexMap::new();
10839                m.insert("triggerPrice".to_string(), triggerPrice);
10840            m
10841        })]);
10842        if (self.has.as_map().and_then(|__m| __m.get("createTriggerOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTriggerOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10843            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10844        }
10845        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() is not supported yet".into()))));
10846
10847    Value::Null
10848} }
10849
10850    fn create_stop_loss_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10851        let mut price = get_arg(optional_args, 0, Value::Null);
10852        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10853        let mut params = get_arg(optional_args, 2, Value::Map({
10854    let mut m = indexmap::IndexMap::new();
10855    m
10856}));
10857        /*
10858         * @method
10859         * @name createStopLossOrder
10860         * @description create a trigger stop loss order (type 2)
10861         * @param {string} symbol unified symbol of the market to create an order in
10862         * @param {string} type 'market' or 'limit'
10863         * @param {string} side 'buy' or 'sell'
10864         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10865         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10866         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
10867         * @param {object} [params] extra parameters specific to the exchange API endpoint
10868         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10869         */
10870        if (stopLossPrice == Value::Null) {
10871            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() requires a stopLossPrice argument".into()))));
10872        }
10873        params = self.extend(params.clone(), &[Value::Map({
10874            let mut m = indexmap::IndexMap::new();
10875                m.insert("stopLossPrice".to_string(), stopLossPrice);
10876            m
10877        })]);
10878        if (self.has.as_map().and_then(|__m| __m.get("createStopLossOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createStopLossOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10879            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10880        }
10881        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() is not supported yet".into()))));
10882
10883    Value::Null
10884} }
10885
10886    fn create_take_profit_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10887        let mut price = get_arg(optional_args, 0, Value::Null);
10888        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10889        let mut params = get_arg(optional_args, 2, Value::Map({
10890    let mut m = indexmap::IndexMap::new();
10891    m
10892}));
10893        /*
10894         * @method
10895         * @name createTakeProfitOrder
10896         * @description create a trigger take profit order (type 2)
10897         * @param {string} symbol unified symbol of the market to create an order in
10898         * @param {string} type 'market' or 'limit'
10899         * @param {string} side 'buy' or 'sell'
10900         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10901         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10902         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
10903         * @param {object} [params] extra parameters specific to the exchange API endpoint
10904         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10905         */
10906        if (takeProfitPrice == Value::Null) {
10907            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".into()))));
10908        }
10909        params = self.extend(params.clone(), &[Value::Map({
10910            let mut m = indexmap::IndexMap::new();
10911                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
10912            m
10913        })]);
10914        if (self.has.as_map().and_then(|__m| __m.get("createTakeProfitOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTakeProfitOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10915            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10916        }
10917        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() is not supported yet".into()))));
10918
10919    Value::Null
10920} }
10921
10922    fn create_order_with_take_profit_and_stop_loss(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10923        let mut price = get_arg(optional_args, 0, Value::Null);
10924        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
10925        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
10926        let mut params = get_arg(optional_args, 3, Value::Map({
10927    let mut m = indexmap::IndexMap::new();
10928    m
10929}));
10930        /*
10931         * @method
10932         * @name createOrderWithTakeProfitAndStopLoss
10933         * @description create an order with a stop loss or take profit attached (type 3)
10934         * @param {string} symbol unified symbol of the market to create an order in
10935         * @param {string} type 'market' or 'limit'
10936         * @param {string} side 'buy' or 'sell'
10937         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10938         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10939         * @param {float} [takeProfit] the take profit price, in units of the quote currency
10940         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
10941         * @param {object} [params] extra parameters specific to the exchange API endpoint
10942         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
10943         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
10944         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
10945         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
10946         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
10947         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
10948         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
10949         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
10950         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10951         */
10952        params = self.set_take_profit_and_stop_loss_params(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), takeProfit.clone(), stopLoss.clone(), params.clone()]);
10953        if (self.has.as_map().and_then(|__m| __m.get("createOrderWithTakeProfitAndStopLoss")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createOrderWithTakeProfitAndStopLoss")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10954            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10955        }
10956        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".into()))));
10957
10958    Value::Null
10959} }
10960
10961    fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10962        // async-virtual: try the derived exchange first
10963        if let Some(__v) = self.dispatch_to_derived("create_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(orders); __args.extend_from_slice(optional_args); __args }).await {
10964            if !matches!(__v, crate::Value::Null) { return __v; }
10965        }
10966
10967        let mut params = get_arg(optional_args, 0, Value::Map({
10968    let mut m = indexmap::IndexMap::new();
10969    m
10970}));
10971        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrders() is not supported yet".into()))));
10972
10973    Value::Null
10974} }
10975
10976    fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10977        // async-virtual: try the derived exchange first
10978        if let Some(__v) = self.dispatch_to_derived("cancel_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(id.clone()); __args.extend_from_slice(optional_args); __args }).await {
10979            if !matches!(__v, crate::Value::Null) { return __v; }
10980        }
10981
10982        let mut symbol = get_arg(optional_args, 0, Value::Null);
10983        let mut params = get_arg(optional_args, 1, Value::Map({
10984    let mut m = indexmap::IndexMap::new();
10985    m
10986}));
10987        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() is not supported yet".into()))));
10988
10989    Value::Null
10990} }
10991
10992/*
10993 * @method
10994 * @name cancelOrderWithClientOrderId
10995 * @description create a market order by providing the symbol, side and cost
10996 * @param {string} clientOrderId client order Id
10997 * @param {string} symbol unified symbol of the market to create an order in
10998 * @param {object} [params] extra parameters specific to the exchange API endpoint
10999 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11000 */
11001    fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11002        let mut symbol = get_arg(optional_args, 0, Value::Null);
11003        let mut params = get_arg(optional_args, 1, Value::Map({
11004    let mut m = indexmap::IndexMap::new();
11005    m
11006}));
11007        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11008            let mut m = indexmap::IndexMap::new();
11009                m.insert("clientOrderId".to_string(), clientOrderId);
11010            m
11011        })]);
11012        return self.cancel_order(Value::Str("".into()), &[symbol, extendedParams]).await;
11013
11014    Value::Null
11015} }
11016
11017    fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11018        // async-virtual: try the derived exchange first
11019        if let Some(__v) = self.dispatch_to_derived("cancel_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(ids); __args.extend_from_slice(optional_args); __args }).await {
11020            if !matches!(__v, crate::Value::Null) { return __v; }
11021        }
11022
11023        let mut symbol = get_arg(optional_args, 0, Value::Null);
11024        let mut params = get_arg(optional_args, 1, Value::Map({
11025    let mut m = indexmap::IndexMap::new();
11026    m
11027}));
11028        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() is not supported yet".into()))));
11029
11030    Value::Null
11031} }
11032
11033/*
11034 * @method
11035 * @name cancelOrdersWithClientOrderIds
11036 * @description create a market order by providing the symbol, side and cost
11037 * @param {string[]} clientOrderIds client order Ids
11038 * @param {string} symbol unified symbol of the market to create an order in
11039 * @param {object} [params] extra parameters specific to the exchange API endpoint
11040 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11041 */
11042    fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11043        let mut symbol = get_arg(optional_args, 0, Value::Null);
11044        let mut params = get_arg(optional_args, 1, Value::Map({
11045    let mut m = indexmap::IndexMap::new();
11046    m
11047}));
11048        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11049            let mut m = indexmap::IndexMap::new();
11050                m.insert("clientOrderIds".to_string(), clientOrderIds);
11051            m
11052        })]);
11053        return self.cancel_orders(Value::from(vec![]), &[symbol, extendedParams]).await;
11054
11055    Value::Null
11056} }
11057
11058    fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11059        // async-virtual: try the derived exchange first
11060        if let Some(__v) = self.dispatch_to_derived("cancel_all_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
11061            if !matches!(__v, crate::Value::Null) { return __v; }
11062        }
11063
11064        let mut symbol = get_arg(optional_args, 0, Value::Null);
11065        let mut params = get_arg(optional_args, 1, Value::Map({
11066    let mut m = indexmap::IndexMap::new();
11067    m
11068}));
11069        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() is not supported yet".into()))));
11070
11071    Value::Null
11072} }
11073
11074    fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11075        let mut params = get_arg(optional_args, 0, Value::Map({
11076    let mut m = indexmap::IndexMap::new();
11077    m
11078}));
11079        return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11080
11081    Value::Null
11082} }
11083
11084    fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11085        // async-virtual: try the derived exchange first
11086        if let Some(__v) = self.dispatch_to_derived("fetch_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
11087            if !matches!(__v, crate::Value::Null) { return __v; }
11088        }
11089
11090        let mut symbol = get_arg(optional_args, 0, Value::Null);
11091        let mut since = get_arg(optional_args, 1, Value::Null);
11092        let mut limit = get_arg(optional_args, 2, Value::Null);
11093        let mut params = get_arg(optional_args, 3, Value::Map({
11094    let mut m = indexmap::IndexMap::new();
11095    m
11096}));
11097        if ((self.has.as_map().and_then(|__m| __m.get("fetchOpenOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOpenOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("fetchClosedOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchClosedOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
11098            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".into()))));
11099        }
11100        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet".into()))));
11101
11102    Value::Null
11103} }
11104
11105    fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11106        let mut symbol = get_arg(optional_args, 0, Value::Null);
11107        let mut since = get_arg(optional_args, 1, Value::Null);
11108        let mut limit = get_arg(optional_args, 2, Value::Null);
11109        let mut params = get_arg(optional_args, 3, Value::Map({
11110    let mut m = indexmap::IndexMap::new();
11111    m
11112}));
11113        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderTrades() is not supported yet".into()))));
11114
11115    Value::Null
11116} }
11117
11118    fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11119        let mut symbol = get_arg(optional_args, 0, Value::Null);
11120        let mut since = get_arg(optional_args, 1, Value::Null);
11121        let mut limit = get_arg(optional_args, 2, Value::Null);
11122        let mut params = get_arg(optional_args, 3, Value::Map({
11123    let mut m = indexmap::IndexMap::new();
11124    m
11125}));
11126        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrders() is not supported yet".into()))));
11127
11128    Value::Null
11129} }
11130
11131    fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11132        // async-virtual: try the derived exchange first
11133        if let Some(__v) = self.dispatch_to_derived("fetch_open_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
11134            if !matches!(__v, crate::Value::Null) { return __v; }
11135        }
11136
11137        let mut symbol = get_arg(optional_args, 0, Value::Null);
11138        let mut since = get_arg(optional_args, 1, Value::Null);
11139        let mut limit = get_arg(optional_args, 2, Value::Null);
11140        let mut params = get_arg(optional_args, 3, Value::Map({
11141    let mut m = indexmap::IndexMap::new();
11142    m
11143}));
11144        if (self.has.as_map().and_then(|__m| __m.get("fetchOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11145            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11146            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
11147        }
11148        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() is not supported yet".into()))));
11149
11150    Value::Null
11151} }
11152
11153    fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11154        // async-virtual: try the derived exchange first
11155        if let Some(__v) = self.dispatch_to_derived("fetch_closed_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
11156            if !matches!(__v, crate::Value::Null) { return __v; }
11157        }
11158
11159        let mut symbol = get_arg(optional_args, 0, Value::Null);
11160        let mut since = get_arg(optional_args, 1, Value::Null);
11161        let mut limit = get_arg(optional_args, 2, Value::Null);
11162        let mut params = get_arg(optional_args, 3, Value::Map({
11163    let mut m = indexmap::IndexMap::new();
11164    m
11165}));
11166        if (self.has.as_map().and_then(|__m| __m.get("fetchOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11167            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11168            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
11169        }
11170        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrders() is not supported yet".into()))));
11171
11172    Value::Null
11173} }
11174
11175    fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11176        let mut symbol = get_arg(optional_args, 0, Value::Null);
11177        let mut since = get_arg(optional_args, 1, Value::Null);
11178        let mut limit = get_arg(optional_args, 2, Value::Null);
11179        let mut params = get_arg(optional_args, 3, Value::Map({
11180    let mut m = indexmap::IndexMap::new();
11181    m
11182}));
11183        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledOrders() is not supported yet".into()))));
11184
11185    Value::Null
11186} }
11187
11188    fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11189        // async-virtual: try the derived exchange first
11190        if let Some(__v) = self.dispatch_to_derived("fetch_my_trades", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
11191            if !matches!(__v, crate::Value::Null) { return __v; }
11192        }
11193
11194        let mut symbol = get_arg(optional_args, 0, Value::Null);
11195        let mut since = get_arg(optional_args, 1, Value::Null);
11196        let mut limit = get_arg(optional_args, 2, Value::Null);
11197        let mut params = get_arg(optional_args, 3, Value::Map({
11198    let mut m = indexmap::IndexMap::new();
11199    m
11200}));
11201        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() is not supported yet".into()))));
11202
11203    Value::Null
11204} }
11205
11206    fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11207        let mut symbol = get_arg(optional_args, 0, Value::Null);
11208        let mut since = get_arg(optional_args, 1, Value::Null);
11209        let mut limit = get_arg(optional_args, 2, Value::Null);
11210        let mut params = get_arg(optional_args, 3, Value::Map({
11211    let mut m = indexmap::IndexMap::new();
11212    m
11213}));
11214        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTrades() is not supported yet".into()))));
11215
11216    Value::Null
11217} }
11218
11219    fn create_limit_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11220        let mut params = get_arg(optional_args, 0, Value::Map({
11221    let mut m = indexmap::IndexMap::new();
11222    m
11223}));
11224        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
11225
11226    Value::Null
11227} }
11228
11229    fn create_market_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11230        let mut price = get_arg(optional_args, 0, Value::Null);
11231        let mut params = get_arg(optional_args, 1, Value::Map({
11232    let mut m = indexmap::IndexMap::new();
11233    m
11234}));
11235        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
11236
11237    Value::Null
11238} }
11239
11240    fn create_limit_buy_order(&mut self, mut symbol: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11241        let mut params = get_arg(optional_args, 0, Value::Map({
11242    let mut m = indexmap::IndexMap::new();
11243    m
11244}));
11245        return self.create_order(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
11246
11247    Value::Null
11248} }
11249
11250    fn create_limit_sell_order(&mut self, mut symbol: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11251        let mut params = get_arg(optional_args, 0, Value::Map({
11252    let mut m = indexmap::IndexMap::new();
11253    m
11254}));
11255        return self.create_order(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
11256
11257    Value::Null
11258} }
11259
11260    fn create_market_buy_order(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11261        let mut params = get_arg(optional_args, 0, Value::Map({
11262    let mut m = indexmap::IndexMap::new();
11263    m
11264}));
11265        return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
11266
11267    Value::Null
11268} }
11269
11270    fn create_market_sell_order(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11271        let mut params = get_arg(optional_args, 0, Value::Map({
11272    let mut m = indexmap::IndexMap::new();
11273    m
11274}));
11275        return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
11276
11277    Value::Null
11278} }
11279
11280    fn create_post_only_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11281        let mut price = get_arg(optional_args, 0, Value::Null);
11282        let mut params = get_arg(optional_args, 1, Value::Map({
11283    let mut m = indexmap::IndexMap::new();
11284    m
11285}));
11286        if (self.has.as_map().and_then(|__m| __m.get("createPostOnlyOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createPostOnlyOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11287            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrder() is not supported yet".into()))));
11288        }
11289        let mut query: Value = self.extend(params, &[Value::Map({
11290            let mut m = indexmap::IndexMap::new();
11291                m.insert("postOnly".to_string(), Value::Bool(true));
11292            m
11293        })]);
11294        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11295
11296    Value::Null
11297} }
11298
11299    fn create_reduce_only_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11300        let mut price = get_arg(optional_args, 0, Value::Null);
11301        let mut params = get_arg(optional_args, 1, Value::Map({
11302    let mut m = indexmap::IndexMap::new();
11303    m
11304}));
11305        if (self.has.as_map().and_then(|__m| __m.get("createReduceOnlyOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createReduceOnlyOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11306            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrder() is not supported yet".into()))));
11307        }
11308        let mut query: Value = self.extend(params, &[Value::Map({
11309            let mut m = indexmap::IndexMap::new();
11310                m.insert("reduceOnly".to_string(), Value::Bool(true));
11311            m
11312        })]);
11313        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11314
11315    Value::Null
11316} }
11317
11318    fn create_stop_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11319        let mut price = get_arg(optional_args, 0, Value::Null);
11320        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11321        let mut params = get_arg(optional_args, 2, Value::Map({
11322    let mut m = indexmap::IndexMap::new();
11323    m
11324}));
11325        if (self.has.as_map().and_then(|__m| __m.get("createStopOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11326            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrder() is not supported yet".into()))));
11327        }
11328        if (triggerPrice == Value::Null) {
11329            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" create_stop_order() requires a stopPrice argument".into()))));
11330        }
11331        let mut query: Value = self.extend(params, &[Value::Map({
11332            let mut m = indexmap::IndexMap::new();
11333                m.insert("stopPrice".to_string(), triggerPrice);
11334            m
11335        })]);
11336        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11337
11338    Value::Null
11339} }
11340
11341    fn create_stop_limit_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut price: Value, mut triggerPrice: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11342        let mut params = get_arg(optional_args, 0, Value::Map({
11343    let mut m = indexmap::IndexMap::new();
11344    m
11345}));
11346        if (self.has.as_map().and_then(|__m| __m.get("createStopLimitOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopLimitOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11347            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrder() is not supported yet".into()))));
11348        }
11349        let mut query: Value = self.extend(params, &[Value::Map({
11350            let mut m = indexmap::IndexMap::new();
11351                m.insert("stopPrice".to_string(), triggerPrice);
11352            m
11353        })]);
11354        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
11355
11356    Value::Null
11357} }
11358
11359    fn create_stop_market_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut triggerPrice: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11360        let mut params = get_arg(optional_args, 0, Value::Map({
11361    let mut m = indexmap::IndexMap::new();
11362    m
11363}));
11364        if (self.has.as_map().and_then(|__m| __m.get("createStopMarketOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopMarketOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11365            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrder() is not supported yet".into()))));
11366        }
11367        let mut query: Value = self.extend(params, &[Value::Map({
11368            let mut m = indexmap::IndexMap::new();
11369                m.insert("stopPrice".to_string(), triggerPrice);
11370            m
11371        })]);
11372        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
11373
11374    Value::Null
11375} }
11376
11377    fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11378        // async-virtual: try the derived exchange first
11379        if let Some(__v) = self.dispatch_to_derived("fetch_trading_fee", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
11380            if !matches!(__v, crate::Value::Null) { return __v; }
11381        }
11382
11383        let mut params = get_arg(optional_args, 0, Value::Map({
11384    let mut m = indexmap::IndexMap::new();
11385    m
11386}));
11387        if (self.has.as_map().and_then(|__m| __m.get("fetchTradingFees")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchTradingFees")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11388            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFee() is not supported yet".into()))));
11389        }
11390        let mut fees: Value = self.fetch_trading_fees(&[params]).await;
11391        return self.safe_dict(fees, symbol, &[]);
11392
11393    Value::Null
11394} }
11395    /// Base-method fall-through for a core's `call_dynamic`.
11396    fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11397        -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11398    {
11399        Box::pin(async move {
11400            match method {
11401            "account" => self.account(),
11402            "add_key_in_array_items" => self.add_key_in_array_items(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11403            "add_margin" => self.add_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11404            "amount_to_precision" => self.amount_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11405            "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11406            "assign_default_deposit_withdraw_fees" => self.assign_default_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11407            "borrow_cross_margin" => self.borrow_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11408            "borrow_isolated_margin" => self.borrow_isolated_margin(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[3.min(args.len())..]).await,
11409            "borrow_margin" => self.borrow_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11410            "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11411            "calculate_fee" => self.calculate_fee(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).cloned().unwrap_or(crate::Value::Null), &args[5.min(args.len())..]),
11412            "calculate_fee_with_rate" => self.calculate_fee_with_rate(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).cloned().unwrap_or(crate::Value::Null), &args[5.min(args.len())..]),
11413            "calculate_rate_limiter_cost" => self.calculate_rate_limiter_cost(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[4.min(args.len())..]),
11414            "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11415            "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args[..]).await,
11416            "cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
11417            "cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11418            "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args[..]).await,
11419            "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args[..]).await,
11420            "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11421            "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11422            "cancel_order_with_client_order_id" => self.cancel_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11423            "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11424            "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11425            "cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11426            "cancel_orders_with_client_order_ids" => self.cancel_orders_with_client_order_ids(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11427            "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11428            "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11429            "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11430            "check_address" => self.check_address(&args[..]),
11431            "check_proxy_settings" => self.check_proxy_settings(&args[..]),
11432            "check_proxy_url_settings" => self.check_proxy_url_settings(&args[..]),
11433            "check_required_credentials" => self.check_required_credentials(&args[..]),
11434            "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11435            "close_all_positions" => self.close_all_positions(&args[..]).await,
11436            "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11437            "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11438            "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11439            "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11440            "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11441            "convert_ohlcv_to_trading_view" => self.convert_ohlcv_to_trading_view(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11442            "convert_trading_view_to_ohlcv" => self.convert_trading_view_to_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11443            "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11444            "cost_to_precision" => self.cost_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11445            "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args[..]),
11446            "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11447            "create_convert_trade" => self.create_convert_trade(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[3.min(args.len())..]).await,
11448            "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11449            "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11450            "create_limit_buy_order" => self.create_limit_buy_order(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[3.min(args.len())..]).await,
11451            "create_limit_buy_order_ws" => self.create_limit_buy_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[3.min(args.len())..]).await,
11452            "create_limit_order" => self.create_limit_order(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[4.min(args.len())..]).await,
11453            "create_limit_order_ws" => self.create_limit_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[4.min(args.len())..]).await,
11454            "create_limit_sell_order" => self.create_limit_sell_order(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[3.min(args.len())..]).await,
11455            "create_limit_sell_order_ws" => self.create_limit_sell_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[3.min(args.len())..]).await,
11456            "create_market_buy_order" => self.create_market_buy_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11457            "create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11458            "create_market_buy_order_ws" => self.create_market_buy_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11459            "create_market_order" => self.create_market_order(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[3.min(args.len())..]).await,
11460            "create_market_order_with_cost" => self.create_market_order_with_cost(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[3.min(args.len())..]).await,
11461            "create_market_order_with_cost_ws" => self.create_market_order_with_cost_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[3.min(args.len())..]).await,
11462            "create_market_order_ws" => self.create_market_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[3.min(args.len())..]).await,
11463            "create_market_sell_order" => self.create_market_sell_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11464            "create_market_sell_order_with_cost" => self.create_market_sell_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11465            "create_market_sell_order_ws" => self.create_market_sell_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11466            "create_ohlcv_object" => self.create_ohlcv_object(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)),
11467            "create_order" => self.create_order(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[4.min(args.len())..]).await,
11468            "create_order_with_take_profit_and_stop_loss" => self.create_order_with_take_profit_and_stop_loss(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[4.min(args.len())..]).await,
11469            "create_order_with_take_profit_and_stop_loss_ws" => self.create_order_with_take_profit_and_stop_loss_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[4.min(args.len())..]).await,
11470            "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[4.min(args.len())..]).await,
11471            "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11472            "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11473            "create_post_only_order" => self.create_post_only_order(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[4.min(args.len())..]).await,
11474            "create_post_only_order_ws" => self.create_post_only_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[4.min(args.len())..]).await,
11475            "create_reduce_only_order" => self.create_reduce_only_order(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[4.min(args.len())..]).await,
11476            "create_reduce_only_order_ws" => self.create_reduce_only_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[4.min(args.len())..]).await,
11477            "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11478            "create_stop_limit_order" => self.create_stop_limit_order(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).cloned().unwrap_or(crate::Value::Null), &args[5.min(args.len())..]).await,
11479            "create_stop_limit_order_ws" => self.create_stop_limit_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).cloned().unwrap_or(crate::Value::Null), &args[5.min(args.len())..]).await,
11480            "create_stop_loss_order" => self.create_stop_loss_order(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[4.min(args.len())..]).await,
11481            "create_stop_loss_order_ws" => self.create_stop_loss_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[4.min(args.len())..]).await,
11482            "create_stop_market_order" => self.create_stop_market_order(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[4.min(args.len())..]).await,
11483            "create_stop_market_order_ws" => self.create_stop_market_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[4.min(args.len())..]).await,
11484            "create_stop_order" => self.create_stop_order(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[4.min(args.len())..]).await,
11485            "create_stop_order_ws" => self.create_stop_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[4.min(args.len())..]).await,
11486            "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11487            "create_take_profit_order" => self.create_take_profit_order(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[4.min(args.len())..]).await,
11488            "create_take_profit_order_ws" => self.create_take_profit_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[4.min(args.len())..]).await,
11489            "create_trailing_amount_order" => self.create_trailing_amount_order(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[4.min(args.len())..]).await,
11490            "create_trailing_amount_order_ws" => self.create_trailing_amount_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[4.min(args.len())..]).await,
11491            "create_trailing_percent_order" => self.create_trailing_percent_order(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[4.min(args.len())..]).await,
11492            "create_trailing_percent_order_ws" => self.create_trailing_percent_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[4.min(args.len())..]).await,
11493            "create_trigger_order" => self.create_trigger_order(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[4.min(args.len())..]).await,
11494            "create_trigger_order_ws" => self.create_trigger_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[4.min(args.len())..]).await,
11495            "create_twap_order" => self.create_twap_order(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[4.min(args.len())..]).await,
11496            "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11497            "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11498            "currency_ids" => self.currency_ids(&args[..]),
11499            "currency_to_precision" => self.currency_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11500            "default_network_code" => self.default_network_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11501            "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11502            "edit_limit_buy_order" => self.edit_limit_buy_order(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[3.min(args.len())..]).await,
11503            "edit_limit_order" => self.edit_limit_order(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[4.min(args.len())..]).await,
11504            "edit_limit_sell_order" => self.edit_limit_sell_order(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[3.min(args.len())..]).await,
11505            "edit_order" => self.edit_order(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[4.min(args.len())..]).await,
11506            "edit_order_with_client_order_id" => self.edit_order_with_client_order_id(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[4.min(args.len())..]).await,
11507            "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[4.min(args.len())..]).await,
11508            "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11509            "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11510            "feature_value_by_type" => self.feature_value_by_type(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11511            "features_mapper" => self.features_mapper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11512            "fee_to_precision" => self.fee_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11513            "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11514            "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11515            "fetch_accounts" => self.fetch_accounts(&args[..]).await,
11516            "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11517            "fetch_all_greeks" => self.fetch_all_greeks(&args[..]).await,
11518            "fetch_balance" => self.fetch_balance(&args[..]).await,
11519            "fetch_balance_ws" => self.fetch_balance_ws(&args[..]).await,
11520            "fetch_bids_asks" => self.fetch_bids_asks(&args[..]).await,
11521            "fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
11522            "fetch_borrow_rate" => self.fetch_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11523            "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
11524            "fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
11525            "fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
11526            "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args[..]).await,
11527            "fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11528            "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11529            "fetch_contract_tickers" => self.fetch_contract_tickers(&args[..]).await,
11530            "fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
11531            "fetch_convert_quote" => self.fetch_convert_quote(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11532            "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11533            "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
11534            "fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11535            "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args[..]).await,
11536            "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11537            "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args[..]).await,
11538            "fetch_deposit_addresses_by_network" => self.fetch_deposit_addresses_by_network(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11539            "fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11540            "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
11541            "fetch_deposits" => self.fetch_deposits(&args[..]).await,
11542            "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
11543            "fetch_deposits_ws" => self.fetch_deposits_ws(&args[..]).await,
11544            "fetch_free_balance" => self.fetch_free_balance(&args[..]).await,
11545            "fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
11546            "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11547            "fetch_funding_intervals" => self.fetch_funding_intervals(&args[..]).await,
11548            "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11549            "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
11550            "fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
11551            "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11552            "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11553            "fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11554            "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args[..]).await,
11555            "fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11556            "fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11557            "fetch_last_prices" => self.fetch_last_prices(&args[..]).await,
11558            "fetch_ledger" => self.fetch_ledger(&args[..]).await,
11559            "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11560            "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11561            "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args[..]).await,
11562            "fetch_leverages" => self.fetch_leverages(&args[..]).await,
11563            "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11564            "fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11565            "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args[..]).await,
11566            "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args[..]).await,
11567            "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11568            "fetch_margin_modes" => self.fetch_margin_modes(&args[..]).await,
11569            "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11570            "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11571            "fetch_mark_prices" => self.fetch_mark_prices(&args[..]).await,
11572            "fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11573            "fetch_my_liquidations" => self.fetch_my_liquidations(&args[..]).await,
11574            "fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
11575            "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args[..]).await,
11576            "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11577            "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11578            "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11579            "fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11580            "fetch_open_interests" => self.fetch_open_interests(&args[..]).await,
11581            "fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
11582            "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args[..]).await,
11583            "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11584            "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11585            "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11586            "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11587            "fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11588            "fetch_order_books" => self.fetch_order_books(&args[..]).await,
11589            "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11590            "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11591            "fetch_order_with_client_order_id" => self.fetch_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11592            "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11593            "fetch_orders" => self.fetch_orders(&args[..]).await,
11594            "fetch_orders_by_status_ws" => self.fetch_orders_by_status_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11595            "fetch_orders_ws" => self.fetch_orders_ws(&args[..]).await,
11596            "fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11597            "fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11598            "fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11599            "fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11600            "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11601            "fetch_payment_methods" => self.fetch_payment_methods(&args[..]).await,
11602            "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11603            "fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11604            "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11605            "fetch_position_mode" => self.fetch_position_mode(&args[..]).await,
11606            "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11607            "fetch_positions" => self.fetch_positions(&args[..]).await,
11608            "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args[..]).await,
11609            "fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11610            "fetch_positions_for_symbol_ws" => self.fetch_positions_for_symbol_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11611            "fetch_positions_history" => self.fetch_positions_history(&args[..]).await,
11612            "fetch_positions_risk" => self.fetch_positions_risk(&args[..]).await,
11613            "fetch_positions_ws" => self.fetch_positions_ws(&args[..]).await,
11614            "fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11615            "fetch_rest_order_book_safe" => self.fetch_rest_order_book_safe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11616            "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11617            "fetch_spot_tickers" => self.fetch_spot_tickers(&args[..]).await,
11618            "fetch_status" => self.fetch_status(&args[..]).await,
11619            "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11620            "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11621            "fetch_tickers" => self.fetch_tickers(&args[..]).await,
11622            "fetch_tickers_ws" => self.fetch_tickers_ws(&args[..]).await,
11623            "fetch_time" => self.fetch_time(&args[..]).await,
11624            "fetch_total_balance" => self.fetch_total_balance(&args[..]).await,
11625            "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11626            "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11627            "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11628            "fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
11629            "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args[..]).await,
11630            "fetch_trading_limits" => self.fetch_trading_limits(&args[..]).await,
11631            "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11632            "fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
11633            "fetch_transactions" => self.fetch_transactions(&args[..]).await,
11634            "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11635            "fetch_transfers" => self.fetch_transfers(&args[..]).await,
11636            "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11637            "fetch_used_balance" => self.fetch_used_balance(&args[..]).await,
11638            "fetch_web_endpoint" => self.fetch_web_endpoint(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[3.min(args.len())..]).await,
11639            "fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
11640            "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args[..]).await,
11641            "filter_by_array" => self.filter_by_array(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11642            "filter_by_array_adl_ranks" => self.filter_by_array_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11643            "filter_by_array_positions" => self.filter_by_array_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11644            "filter_by_array_tickers" => self.filter_by_array_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11645            "filter_by_currency_since_limit" => self.filter_by_currency_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11646            "filter_by_key" => self.filter_by_key(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11647            "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11648            "filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11649            "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11650            "filter_by_symbol_since_limit" => self.filter_by_symbol_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11651            "filter_by_symbols_since_limit" => self.filter_by_symbols_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11652            "filter_by_value_since_limit" => self.filter_by_value_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11653            "filter_out_by_array" => self.filter_out_by_array(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11654            "find_broadly_matched_key" => self.find_broadly_matched_key(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11655            "find_message_hashes" => self.find_message_hashes(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11656            "find_nearest_ceiling" => self.find_nearest_ceiling(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11657            "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11658            "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11659            "get_cache_index" => self.get_cache_index(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11660            "get_default_options" => self.get_default_options(),
11661            "get_describe_for_extended_ws_exchange" => self.get_describe_for_extended_ws_exchange(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)),
11662            "get_list_from_object_values" => self.get_list_from_object_values(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11663            "get_market_from_symbols" => self.get_market_from_symbols(&args[..]),
11664            "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11665            "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args[..]),
11666            "handle_errors" => <Self as crate::exchange_generated::ExchangeBase>::handle_errors(self, 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).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
11667            "handle_margin_mode_and_params" => self.handle_margin_mode_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11668            "handle_market_type_and_params" => self.handle_market_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11669            "handle_max_entries_per_request_and_params" => self.handle_max_entries_per_request_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11670            "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11671            "handle_option" => self.handle_option(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11672            "handle_option_and_params" => self.handle_option_and_params(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[3.min(args.len())..]),
11673            "handle_option_and_params2" => self.handle_option_and_params2(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[4.min(args.len())..]),
11674            "handle_param_bool" => self.handle_param_bool(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11675            "handle_param_bool2" => self.handle_param_bool2(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[3.min(args.len())..]),
11676            "handle_param_integer" => self.handle_param_integer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11677            "handle_param_integer2" => self.handle_param_integer2(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[3.min(args.len())..]),
11678            "handle_param_string" => self.handle_param_string(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11679            "handle_param_string2" => self.handle_param_string2(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[3.min(args.len())..]),
11680            "handle_post_only" => self.handle_post_only(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11681            "handle_request_network" => self.handle_request_network(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[3.min(args.len())..]),
11682            "handle_sub_type_and_params" => self.handle_sub_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11683            "handle_time_in_force" => self.handle_time_in_force(&args[..]),
11684            "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11685            "handle_trigger_direction_and_params" => self.handle_trigger_direction_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11686            "handle_trigger_prices_and_params" => self.handle_trigger_prices_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11687            "handle_until_option" => self.handle_until_option(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[3.min(args.len())..]),
11688            "handle_withdraw_tag_and_params" => self.handle_withdraw_tag_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11689            "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11690            "incrementing_nonce" => self.incrementing_nonce(),
11691            "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11692            "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11693            "is_decimal_precision" => self.is_decimal_precision(),
11694            "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11695            "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11696            "is_post_only" => self.is_post_only(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11697            "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11698            "is_significant_precision" => self.is_significant_precision(),
11699            "is_tick_precision" => self.is_tick_precision(),
11700            "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11701            "is_uta_enabled" => self.is_uta_enabled(&args[..]).await,
11702            "load_accounts" => self.load_accounts(&args[..]).await,
11703            "load_markets" => self.load_markets(&args[..]).await,
11704            "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
11705            "load_time_difference" => self.load_time_difference(&args[..]).await,
11706            "load_trading_limits" => self.load_trading_limits(&args[..]).await,
11707            "market" => self.market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11708            "market_codes" => self.market_codes(&args[..]),
11709            "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11710            "market_ids" => self.market_ids(&args[..]),
11711            "market_or_null" => self.market_or_null(&args[..]),
11712            "market_symbols" => self.market_symbols(&args[..]),
11713            "markets_for_symbols" => self.markets_for_symbols(&args[..]),
11714            "merge_balance_account" => self.merge_balance_account(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)),
11715            "network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11716            "network_id_to_code" => self.network_id_to_code(&args[..]),
11717            "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
11718            "oath" => self.oath(),
11719            "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11720            "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11721            "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11722            "parse_adl_rank" => <Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11723            "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11724            "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11725            "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11726            "parse_borrow_interest" => <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11727            "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11728            "parse_borrow_rate" => <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11729            "parse_borrow_rate_history" => self.parse_borrow_rate_history(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)),
11730            "parse_conversion" => <Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11731            "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11732            "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11733            "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11734            "parse_deposit_address" => <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11735            "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11736            "parse_deposit_withdraw_fee" => <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11737            "parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11738            "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11739            "parse_funding_rate" => <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11740            "parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11741            "parse_funding_rate_history" => <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11742            "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11743            "parse_greeks" => <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11744            "parse_income" => <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11745            "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11746            "parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11747            "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11748            "parse_last_price" => <Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11749            "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11750            "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11751            "parse_ledger_entry" => <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11752            "parse_leverage" => <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11753            "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11754            "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11755            "parse_liquidation" => <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11756            "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11757            "parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11758            "parse_long_short_ratio_history" => self.parse_long_short_ratio_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11759            "parse_margin_mode" => <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11760            "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11761            "parse_margin_modification" => <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11762            "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11763            "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11764            "parse_market_leverage_tiers" => <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11765            "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11766            "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11767            "parse_ohlcv" => <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11768            "parse_open_interest" => <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11769            "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11770            "parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11771            "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11772            "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11773            "parse_order" => <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11774            "parse_order_book" => <Self as crate::exchange_generated::ExchangeBase>::parse_order_book(self, args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11775            "parse_order_book_bid_ask" => self.parse_order_book_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11776            "parse_order_book_bids_asks" => self.parse_order_book_bids_asks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11777            "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11778            "parse_position" => <Self as crate::exchange_generated::ExchangeBase>::parse_position(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11779            "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11780            "parse_precision" => self.parse_precision(&args[..]),
11781            "parse_ticker" => <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11782            "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11783            "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11784            "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11785            "parse_trade" => <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11786            "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11787            "parse_trades_helper" => self.parse_trades_helper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11788            "parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11789            "parse_transaction" => <Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11790            "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11791            "parse_transfer" => <Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11792            "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11793            "parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11794            "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11795            "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11796            "parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11797            "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11798            "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11799            "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11800            "price_to_precision" => self.price_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11801            "prioritized_network_aliases" => self.prioritized_network_aliases(&args[..]),
11802            "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11803            "reduce_margin" => self.reduce_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11804            "remove_keys_from_dict" => self.remove_keys_from_dict(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11805            "remove_repeated_elements_from_array" => self.remove_repeated_elements_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11806            "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11807            "repay_cross_margin" => self.repay_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11808            "repay_isolated_margin" => self.repay_isolated_margin(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[3.min(args.len())..]).await,
11809            "repay_margin" => self.repay_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11810            "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11811            "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11812            "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11813            "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11814            "safe_bool" => self.safe_bool(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11815            "safe_bool2" => self.safe_bool2(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[3.min(args.len())..]),
11816            "safe_bool_n" => self.safe_bool_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11817            "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11818            "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11819            "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11820            "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11821            "safe_dict" => self.safe_dict(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11822            "safe_dict2" => self.safe_dict2(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[3.min(args.len())..]),
11823            "safe_dict_n" => self.safe_dict_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11824            "safe_integer_omit_zero" => self.safe_integer_omit_zero(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11825            "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11826            "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11827            "safe_list" => self.safe_list(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11828            "safe_list2" => self.safe_list2(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[3.min(args.len())..]),
11829            "safe_list_n" => self.safe_list_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11830            "safe_market" => self.safe_market(&args[..]),
11831            "safe_market_structure" => self.safe_market_structure(&args[..]),
11832            "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11833            "safe_number" => self.safe_number(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11834            "safe_number2" => self.safe_number2(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[3.min(args.len())..]),
11835            "safe_number_n" => self.safe_number_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11836            "safe_number_omit_zero" => self.safe_number_omit_zero(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11837            "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11838            "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11839            "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11840            "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11841            "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11842            "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11843            "select_network_code_from_unified_networks" => self.select_network_code_from_unified_networks(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)),
11844            "select_network_id_from_raw_networks" => self.select_network_id_from_raw_networks(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)),
11845            "select_network_key_from_networks" => self.select_network_key_from_networks(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[3.min(args.len())..]),
11846            "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11847            "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11848            "set_margin" => self.set_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11849            "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11850            "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11851            "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11852            "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11853            "set_take_profit_and_stop_loss_params" => self.set_take_profit_and_stop_loss_params(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[4.min(args.len())..]),
11854            "sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11855            "sign_in" => self.sign_in(&args[..]).await,
11856            "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11857            "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11858            "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11859            "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11860            "transfer" => self.transfer(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[4.min(args.len())..]).await,
11861            "un_watch_bids_asks" => self.un_watch_bids_asks(&args[..]).await,
11862            "un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11863            "un_watch_funding_rates" => self.un_watch_funding_rates(&args[..]).await,
11864            "un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11865            "un_watch_mark_prices" => self.un_watch_mark_prices(&args[..]).await,
11866            "un_watch_my_trades" => self.un_watch_my_trades(&args[..]).await,
11867            "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11868            "un_watch_ohlcv_for_symbols" => self.un_watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11869            "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11870            "un_watch_order_book_for_symbols" => self.un_watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11871            "un_watch_orders" => self.un_watch_orders(&args[..]).await,
11872            "un_watch_positions" => self.un_watch_positions(&args[..]).await,
11873            "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11874            "un_watch_tickers" => self.un_watch_tickers(&args[..]).await,
11875            "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11876            "un_watch_trades_for_symbols" => self.un_watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11877            "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11878            "watch_balance" => self.watch_balance(&args[..]).await,
11879            "watch_bids_asks" => self.watch_bids_asks(&args[..]).await,
11880            "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11881            "watch_funding_rates" => self.watch_funding_rates(&args[..]).await,
11882            "watch_funding_rates_for_symbols" => self.watch_funding_rates_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11883            "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11884            "watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11885            "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11886            "watch_mark_prices" => self.watch_mark_prices(&args[..]).await,
11887            "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11888            "watch_my_liquidations_for_symbols" => self.watch_my_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11889            "watch_my_trades" => self.watch_my_trades(&args[..]).await,
11890            "watch_my_trades_for_symbols" => self.watch_my_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11891            "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11892            "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11893            "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11894            "watch_order_book_for_symbols" => self.watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11895            "watch_orders" => self.watch_orders(&args[..]).await,
11896            "watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11897            "watch_position" => self.watch_position(&args[..]).await,
11898            "watch_position_for_symbols" => self.watch_position_for_symbols(&args[..]).await,
11899            "watch_positions" => self.watch_positions(&args[..]).await,
11900            "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11901            "watch_tickers" => self.watch_tickers(&args[..]).await,
11902            "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11903            "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11904            "withdraw" => self.withdraw(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[3.min(args.len())..]).await,
11905            "withdraw_ws" => self.withdraw_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[3.min(args.len())..]).await,
11906                // Implicit-API endpoints (`publicGetX`) exist only as inherent
11907                // methods on the venue's `<id>_api.rs`, which no name-based
11908                // dispatch arm covers — a static-request test named after one
11909                // (bingx's accountV1PrivateGetAccountApiRestrictions) otherwise
11910                // computes a null url. Route them the way those wrappers do.
11911                // Guarded on the api block so a genuinely unknown name still
11912                // returns Null rather than panicking inside call_method.
11913                //
11914                // Returning Null keeps an optional probe cheap, but a dynamic
11915                // re-entry (`fetchPaginatedCall*` / `fetchWebEndpoint`, which
11916                // reach here via `method_name_to_snake_case`) must not silently
11917                // see an empty page — so record the miss for
11918                // `crate::exchange::call_dynamic_required` to raise on.
11919                _ => {
11920                    if self.internals.implicit_api.is_empty() {
11921                        self.build_implicit_api();
11922                    }
11923                    if self.internals.implicit_api.contains_key(method) {
11924                        self.call_method(crate::Value::Str(method.to_string().into()), &args[..]).await
11925                    } else {
11926                        self.internals.dynamic_dispatch_miss = Some(method.to_string());
11927                        crate::Value::Null
11928                    }
11929                }
11930            }
11931        })
11932    }
11933}