Skip to main content

ccxt_common/
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 bookside: 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(bookside.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_book_deltas(&self, mut orderbook: Value, mut deltas: Value) {
698        {
699                        let mut i: Value = Value::Int(0);
700            let mut __for_first_72: bool = true;
701            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) } {
702            self.handle_book_delta(orderbook.clone(), get_value(&deltas, &i));
703        }
704        }
705}
706
707    fn handle_book_delta(&self, mut orderbook: Value, mut delta: Value) {
708        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" handleBookDelta not supported yet".into()))));
709}
710
711    fn handle_deltas_with_keys(&self, mut bookSide: Value, mut deltas: Value, optional_args: &[Value]) {
712        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
713        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
714        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
715        {
716                        let mut i: Value = Value::Int(0);
717            let mut __for_first_73: bool = true;
718            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) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
719            let mut bidAsk: Value = self.parse_order_book_bid_ask(get_value(&deltas, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
720            bookSide.store_array(bidAsk);
721        }
722        }
723}
724
725    fn get_cache_index(&self, mut orderbook: Value, mut deltas: Value) -> Value {
726        return Value::Int(-1);
727
728    Value::Null
729}
730
731    fn arrays_concat(&self, mut arraysOfArrays: Value) -> Value {
732        let mut result: Value = Value::from(vec![]);
733        {
734                        let mut i: Value = Value::Int(0);
735            let mut __for_first_74: bool = true;
736            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) < ((arraysOfArrays.len() as i64) as f64) } {
737            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));
738        }
739        }
740        return result;
741
742    Value::Null
743}
744
745    fn find_timeframe(&self, mut timeframe: Value, optional_args: &[Value]) -> Value {
746        let mut timeframes = get_arg(optional_args, 0, Value::Null);
747        let mut timeframesResolved: Value = (if (timeframes == Value::Null) { self.timeframes.clone() } else { timeframes });
748        let mut keys: Value = object_keys(&timeframesResolved);
749        {
750                        let mut i: Value = Value::Int(0);
751            let mut __for_first_75: bool = true;
752            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) < ((keys.len() as i64) as f64) } {
753            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);
754            if is_equal(&timeframesResolved.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &timeframe) {
755                return key;
756            }
757        }
758        }
759        return Value::Null;
760
761    Value::Null
762}
763
764    fn check_proxy_url_settings(&self, optional_args: &[Value]) -> Value {
765        let mut url = get_arg(optional_args, 0, Value::Null);
766        let mut method = get_arg(optional_args, 1, Value::Null);
767        let mut headers = get_arg(optional_args, 2, Value::Null);
768        let mut body = get_arg(optional_args, 3, Value::Null);
769        let mut usedProxies: Value = Value::from(vec![]);
770        let mut proxyUrl: Value = Value::Null;
771        if (self.proxyUrl.clone() != Value::Null) {
772            append_to_array(&mut usedProxies, Value::Str("proxyUrl".into()));
773            proxyUrl = self.proxyUrl.clone();
774        }
775        if (self.proxy_url.clone() != Value::Null) {
776            append_to_array(&mut usedProxies, Value::Str("proxy_url".into()));
777            proxyUrl = self.proxy_url.clone();
778        }
779        if (self.proxyUrlCallback.clone() != Value::Null) {
780            append_to_array(&mut usedProxies, Value::Str("proxyUrlCallback".into()));
781            proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
782        }
783        if (self.proxy_url_callback.clone() != Value::Null) {
784            append_to_array(&mut usedProxies, Value::Str("proxy_url_callback".into()));
785            proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
786        }
787        // backwards-compatibility
788        if (self.proxy.clone() != Value::Null) {
789            append_to_array(&mut usedProxies, Value::Str("proxy".into()));
790            if is_function(&self.proxy) {
791                proxyUrl = self.proxy_fn(url, method, headers, body);
792            }  else {
793                proxyUrl = self.proxy.clone();
794            }
795        }
796        let mut length: f64 = ((usedProxies.len() as i64) as f64);
797        if length > ((1i64) as f64) {
798            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
799            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()))));
800        }
801        return proxyUrl;
802
803    Value::Null
804}
805
806    fn url_encoder_for_proxy_url(&self, mut targetUrl: Value) -> Value {
807        // to be overriden
808        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);
809        let mut finalUrl: Value = (if includesQuery { self.encode_uri_component(targetUrl.clone()) } else { targetUrl });
810        return finalUrl;
811
812    Value::Null
813}
814
815    fn check_proxy_settings(&self, optional_args: &[Value]) -> Value {
816        let mut url = get_arg(optional_args, 0, Value::Null);
817        let mut method = get_arg(optional_args, 1, Value::Null);
818        let mut headers = get_arg(optional_args, 2, Value::Null);
819        let mut body = get_arg(optional_args, 3, Value::Null);
820        let mut usedProxies: Value = Value::from(vec![]);
821        let mut httpProxy: Value = Value::Null;
822        let mut httpsProxy: Value = Value::Null;
823        let mut socksProxy: Value = Value::Null;
824        // httpProxy
825        let mut isHttpProxyDefined: Value = self.value_is_defined(self.httpProxy.clone());
826        let mut isHttp_proxy_defined: Value = self.value_is_defined(self.http_proxy.clone());
827        if is_true(&isHttpProxyDefined) || is_true(&isHttp_proxy_defined) {
828            append_to_array(&mut usedProxies, Value::Str("httpProxy".into()));
829            httpProxy = (if is_true(&isHttpProxyDefined) { self.httpProxy.clone() } else { self.http_proxy.clone() });
830        }
831        let mut ishttpProxyCallbackDefined: Value = self.value_is_defined(self.httpProxyCallback.clone());
832        let mut ishttp_proxy_callback_defined: Value = self.value_is_defined(self.http_proxy_callback.clone());
833        if is_true(&ishttpProxyCallbackDefined) || is_true(&ishttp_proxy_callback_defined) {
834            append_to_array(&mut usedProxies, Value::Str("httpProxyCallback".into()));
835            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()) });
836        }
837        // httpsProxy
838        let mut isHttpsProxyDefined: Value = self.value_is_defined(self.httpsProxy.clone());
839        let mut isHttps_proxy_defined: Value = self.value_is_defined(self.https_proxy.clone());
840        if is_true(&isHttpsProxyDefined) || is_true(&isHttps_proxy_defined) {
841            append_to_array(&mut usedProxies, Value::Str("httpsProxy".into()));
842            httpsProxy = (if is_true(&isHttpsProxyDefined) { self.httpsProxy.clone() } else { self.https_proxy.clone() });
843        }
844        let mut ishttpsProxyCallbackDefined: Value = self.value_is_defined(self.httpsProxyCallback.clone());
845        let mut ishttps_proxy_callback_defined: Value = self.value_is_defined(self.https_proxy_callback.clone());
846        if is_true(&ishttpsProxyCallbackDefined) || is_true(&ishttps_proxy_callback_defined) {
847            append_to_array(&mut usedProxies, Value::Str("httpsProxyCallback".into()));
848            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()) });
849        }
850        // socksProxy
851        let mut isSocksProxyDefined: Value = self.value_is_defined(self.socksProxy.clone());
852        let mut isSocks_proxy_defined: Value = self.value_is_defined(self.socks_proxy.clone());
853        if is_true(&isSocksProxyDefined) || is_true(&isSocks_proxy_defined) {
854            append_to_array(&mut usedProxies, Value::Str("socksProxy".into()));
855            socksProxy = (if is_true(&isSocksProxyDefined) { self.socksProxy.clone() } else { self.socks_proxy.clone() });
856        }
857        let mut issocksProxyCallbackDefined: Value = self.value_is_defined(self.socksProxyCallback.clone());
858        let mut issocks_proxy_callback_defined: Value = self.value_is_defined(self.socks_proxy_callback.clone());
859        if is_true(&issocksProxyCallbackDefined) || is_true(&issocks_proxy_callback_defined) {
860            append_to_array(&mut usedProxies, Value::Str("socksProxyCallback".into()));
861            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) });
862        }
863        // check
864        let mut length: f64 = ((usedProxies.len() as i64) as f64);
865        if length > ((1i64) as f64) {
866            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
867            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()))));
868        }
869        return Value::from(vec![httpProxy, httpsProxy, socksProxy]);
870
871    Value::Null
872}
873
874    fn check_ws_proxy_settings(&self) -> Value {
875        let mut usedProxies: Value = Value::from(vec![]);
876        let mut wsProxy: Value = Value::Null;
877        let mut wssProxy: Value = Value::Null;
878        let mut wsSocksProxy: Value = Value::Null;
879        // ws proxy
880        let mut isWsProxyDefined: Value = self.value_is_defined(self.wsProxy.clone());
881        let mut is_ws_proxy_defined: Value = self.value_is_defined(self.ws_proxy.clone());
882        if is_true(&isWsProxyDefined) || is_true(&is_ws_proxy_defined) {
883            append_to_array(&mut usedProxies, Value::Str("wsProxy".into()));
884            wsProxy = (if is_true(&(isWsProxyDefined)) { self.wsProxy.clone() } else { self.ws_proxy.clone() });
885        }
886        // wss proxy
887        let mut isWssProxyDefined: Value = self.value_is_defined(self.wssProxy.clone());
888        let mut is_wss_proxy_defined: Value = self.value_is_defined(self.wss_proxy.clone());
889        if is_true(&isWssProxyDefined) || is_true(&is_wss_proxy_defined) {
890            append_to_array(&mut usedProxies, Value::Str("wssProxy".into()));
891            wssProxy = (if is_true(&(isWssProxyDefined)) { self.wssProxy.clone() } else { self.wss_proxy.clone() });
892        }
893        // ws socks proxy
894        let mut isWsSocksProxyDefined: Value = self.value_is_defined(self.wsSocksProxy.clone());
895        let mut is_ws_socks_proxy_defined: Value = self.value_is_defined(self.ws_socks_proxy.clone());
896        if is_true(&isWsSocksProxyDefined) || is_true(&is_ws_socks_proxy_defined) {
897            append_to_array(&mut usedProxies, Value::Str("wsSocksProxy".into()));
898            wsSocksProxy = (if is_true(&(isWsSocksProxyDefined)) { self.wsSocksProxy.clone() } else { self.ws_socks_proxy.clone() });
899        }
900        // check
901        let mut length: f64 = ((usedProxies.len() as i64) as f64);
902        if length > ((1i64) as f64) {
903            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
904            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()))));
905        }
906        return Value::from(vec![wsProxy, wssProxy, wsSocksProxy]);
907
908    Value::Null
909}
910
911    fn check_conflicting_proxies(&self, mut proxyAgentSet: Value, mut proxyUrlSet: Value) {
912        let mut proxyAgentIsSet: bool = (proxyAgentSet != Value::Null) && (proxyAgentSet != Value::Null) && (proxyAgentSet.as_str() != Some(""));
913        let mut proxyUrlIsSet: bool = (proxyUrlSet != Value::Null) && (proxyUrlSet != Value::Null) && (proxyUrlSet.as_str() != Some(""));
914        if proxyAgentIsSet && proxyUrlIsSet {
915            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()))));
916        }
917}
918
919    fn check_address(&self, optional_args: &[Value]) -> Value {
920        let mut address = get_arg(optional_args, 0, Value::Null);
921        let mut code = get_arg(optional_args, 1, Value::Null);
922        let mut tag = get_arg(optional_args, 2, Value::Null);
923        if (address == Value::Null) {
924            panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", self.id.clone(), Value::Str(" address is undefined".into()))));
925        }
926        // check the address is not the same letter like 'aaaaa' nor too short nor has a space
927        let mut uniqChars: Value = (self.unique(self.string_to_chars_array(address.clone())));
928        let mut length: f64 = ((uniqChars.len() as i64) as f64); // py transpiler trick
929        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) {
930            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()))));
931        }
932        if (code != Value::Null) {
933            let mut tagRequiredCurrencies: Value = self.safe_list_k(self.options.clone(), "withdrawTagRequiredCurrencies", &[Value::from(vec![])]);
934            if self.in_array(code.clone(), tagRequiredCurrencies).as_bool() == Some(true) {
935                if (tag == Value::Null) {
936                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" withdraw() requires params[\"tag\"] for ".into())).into()), code)));
937                }
938            }
939        }
940        return address;
941
942    Value::Null
943}
944
945    fn find_message_hashes(&self, mut client: Value, mut element: Value) -> Value {
946        let mut result: Value = Value::from(vec![]);
947        let mut messageHashes: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
948        {
949                        let mut i: Value = Value::Int(0);
950            let mut __for_first_76: bool = true;
951            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) < ((messageHashes.len() as i64) as f64) } {
952            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);
953            if get_index_of(&messageHash, &element).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
954                append_to_array(&mut result, messageHash.clone());
955            }
956        }
957        }
958        return result;
959
960    Value::Null
961}
962
963    fn filter_by_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
964        let mut limit = get_arg(optional_args, 0, Value::Null);
965        let mut key = get_arg(optional_args, 1, Value::Str("timestamp".into()));
966        let mut fromStart = get_arg(optional_args, 2, Value::Bool(false));
967        if self.value_is_defined(limit.clone()).as_bool() == Some(true) {
968            let mut arrayLength: Value = Value::Int(array.len() as i64);
969            if arrayLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
970                let mut ascending: bool = true;
971                if (in_op(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key)) {
972                    let mut first: Value = get_value(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key);
973                    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);
974                    if (first != Value::Null) && (last != Value::Null) {
975                        ascending = is_less_than_or_equal(&first, &last); // true if array is sorted in ascending order based on 'timestamp'
976                    }
977                }
978                if is_true(&fromStart) {
979                    let mut limitResolved: Value = (if (limit.as_f64().unwrap_or(f64::NAN) > arrayLength.as_f64().unwrap_or(f64::NAN)) { arrayLength } else { limit.clone() });
980                    if ascending {
981                        return self.array_slice(array.clone(), Value::Int(0), &[limitResolved.clone()]);
982                    }
983                    return self.array_slice(array.clone(), negate(&limitResolved), &[]);
984                }
985                if ascending {
986                    return self.array_slice(array.clone(), negate(&limit), &[]);
987                }
988                return self.array_slice(array.clone(), Value::Int(0), &[limit]);
989            }
990        }
991        return array;
992
993    Value::Null
994}
995
996    fn filter_by_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
997        let mut since = get_arg(optional_args, 0, Value::Null);
998        let mut limit = get_arg(optional_args, 1, Value::Null);
999        let mut key = get_arg(optional_args, 2, Value::Str("timestamp".into()));
1000        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
1001        if (array == Value::Null) {
1002            return Value::from(vec![]);
1003        }
1004        let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
1005        let mut parsedArray: Value = self.to_array(array);
1006        let mut result: Value = parsedArray.clone();
1007        if is_true(&sinceIsDefined) {
1008            result = Value::from(vec![]);
1009            {
1010                                let mut i: Value = Value::Int(0);
1011                let mut __for_first_77: bool = true;
1012                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) } {
1013                let mut entry: Value = get_value(&parsedArray, &i);
1014                let mut entry: Value = get_value(&parsedArray, &i);
1015                let mut value: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1016                if (value != Value::Null) && (value != Value::Null) && (!is_equal(&value, &Value::Int(0))) && (is_greater_than_or_equal(&value, &since)) {
1017                    append_to_array(&mut result, entry);
1018                }
1019            }
1020            }
1021        }
1022        if is_true(&tail) && (limit != Value::Null) {
1023            return self.array_slice(result.clone(), negate(&limit), &[]);
1024        }
1025        // if the user provided a 'since' argument
1026        // we want to limit the result starting from the 'since'
1027        let mut shouldFilterFromStart: Value = Value::Bool(!is_true(&tail) && is_true(&sinceIsDefined));
1028        return self.filter_by_limit(result, &[limit, key, shouldFilterFromStart]);
1029
1030    Value::Null
1031}
1032
1033    fn filter_by_value_since_limit(&self, mut array: Value, mut field: Value, optional_args: &[Value]) -> Value {
1034        let mut value = get_arg(optional_args, 0, Value::Null);
1035        let mut since = get_arg(optional_args, 1, Value::Null);
1036        let mut limit = get_arg(optional_args, 2, Value::Null);
1037        let mut key = get_arg(optional_args, 3, Value::Str("timestamp".into()));
1038        let mut tail = get_arg(optional_args, 4, Value::Bool(false));
1039        let mut valueIsDefined: Value = self.value_is_defined(value.clone());
1040        let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
1041        let mut parsedArray: Value = self.to_array(array);
1042        let mut result: Value = parsedArray.clone();
1043        // single-pass filter for both symbol and since
1044        if is_true(&valueIsDefined) || is_true(&sinceIsDefined) {
1045            result = Value::from(vec![]);
1046            {
1047                                let mut i: Value = Value::Int(0);
1048                let mut __for_first_78: bool = true;
1049                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) < get_array_length(&parsedArray).as_f64().unwrap_or(f64::NAN) } {
1050                let mut entry: Value = get_value(&parsedArray, &i);
1051                let mut entry: Value = get_value(&parsedArray, &i);
1052                // safeValue (not entry[field]) so a missing field is a non-match, not a
1053                // KeyError in python/php — prediction structures key on outcome, not symbol
1054                let mut entryFiledEqualValue: Value = Value::Bool(is_equal(&self.safe_value(entry.clone(), field.clone(), &[]), &value));
1055                let mut firstCondition: Value = (if is_true(&valueIsDefined) { entryFiledEqualValue } else { Value::Bool(true) });
1056                let mut entryKeyValue: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1057                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)));
1058                let mut secondCondition: Value = (if is_true(&sinceIsDefined) { entryKeyGESince } else { Value::Bool(true) });
1059                if is_true(&firstCondition) && is_true(&secondCondition) {
1060                    append_to_array(&mut result, entry);
1061                }
1062            }
1063            }
1064        }
1065        if is_true(&tail) && (limit != Value::Null) {
1066            return self.array_slice(result.clone(), negate(&limit), &[]);
1067        }
1068        return self.filter_by_limit(result, &[limit, key, sinceIsDefined]);
1069
1070    Value::Null
1071}
1072
1073/*
1074 * @method
1075 * @name Exchange#setSandboxMode
1076 * @description set the sandbox mode for the exchange
1077 * @param {boolean} enabled true to enable sandbox mode, false to disable it
1078 */
1079    fn set_sandbox_mode(&mut self, mut enabled: Value) {
1080        if is_true(&enabled) {
1081            if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("test"))) {
1082                if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1083                    { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".into()), __be_tmp); };
1084                    { let __be_tmp = crate::value::get_value_k(&self.urls, "test"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1085                }  else {
1086                    { 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); };
1087                    { 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); };
1088                }
1089            }  else {
1090                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" does not have a sandbox URL".into()))));
1091            }
1092            // set flag
1093            self.isSandboxModeEnabled = Value::Bool(true);
1094        }  else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackup"))) {
1095            if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1096                { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackup"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1097            }  else {
1098                { 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); };
1099            }
1100            let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackup".into()), &[]);
1101            self.urls = newUrls;
1102            // set flag
1103            self.isSandboxModeEnabled = Value::Bool(false);
1104        }
1105}
1106
1107/*
1108 * @method
1109 * @name Exchange#enableDemoTrading
1110 * @description enables or disables demo trading mode
1111 * @param {boolean} [enable] true if demo trading should be enabled, false otherwise
1112 */
1113    fn enable_demo_trading(&mut self, mut enable: Value) {
1114        if is_true(&self.isSandboxModeEnabled) {
1115            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()))));
1116        }
1117        if is_true(&enable) {
1118            { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); add_element_to_object(&mut self.urls, &Value::Str("apiBackupDemoTrading".into()), __be_tmp); };
1119            { let __be_tmp = crate::value::get_value_k(&self.urls, "demo"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1120        }  else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackupDemoTrading"))) {
1121            { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackupDemoTrading"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1122            let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".into()), &[]);
1123            self.urls = newUrls;
1124        }
1125        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("enableDemoTrading".into(), enable); }
1126}
1127
1128    fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
1129        // virtual-dispatch (static: DerivedExchange::sign(self, ...))
1130        { 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; } }
1131
1132        let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
1133        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
1134        let mut params = get_arg(optional_args, 2, Value::Map({
1135    let mut m = indexmap::IndexMap::new();
1136    m
1137}));
1138        let mut headers = get_arg(optional_args, 3, Value::Null);
1139        let mut body = get_arg(optional_args, 4, Value::Null);
1140        return Value::Map({
1141    let mut m = indexmap::IndexMap::new();
1142        m.insert("url".to_string(), Value::Null);
1143        m.insert("method".to_string(), Value::Null);
1144        m.insert("headers".to_string(), Value::Null);
1145        m.insert("body".to_string(), Value::Null);
1146    m
1147});
1148
1149    Value::Null
1150}
1151
1152    fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1153        let mut params = get_arg(optional_args, 0, Value::Map({
1154    let mut m = indexmap::IndexMap::new();
1155    m
1156}));
1157        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAccounts() is not supported yet".into()))));
1158
1159    Value::Null
1160} }
1161
1162    fn watch_liquidations(&mut self, mut symbol: 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        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)) {
1170            return self.watch_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1171        }
1172        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidations() is not supported yet".into()))));
1173
1174    Value::Null
1175} }
1176
1177    fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1178        let mut since = get_arg(optional_args, 0, Value::Null);
1179        let mut limit = get_arg(optional_args, 1, Value::Null);
1180        let mut params = get_arg(optional_args, 2, Value::Map({
1181    let mut m = indexmap::IndexMap::new();
1182    m
1183}));
1184        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidationsForSymbols() is not supported yet".into()))));
1185
1186    Value::Null
1187} }
1188
1189    fn watch_my_liquidations(&mut self, mut symbol: 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        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)) {
1197            return self.watch_my_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1198        }
1199        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidations() is not supported yet".into()))));
1200
1201    Value::Null
1202} }
1203
1204    fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1205        let mut since = get_arg(optional_args, 0, Value::Null);
1206        let mut limit = get_arg(optional_args, 1, Value::Null);
1207        let mut params = get_arg(optional_args, 2, Value::Map({
1208    let mut m = indexmap::IndexMap::new();
1209    m
1210}));
1211        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".into()))));
1212
1213    Value::Null
1214} }
1215
1216    fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1217        let mut symbol = get_arg(optional_args, 0, Value::Null);
1218        let mut params = get_arg(optional_args, 1, Value::Map({
1219    let mut m = indexmap::IndexMap::new();
1220    m
1221}));
1222        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrders() is not supported yet".into()))));
1223
1224    Value::Null
1225} }
1226
1227    fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1228        let mut params = get_arg(optional_args, 0, Value::Map({
1229    let mut m = indexmap::IndexMap::new();
1230    m
1231}));
1232        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTrades() is not supported yet".into()))));
1233
1234    Value::Null
1235} }
1236
1237    fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1238        let mut params = get_arg(optional_args, 0, Value::Map({
1239    let mut m = indexmap::IndexMap::new();
1240    m
1241}));
1242        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTradesForSymbols() is not supported yet".into()))));
1243
1244    Value::Null
1245} }
1246
1247    fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1248        let mut since = get_arg(optional_args, 0, Value::Null);
1249        let mut limit = get_arg(optional_args, 1, Value::Null);
1250        let mut params = get_arg(optional_args, 2, Value::Map({
1251    let mut m = indexmap::IndexMap::new();
1252    m
1253}));
1254        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCVForSymbols() is not supported yet".into()))));
1255
1256    Value::Null
1257} }
1258
1259    fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1260        let mut params = get_arg(optional_args, 0, Value::Map({
1261    let mut m = indexmap::IndexMap::new();
1262    m
1263}));
1264        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCVForSymbols() is not supported yet".into()))));
1265
1266    Value::Null
1267} }
1268
1269    fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1270        let mut params = get_arg(optional_args, 0, Value::Map({
1271    let mut m = indexmap::IndexMap::new();
1272    m
1273}));
1274        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBookForSymbols() is not supported yet".into()))));
1275
1276    Value::Null
1277} }
1278
1279    fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1280        let mut symbols = get_arg(optional_args, 0, Value::Null);
1281        let mut params = get_arg(optional_args, 1, Value::Map({
1282    let mut m = indexmap::IndexMap::new();
1283    m
1284}));
1285        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchPositions() is not supported yet".into()))));
1286
1287    Value::Null
1288} }
1289
1290    fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1291        let mut params = get_arg(optional_args, 0, Value::Map({
1292    let mut m = indexmap::IndexMap::new();
1293    m
1294}));
1295        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTicker() is not supported yet".into()))));
1296
1297    Value::Null
1298} }
1299
1300    fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1301        let mut params = get_arg(optional_args, 0, Value::Map({
1302    let mut m = indexmap::IndexMap::new();
1303    m
1304}));
1305        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrice() is not supported yet".into()))));
1306
1307    Value::Null
1308} }
1309
1310    fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1311        let mut symbols = get_arg(optional_args, 0, Value::Null);
1312        let mut params = get_arg(optional_args, 1, Value::Map({
1313    let mut m = indexmap::IndexMap::new();
1314    m
1315}));
1316        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrices() is not supported yet".into()))));
1317
1318    Value::Null
1319} }
1320
1321    fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1322        // async-virtual: try the derived exchange first
1323        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 {
1324            if !matches!(__v, crate::Value::Null) { return __v; }
1325        }
1326
1327        let mut codes = get_arg(optional_args, 0, Value::Null);
1328        let mut params = get_arg(optional_args, 1, Value::Map({
1329    let mut m = indexmap::IndexMap::new();
1330    m
1331}));
1332        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddresses() is not supported yet".into()))));
1333
1334    Value::Null
1335} }
1336
1337    fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1338        // async-virtual: try the derived exchange first
1339        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 {
1340            if !matches!(__v, crate::Value::Null) { return __v; }
1341        }
1342
1343        let mut params = get_arg(optional_args, 0, Value::Map({
1344    let mut m = indexmap::IndexMap::new();
1345    m
1346}));
1347        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)) {
1348            let mut marginModes: Value = self.fetch_margin_modes(&[Value::from(vec![symbol.clone()]), params]).await;
1349            let mut marginMode: Value = self.safe_dict(marginModes, symbol, &[]);
1350            return marginMode;
1351        }  else {
1352            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginMode() is not supported yet".into()))));
1353        }
1354
1355    Value::Null
1356} }
1357
1358    fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1359        // async-virtual: try the derived exchange first
1360        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 {
1361            if !matches!(__v, crate::Value::Null) { return __v; }
1362        }
1363
1364        let mut symbols = get_arg(optional_args, 0, Value::Null);
1365        let mut params = get_arg(optional_args, 1, Value::Map({
1366    let mut m = indexmap::IndexMap::new();
1367    m
1368}));
1369        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginModes () is not supported yet".into()))));
1370
1371    Value::Null
1372} }
1373
1374    fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1375        let mut params = get_arg(optional_args, 0, Value::Map({
1376    let mut m = indexmap::IndexMap::new();
1377    m
1378}));
1379        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBook() is not supported yet".into()))));
1380
1381    Value::Null
1382} }
1383
1384    fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1385        // async-virtual: try the derived exchange first
1386        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 {
1387            if !matches!(__v, crate::Value::Null) { return __v; }
1388        }
1389
1390        let mut params = get_arg(optional_args, 0, Value::Map({
1391    let mut m = indexmap::IndexMap::new();
1392    m
1393}));
1394        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTime() is not supported yet".into()))));
1395
1396    Value::Null
1397} }
1398
1399    fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1400        let mut symbols = get_arg(optional_args, 0, Value::Null);
1401        let mut params = get_arg(optional_args, 1, Value::Map({
1402    let mut m = indexmap::IndexMap::new();
1403    m
1404}));
1405        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingLimits() is not supported yet".into()))));
1406
1407    Value::Null
1408} }
1409
1410    fn parse_currency(&self, mut rawCurrency: Value) -> Value {
1411        // virtual-dispatch (static: DerivedExchange::parse_currency(self, ...))
1412        { let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency); if !matches!(__v, crate::Value::Null) { return __v; } }
1413
1414        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseCurrency() is not supported yet".into()))));
1415
1416    Value::Null
1417}
1418
1419    fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
1420        let mut result: Value = Value::Map({
1421            let mut m = indexmap::IndexMap::new();
1422            m
1423        });
1424        let mut arr: Value = self.to_array(rawCurrencies);
1425        {
1426                        let mut i: Value = Value::Int(0);
1427            let mut __for_first_79: bool = true;
1428            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) < ((arr.len() as i64) as f64) } {
1429            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));
1430            if (parsed == Value::Null) {
1431                continue;
1432            }
1433            let mut code: Value = parsed.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
1434            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), parsed); }
1435        }
1436        }
1437        return result;
1438
1439    Value::Null
1440}
1441
1442    fn parse_market(&self, mut market: Value) -> Value {
1443        // virtual-dispatch (static: DerivedExchange::parse_market(self, ...))
1444        { let __v = crate::exchange::DerivedExchange::parse_market(self, market); if !matches!(__v, crate::Value::Null) { return __v; } }
1445
1446        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarket() is not supported yet".into()))));
1447
1448    Value::Null
1449}
1450
1451    fn parse_markets(&self, mut markets: Value) -> Value {
1452        let mut result: Value = Value::from(vec![]);
1453        {
1454                        let mut i: Value = Value::Int(0);
1455            let mut __for_first_80: bool = true;
1456            while { if !__for_first_80 { 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_80 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
1457            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i));
1458            // parseMarket returns undefined for a market it cannot build (e.g. unknown base or quote)
1459            if (market != Value::Null) {
1460                append_to_array(&mut result, market);
1461            }
1462        }
1463        }
1464        return result;
1465
1466    Value::Null
1467}
1468
1469    fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
1470        // virtual-dispatch (static: DerivedExchange::parse_ticker(self, ...))
1471        { 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; } }
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(" parseTicker() is not supported yet".into()))));
1475
1476    Value::Null
1477}
1478
1479    fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
1480        // virtual-dispatch (static: DerivedExchange::parse_deposit_address(self, ...))
1481        { 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; } }
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(" parseDepositAddress() is not supported yet".into()))));
1485
1486    Value::Null
1487}
1488
1489    fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1490        // virtual-dispatch (static: DerivedExchange::parse_trade(self, ...))
1491        { 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; } }
1492
1493        let mut market = get_arg(optional_args, 0, Value::Null);
1494        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTrade() is not supported yet".into()))));
1495
1496    Value::Null
1497}
1498
1499    fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
1500        // virtual-dispatch (static: DerivedExchange::parse_transaction(self, ...))
1501        { 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; } }
1502
1503        let mut currency = get_arg(optional_args, 0, Value::Null);
1504        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransaction() is not supported yet".into()))));
1505
1506    Value::Null
1507}
1508
1509    fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
1510        // virtual-dispatch (static: DerivedExchange::parse_transfer(self, ...))
1511        { 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; } }
1512
1513        let mut currency = get_arg(optional_args, 0, Value::Null);
1514        if (transfer == Value::Null) {
1515            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1516        }
1517        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1518
1519    Value::Null
1520}
1521
1522    fn parse_account(&self, mut account: Value) -> Value {
1523        // virtual-dispatch (static: DerivedExchange::parse_account(self, ...))
1524        { let __v = crate::exchange::DerivedExchange::parse_account(self, account); if !matches!(__v, crate::Value::Null) { return __v; } }
1525
1526        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseAccount() is not supported yet".into()))));
1527
1528    Value::Null
1529}
1530
1531    fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
1532        // virtual-dispatch (static: DerivedExchange::parse_ledger_entry(self, ...))
1533        { 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; } }
1534
1535        let mut currency = get_arg(optional_args, 0, Value::Null);
1536        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLedgerEntry() is not supported yet".into()))));
1537
1538    Value::Null
1539}
1540
1541    fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1542        // virtual-dispatch (static: DerivedExchange::parse_order(self, ...))
1543        { 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; } }
1544
1545        let mut market = get_arg(optional_args, 0, Value::Null);
1546        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOrder() is not supported yet".into()))));
1547
1548    Value::Null
1549}
1550
1551    fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1552        let mut params = get_arg(optional_args, 0, Value::Map({
1553    let mut m = indexmap::IndexMap::new();
1554    m
1555}));
1556        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRates() is not supported yet".into()))));
1557
1558    Value::Null
1559} }
1560
1561    fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1562        let mut params = get_arg(optional_args, 0, Value::Map({
1563    let mut m = indexmap::IndexMap::new();
1564    m
1565}));
1566        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRates() is not supported yet".into()))));
1567
1568    Value::Null
1569} }
1570
1571    fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
1572        // virtual-dispatch (static: DerivedExchange::parse_market_leverage_tiers(self, ...))
1573        { 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; } }
1574
1575        let mut market = get_arg(optional_args, 0, Value::Null);
1576        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarketLeverageTiers() is not supported yet".into()))));
1577
1578    Value::Null
1579}
1580
1581    fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1582        // async-virtual: try the derived exchange first
1583        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 {
1584            if !matches!(__v, crate::Value::Null) { return __v; }
1585        }
1586
1587        let mut symbols = get_arg(optional_args, 0, Value::Null);
1588        let mut params = get_arg(optional_args, 1, Value::Map({
1589    let mut m = indexmap::IndexMap::new();
1590    m
1591}));
1592        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverageTiers() is not supported yet".into()))));
1593
1594    Value::Null
1595} }
1596
1597    fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
1598        // virtual-dispatch (static: DerivedExchange::parse_position(self, ...))
1599        { 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; } }
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(" parsePosition() is not supported yet".into()))));
1603
1604    Value::Null
1605}
1606
1607    fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
1608        // virtual-dispatch (static: DerivedExchange::parse_funding_rate_history(self, ...))
1609        { 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; } }
1610
1611        let mut market = get_arg(optional_args, 0, Value::Null);
1612        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRateHistory() is not supported yet".into()))));
1613
1614    Value::Null
1615}
1616
1617    fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
1618        // virtual-dispatch (static: DerivedExchange::parse_borrow_interest(self, ...))
1619        { 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; } }
1620
1621        let mut market = get_arg(optional_args, 0, Value::Null);
1622        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowInterest() is not supported yet".into()))));
1623
1624    Value::Null
1625}
1626
1627    fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
1628        let mut market = get_arg(optional_args, 0, Value::Null);
1629        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIsolatedBorrowRate() is not supported yet".into()))));
1630
1631    Value::Null
1632}
1633
1634    fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1635        let mut market = get_arg(optional_args, 0, Value::Null);
1636        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsTrade() is not supported yet".into()))));
1637
1638    Value::Null
1639}
1640
1641    fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1642        let mut market = get_arg(optional_args, 0, Value::Null);
1643        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrder() is not supported yet".into()))));
1644
1645    Value::Null
1646}
1647
1648    fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1649        let mut market = get_arg(optional_args, 0, Value::Null);
1650        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrderTrade() is not supported yet".into()))));
1651
1652    Value::Null
1653}
1654
1655    fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
1656        let mut market = get_arg(optional_args, 0, Value::Null);
1657        return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv, &[market]);
1658
1659    Value::Null
1660}
1661
1662    fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1663        // async-virtual: try the derived exchange first
1664        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 {
1665            if !matches!(__v, crate::Value::Null) { return __v; }
1666        }
1667
1668        let mut symbols = get_arg(optional_args, 0, Value::Null);
1669        let mut params = get_arg(optional_args, 1, Value::Map({
1670    let mut m = indexmap::IndexMap::new();
1671    m
1672}));
1673        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRates() is not supported yet".into()))));
1674
1675    Value::Null
1676} }
1677
1678    fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1679        // async-virtual: try the derived exchange first
1680        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 {
1681            if !matches!(__v, crate::Value::Null) { return __v; }
1682        }
1683
1684        let mut symbols = get_arg(optional_args, 0, Value::Null);
1685        let mut params = get_arg(optional_args, 1, Value::Map({
1686    let mut m = indexmap::IndexMap::new();
1687    m
1688}));
1689        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingIntervals() is not supported yet".into()))));
1690
1691    Value::Null
1692} }
1693
1694    fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1695        let mut params = get_arg(optional_args, 0, Value::Map({
1696    let mut m = indexmap::IndexMap::new();
1697    m
1698}));
1699        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRate() is not supported yet".into()))));
1700
1701    Value::Null
1702} }
1703
1704    fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1705        let mut symbols = get_arg(optional_args, 0, Value::Null);
1706        let mut params = get_arg(optional_args, 1, Value::Map({
1707    let mut m = indexmap::IndexMap::new();
1708    m
1709}));
1710        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRates() is not supported yet".into()))));
1711
1712    Value::Null
1713} }
1714
1715    fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1716        let mut symbols = get_arg(optional_args, 0, Value::Null);
1717        let mut params = get_arg(optional_args, 1, Value::Map({
1718    let mut m = indexmap::IndexMap::new();
1719    m
1720}));
1721        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRates() is not supported yet".into()))));
1722
1723    Value::Null
1724} }
1725
1726    fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1727        let mut params = get_arg(optional_args, 0, Value::Map({
1728    let mut m = indexmap::IndexMap::new();
1729    m
1730}));
1731        return self.watch_funding_rates(&[symbols, params]).await;
1732
1733    Value::Null
1734} }
1735
1736    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 {
1737        // async-virtual: try the derived exchange first
1738        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 {
1739            if !matches!(__v, crate::Value::Null) { return __v; }
1740        }
1741
1742        let mut params = get_arg(optional_args, 0, Value::Map({
1743    let mut m = indexmap::IndexMap::new();
1744    m
1745}));
1746        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" transfer() is not supported yet".into()))));
1747
1748    Value::Null
1749} }
1750
1751    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 {
1752        // async-virtual: try the derived exchange first
1753        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 {
1754            if !matches!(__v, crate::Value::Null) { return __v; }
1755        }
1756
1757        let mut params = get_arg(optional_args, 0, Value::Map({
1758    let mut m = indexmap::IndexMap::new();
1759    m
1760}));
1761        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdraw() is not supported yet".into()))));
1762
1763    Value::Null
1764} }
1765
1766    fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1767        let mut params = get_arg(optional_args, 0, Value::Map({
1768    let mut m = indexmap::IndexMap::new();
1769    m
1770}));
1771        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createDepositAddress() is not supported yet".into()))));
1772
1773    Value::Null
1774} }
1775
1776    fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1777        // async-virtual: try the derived exchange first
1778        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 {
1779            if !matches!(__v, crate::Value::Null) { return __v; }
1780        }
1781
1782        let mut symbol = get_arg(optional_args, 0, Value::Null);
1783        let mut params = get_arg(optional_args, 1, Value::Map({
1784    let mut m = indexmap::IndexMap::new();
1785    m
1786}));
1787        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() is not supported yet".into()))));
1788
1789    Value::Null
1790} }
1791
1792    fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1793        // async-virtual: try the derived exchange first
1794        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 {
1795            if !matches!(__v, crate::Value::Null) { return __v; }
1796        }
1797
1798        let mut params = get_arg(optional_args, 0, Value::Map({
1799    let mut m = indexmap::IndexMap::new();
1800    m
1801}));
1802        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)) {
1803            let mut leverages: Value = self.fetch_leverages(&[Value::from(vec![symbol.clone()]), params]).await;
1804            let mut leverage: Value = self.safe_dict(leverages, symbol, &[]);
1805            return leverage;
1806        }  else {
1807            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverage() is not supported yet".into()))));
1808        }
1809
1810    Value::Null
1811} }
1812
1813    fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1814        // async-virtual: try the derived exchange first
1815        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 {
1816            if !matches!(__v, crate::Value::Null) { return __v; }
1817        }
1818
1819        let mut symbols = get_arg(optional_args, 0, Value::Null);
1820        let mut params = get_arg(optional_args, 1, Value::Map({
1821    let mut m = indexmap::IndexMap::new();
1822    m
1823}));
1824        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverages() is not supported yet".into()))));
1825
1826    Value::Null
1827} }
1828
1829    fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1830        // async-virtual: try the derived exchange first
1831        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 {
1832            if !matches!(__v, crate::Value::Null) { return __v; }
1833        }
1834
1835        let mut symbol = get_arg(optional_args, 0, Value::Null);
1836        let mut params = get_arg(optional_args, 1, Value::Map({
1837    let mut m = indexmap::IndexMap::new();
1838    m
1839}));
1840        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setPositionMode() is not supported yet".into()))));
1841
1842    Value::Null
1843} }
1844
1845    fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1846        // async-virtual: try the derived exchange first
1847        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 {
1848            if !matches!(__v, crate::Value::Null) { return __v; }
1849        }
1850
1851        let mut params = get_arg(optional_args, 0, Value::Map({
1852    let mut m = indexmap::IndexMap::new();
1853    m
1854}));
1855        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" addMargin() is not supported yet".into()))));
1856
1857    Value::Null
1858} }
1859
1860    fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1861        // async-virtual: try the derived exchange first
1862        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 {
1863            if !matches!(__v, crate::Value::Null) { return __v; }
1864        }
1865
1866        let mut params = get_arg(optional_args, 0, Value::Map({
1867    let mut m = indexmap::IndexMap::new();
1868    m
1869}));
1870        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" reduceMargin() is not supported yet".into()))));
1871
1872    Value::Null
1873} }
1874
1875    fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1876        let mut params = get_arg(optional_args, 0, Value::Map({
1877    let mut m = indexmap::IndexMap::new();
1878    m
1879}));
1880        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMargin() is not supported yet".into()))));
1881
1882    Value::Null
1883} }
1884
1885    fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1886        let mut timeframe = get_arg(optional_args, 0, Value::Null);
1887        let mut params = get_arg(optional_args, 1, Value::Map({
1888    let mut m = indexmap::IndexMap::new();
1889    m
1890}));
1891        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatio() is not supported yet".into()))));
1892
1893    Value::Null
1894} }
1895
1896    fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1897        let mut symbol = get_arg(optional_args, 0, Value::Null);
1898        let mut timeframe = get_arg(optional_args, 1, Value::Null);
1899        let mut since = get_arg(optional_args, 2, Value::Null);
1900        let mut limit = get_arg(optional_args, 3, Value::Null);
1901        let mut params = get_arg(optional_args, 4, Value::Map({
1902    let mut m = indexmap::IndexMap::new();
1903    m
1904}));
1905        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatioHistory() is not supported yet".into()))));
1906
1907    Value::Null
1908} }
1909
1910    fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1911        let mut symbol = get_arg(optional_args, 0, Value::Null);
1912        let mut type_var = get_arg(optional_args, 1, Value::Null);
1913        let mut since = get_arg(optional_args, 2, Value::Null);
1914        let mut limit = get_arg(optional_args, 3, Value::Null);
1915        let mut params = get_arg(optional_args, 4, Value::Map({
1916    let mut m = indexmap::IndexMap::new();
1917    m
1918}));
1919        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".into()))));
1920
1921    Value::Null
1922} }
1923
1924    fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1925        // async-virtual: try the derived exchange first
1926        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 {
1927            if !matches!(__v, crate::Value::Null) { return __v; }
1928        }
1929
1930        let mut symbol = get_arg(optional_args, 0, Value::Null);
1931        let mut params = get_arg(optional_args, 1, Value::Map({
1932    let mut m = indexmap::IndexMap::new();
1933    m
1934}));
1935        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMarginMode() is not supported yet".into()))));
1936
1937    Value::Null
1938} }
1939
1940    fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1941        // async-virtual: try the derived exchange first
1942        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 {
1943            if !matches!(__v, crate::Value::Null) { return __v; }
1944        }
1945
1946        let mut params = get_arg(optional_args, 0, Value::Map({
1947    let mut m = indexmap::IndexMap::new();
1948    m
1949}));
1950        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".into()))));
1951
1952    Value::Null
1953} }
1954
1955    fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1956        let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".into()));
1957        let mut since = get_arg(optional_args, 1, Value::Null);
1958        let mut limit = get_arg(optional_args, 2, Value::Null);
1959        let mut params = get_arg(optional_args, 3, Value::Map({
1960    let mut m = indexmap::IndexMap::new();
1961    m
1962}));
1963        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterestHistory() is not supported yet".into()))));
1964
1965    Value::Null
1966} }
1967
1968    fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1969        // async-virtual: try the derived exchange first
1970        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 {
1971            if !matches!(__v, crate::Value::Null) { return __v; }
1972        }
1973
1974        let mut symbols = get_arg(optional_args, 0, Value::Null);
1975        let mut params = get_arg(optional_args, 1, Value::Map({
1976    let mut m = indexmap::IndexMap::new();
1977    m
1978}));
1979        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterests() is not supported yet".into()))));
1980
1981    Value::Null
1982} }
1983
1984    fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1985        // async-virtual: try the derived exchange first
1986        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 {
1987            if !matches!(__v, crate::Value::Null) { return __v; }
1988        }
1989
1990        let mut params = get_arg(optional_args, 0, Value::Map({
1991    let mut m = indexmap::IndexMap::new();
1992    m
1993}));
1994        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" signIn() is not supported yet".into()))));
1995
1996    Value::Null
1997} }
1998
1999    fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
2000        let mut params = get_arg(optional_args, 0, Value::Map({
2001    let mut m = indexmap::IndexMap::new();
2002    m
2003}));
2004        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPaymentMethods() is not supported yet".into()))));
2005
2006    Value::Null
2007} }
2008
2009    fn parse_to_int(&self, mut number: Value) -> Value {
2010        // Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
2011        // using a number as parameter which is not valid in ts
2012        // numberToString is typed as nullable under strictNullChecks; cast to string
2013        // the cast is erased at transpile-time, so output matches every target language, rather than
2014        // branching to a bare `NaN` literal, which has no symbol in Go/Java/C#
2015        let mut stringifiedNumber: Value = self.number_to_string(number);
2016        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 });
2017        return crate::runtime::parse_int(&convertedNumber);
2018
2019    Value::Null
2020}
2021
2022    fn parse_to_numeric(&self, mut number: Value) -> Value {
2023        let mut stringVersion: Value = self.number_to_string(number); // this will convert 1.0 and 1 to "1" and 1.1 to "1.1"
2024        // keep this in mind:
2025        // in JS:     1 === 1.0 is true
2026        // in Python: 1 == 1.0 is true
2027        // in PHP:    1 == 1.0 is true, but 1 === 1.0 is false.
2028        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) {
2029            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 });
2030        }
2031        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 });
2032
2033    Value::Null
2034}
2035
2036    fn is_round_number(&self, mut value: Value) -> Value {
2037        // this method is similar to isInteger, but this is more loyal and does not check for types.
2038        // i.e. isRoundNumber(1.000) returns true, while isInteger(1.000) returns false
2039        let mut res: Value = self.parse_to_numeric((mod_val(&value, &Value::Int(1))));
2040        return Value::Bool(res.as_f64() == Some(0.0));
2041
2042    Value::Null
2043}
2044
2045    fn is_empty_string(&self, mut value: Value) -> Value {
2046        return Value::Bool(!(self.value_is_defined(value.clone()).as_bool() == Some(true)) || (value.as_str() == Some("")));
2047
2048    Value::Null
2049}
2050
2051    fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2052        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2053        let mut value: Value = self.safe_string(obj, key, &[]);
2054        let mut final_val: Value = self.parse_number(self.omit_zero(value), &[]);
2055        return (if (final_val == Value::Null) { defaultValue } else { final_val });
2056
2057    Value::Null
2058}
2059
2060    fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2061        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2062        let mut timestamp: Value = self.safe_integer(obj, key, &[defaultValue]);
2063        if (timestamp == Value::Null) || (timestamp.as_f64() == Some(0.0)) {
2064            return Value::Null;
2065        }
2066        return timestamp;
2067
2068    Value::Null
2069}
2070
2071    fn after_construct(&mut self) {
2072        // networks
2073        self.create_networks_by_id_object();
2074        self.features_generator();
2075        // init predefined markets if any
2076        if (self.markets.clone() != Value::Null) {
2077            self.set_markets(self.markets.clone(), &[]);
2078        }
2079        // init the request rate limiter
2080        self.init_rest_rate_limiter();
2081        // sanbox mode
2082        let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".into()), Value::Str("testnet".into()), &[Value::Bool(false)]);
2083        if (isSandbox.as_bool() == Some(true)) {
2084            self.set_sandbox_mode(isSandbox);
2085        }
2086}
2087
2088    fn init_rest_rate_limiter(&mut self) {
2089        if (self.rateLimit.clone() == Value::Null) || ((self.id.clone() != Value::Null) && (self.rateLimit.as_f64() == Value::Int(-1).as_f64())) {
2090            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(".rateLimit property is not configured".into()))));
2091        }
2092        let mut refillRate: Value = self.MAX_VALUE.clone();
2093        if self.rateLimit.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2094            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 });
2095        }
2096        let mut useLeaky: bool = (self.rollingWindowSize.as_f64() == Some(0.0)) || (self.rateLimiterAlgorithm.as_str() == Some("leakyBucket"));
2097        let mut algorithm: Value = (if useLeaky { Value::Str("leakyBucket".into()) } else { Value::Str("rollingWindow".into()) });
2098        let mut defaultBucket: Value = Value::Map({
2099            let mut m = indexmap::IndexMap::new();
2100                m.insert("delay".to_string(), Value::Float(0.001));
2101                m.insert("capacity".to_string(), Value::Int(1));
2102                m.insert("cost".to_string(), Value::Int(1));
2103                m.insert("refillRate".to_string(), refillRate);
2104                m.insert("algorithm".to_string(), algorithm);
2105                m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2106                m.insert("rateLimit".to_string(), self.rateLimit.clone());
2107            m
2108        });
2109        let mut existingBucket: Value = (if (self.tokenBucket.clone() == Value::Null) { Value::Map({
2110    let mut m = indexmap::IndexMap::new();
2111    m
2112}) } else { self.tokenBucket.clone() });
2113        { let __t = self.extend(defaultBucket, &[existingBucket]); self.tokenBucket = __t; }
2114        self.init_throttler();
2115}
2116
2117    fn features_generator(&mut self) {
2118        //
2119        // in the exchange-specific features can be something like this, where we support 'string' aliases too:
2120        //
2121        //     {
2122        //         'my' : {
2123        //             'createOrder' : {...},
2124        //         },
2125        //         'swap': {
2126        //             'linear': {
2127        //                 'extends': my',
2128        //             },
2129        //         },
2130        //     }
2131        //
2132        if (self.features.clone() == Value::Null) {
2133            return;
2134        }
2135        // reconstruct
2136        let mut initialFeatures: Value = self.features.clone();
2137        self.features = Value::Map({
2138            let mut m = indexmap::IndexMap::new();
2139            m
2140        });
2141        let mut unifiedMarketTypes: Value = Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into()), Value::Str("future".into()), Value::Str("option".into())]);
2142        let mut subTypes: Value = Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into())]);
2143        {
2144                        let mut i: Value = Value::Int(0);
2145            let mut __for_first_82: bool = true;
2146            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) < ((unifiedMarketTypes.len() as i64) as f64) } {
2147            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);
2148            // if marketType is not filled for this exchange, don't add that in `features`
2149            if !(in_op(&initialFeatures, &marketType)) {
2150                if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Null); }
2151            }  else {
2152                if (marketType.as_str() == Some("spot")) {
2153                    { 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); } }
2154                }  else {
2155                    if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Map({
2156    let mut m = indexmap::IndexMap::new();
2157    m
2158})); }
2159                    {
2160                                                let mut j: Value = Value::Int(0);
2161                        let mut __for_first_81: bool = true;
2162                        while { if !__for_first_81 { 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_81 = false; j.as_f64().unwrap_or(f64::NAN) < ((subTypes.len() as i64) as f64) } {
2163                        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);
2164                        { 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); };
2165                    }
2166                    }
2167                }
2168            }
2169        }
2170        }
2171}
2172
2173    fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2174        let mut subType = get_arg(optional_args, 0, Value::Null);
2175        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) });
2176        // if exchange does not have that market-type (eg. future>inverse)
2177        if (featuresObj == Value::Null) {
2178            return Value::Null;
2179        }
2180        let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
2181        if (extendsStr != Value::Null) {
2182            featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".into()), &[]);
2183            let mut extendObj: Value = self.features_mapper(initialFeatures, extendsStr, &[]);
2184            featuresObj = self.deep_extend(extendObj, &[featuresObj.clone()]);
2185        }
2186        //
2187        // ### corrections ###
2188        //
2189        // createOrder
2190        if (in_op(&featuresObj, &Value::Str("createOrder".into()))) {
2191            let mut value: Value = self.safe_dict_k(crate::value::get_value_k(&featuresObj, "createOrder"), "attachedStopLossTakeProfit", &[]);
2192            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("stopLoss".into()), value.clone());
2193            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("takeProfit".into()), value.clone());
2194            if (marketType.as_str() == Some("spot")) {
2195                // default 'hedged': false
2196                add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("hedged".into()), Value::Bool(false));
2197                // default 'leverage': false
2198                if !(in_op(&crate::value::get_value_k(&featuresObj, "createOrder"), &Value::Str("leverage".into()))) {
2199                    add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("leverage".into()), Value::Bool(false));
2200                }
2201            }
2202            // default 'GTC' to true
2203            if (self.safe_bool(crate::value::get_value_k(&crate::value::get_value_k(&featuresObj, "createOrder"), "timeInForce"), Value::Str("GTC".into()), &[]) == Value::Null) {
2204                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));
2205            }
2206        }
2207        // other methods
2208        let mut keys: Value = object_keys(&featuresObj);
2209        {
2210                        let mut i: Value = Value::Int(0);
2211            let mut __for_first_83: bool = true;
2212            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) < ((keys.len() as i64) as f64) } {
2213            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);
2214            let mut featureBlock: Value = get_value(&featuresObj, &key);
2215            let mut featureBlock: Value = get_value(&featuresObj, &key);
2216            if !(self.in_array(key.clone(), Value::from(vec![Value::Str("sandbox".into())])).as_bool() == Some(true)) && (featureBlock != Value::Null) {
2217                // default "symbolRequired" to false to all methods (except `createOrder`)
2218                if !(in_op(&featureBlock, &Value::Str("symbolRequired".into()))) {
2219                    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())])));
2220                }
2221            }
2222        }
2223        }
2224        return featuresObj;
2225
2226    Value::Null
2227}
2228
2229    fn feature_value(&self, mut symbol: 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#featureValue
2236         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2237         * @param {string} [symbol] unified symbol
2238         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2239         * @param {string} [paramName] unified param value, like: `triggerPrice`, `stopLoss.triggerPrice` (check docs for supported param names)
2240         * @param {object} [defaultValue] return default value if no result found
2241         * @returns {object} returns feature value
2242         */
2243        let mut market: Value = self.market(symbol.clone());
2244        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]);
2245
2246    Value::Null
2247}
2248
2249    fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2250        let mut methodName = get_arg(optional_args, 0, Value::Null);
2251        let mut paramName = get_arg(optional_args, 1, Value::Null);
2252        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2253        /*
2254         * @method
2255         * @name exchange#featureValueByType
2256         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2257         * @param {string} [marketType] supported only: "spot", "swap", "future"
2258         * @param {string} [subType] supported only: "linear", "inverse"
2259         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2260         * @param {string} [paramName] unified param value (check docs for supported param names)
2261         * @param {object} [defaultValue] return default value if no result found
2262         * @returns {object} returns feature value
2263         */
2264        // if exchange does not yet have features manually implemented
2265        if (self.features.clone() == Value::Null) {
2266            return defaultValue;
2267        }
2268        if (marketType == Value::Null) {
2269            return defaultValue;
2270        }
2271        // if marketType (e.g. 'option') does not exist in features
2272        if !(in_op(&self.features, &marketType)) {
2273            return defaultValue;
2274        }
2275        // if marketType dict undefined
2276        if (get_value(&self.features, &marketType) == Value::Null) {
2277            return defaultValue;
2278        }
2279        let mut methodsContainer: Value = get_value(&self.features, &marketType);
2280        if (subType == Value::Null) {
2281            if (marketType.as_str() != Some("spot")) {
2282                return defaultValue;
2283            }
2284        }  else {
2285            if !(in_op(&get_value(&self.features, &marketType), &subType)) {
2286                return defaultValue;
2287            }
2288            // if subType dict undefined
2289            if (get_value(&get_value(&self.features, &marketType), &subType) == Value::Null) {
2290                return defaultValue;
2291            }
2292            methodsContainer = get_value(&get_value(&self.features, &marketType), &subType);
2293        }
2294        // if user wanted only marketType and didn't provide methodName, eg: featureIsSupported('spot')
2295        if (methodName == Value::Null) {
2296            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodsContainer.clone() });
2297        }
2298        if !(in_op(&methodsContainer, &methodName)) {
2299            return defaultValue;
2300        }
2301        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2302        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2303        if (methodDict == Value::Null) {
2304            return defaultValue;
2305        }
2306        // if user wanted only method and didn't provide `paramName`, eg: featureIsSupported('swap', 'linear', 'createOrder')
2307        if (paramName == Value::Null) {
2308            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodDict.clone() });
2309        }
2310        let mut splited: Value = split(&paramName, &Value::Str(".".into())); // can be only parent key (`stopLoss`) or with child (`stopLoss.triggerPrice`)
2311        let mut parentKey: Value = splited.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
2312        let mut subKey: Value = self.safe_string(splited, Value::Int(1), &[]);
2313        if !(in_op(&methodDict, &parentKey)) {
2314            return defaultValue;
2315        }
2316        let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2317        if (dictionary == Value::Null) {
2318            return get_value(&methodDict, &parentKey);
2319        }  else {
2320            // return as is, when calling without subKey eg: featureValueByType('spot', undefined, 'createOrder', 'stopLoss')
2321            if (subKey == Value::Null) {
2322                return get_value(&methodDict, &parentKey);
2323            }
2324            // throw an exception for unsupported subKey
2325            if !(in_op(&get_value(&methodDict, &parentKey), &subKey)) {
2326                return defaultValue;
2327            }
2328            return get_value(&get_value(&methodDict, &parentKey), &subKey);
2329        }
2330
2331    Value::Null
2332}
2333
2334    fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2335        if (symbol == Value::Null) {
2336            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" orderbookChecksumMessage() requires a symbol argument".into()))));
2337        }
2338        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());
2339
2340    Value::Null
2341}
2342
2343    fn create_networks_by_id_object(&mut self) {
2344        // automatically generate network-id-to-code mappings
2345        let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2346            let mut m = indexmap::IndexMap::new();
2347            m
2348        })])); // invert defined networks dictionary
2349        { let __be_tmp = self.extend(networkIdsToCodesGenerated, &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2350    let mut m = indexmap::IndexMap::new();
2351    m
2352})])]); 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
2353}
2354
2355    fn get_default_options(&self) -> Value {
2356        return Value::Map({
2357    let mut m = indexmap::IndexMap::new();
2358        m.insert("defaultNetworkCodeReplacements".to_string(), Value::Map({
2359    let mut m = indexmap::IndexMap::new();
2360        m.insert("ETH".to_string(), Value::Map({
2361    let mut m = indexmap::IndexMap::new();
2362        m.insert("primary".to_string(), Value::Str("ETH".into()));
2363        m.insert("secondary".to_string(), Value::Str("ERC20".into()));
2364        m.insert("default".to_string(), Value::Str("secondary".into()));
2365    m
2366}));
2367        m.insert("CRO".to_string(), Value::Map({
2368    let mut m = indexmap::IndexMap::new();
2369        m.insert("primary".to_string(), Value::Str("CRONOS".into()));
2370        m.insert("secondary".to_string(), Value::Str("CRC20".into()));
2371        m.insert("default".to_string(), Value::Str("secondary".into()));
2372    m
2373}));
2374        m.insert("TRX".to_string(), Value::Map({
2375    let mut m = indexmap::IndexMap::new();
2376        m.insert("primary".to_string(), Value::Str("TRX".into()));
2377        m.insert("secondary".to_string(), Value::Str("TRC20".into()));
2378        m.insert("default".to_string(), Value::Str("secondary".into()));
2379    m
2380}));
2381        m.insert("BTC".to_string(), Value::Map({
2382    let mut m = indexmap::IndexMap::new();
2383        m.insert("primary".to_string(), Value::Str("BTC".into()));
2384        m.insert("secondary".to_string(), Value::Str("BRC20".into()));
2385        m.insert("default".to_string(), Value::Str("primary".into()));
2386    m
2387}));
2388    m
2389}));
2390        m.insert("backwardSupportedNetworkCodes".to_string(), Value::Map({
2391    let mut m = indexmap::IndexMap::new();
2392        m.insert("ARB".to_string(), Value::Str("ARBITRUM".into()));
2393        m.insert("ARBONE".to_string(), Value::Str("ARBITRUM".into()));
2394        m.insert("ARBNOVA".to_string(), Value::Str("ARBITRUM_NOVA".into()));
2395    m
2396}));
2397        m.insert("withdrawTagRequiredCurrencies".to_string(), Value::from(vec![Value::Str("XRP".into()), Value::Str("XLM".into()), Value::Str("EOS".into()), Value::Str("ATOM".into()), Value::Str("HBAR".into()), Value::Str("TON".into()), Value::Str("KAVA".into()), Value::Str("STX".into()), Value::Str("XEM".into()), Value::Str("IOST".into()), Value::Str("OSMO".into()), Value::Str("WAXP".into())]));
2398    m
2399});
2400
2401    Value::Null
2402}
2403
2404    fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2405        let mut currency = get_arg(optional_args, 0, Value::Null);
2406        let mut currencyResolved: Value = self.safe_currency(Value::Null, &[currency]);
2407        let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2408        let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2409        let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2410        let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
2411        if (amount != Value::Null) {
2412            if (before == Value::Null) && (after != Value::Null) {
2413                before = crate::precise::Precise::stringSub(&after, &amount);
2414            }  else if (before != Value::Null) && (after == Value::Null) {
2415                after = crate::precise::Precise::stringAdd(&before, &amount);
2416            }
2417        }
2418        if (before != Value::Null) && (after != Value::Null) {
2419            if (direction == Value::Null) {
2420                if is_true(&crate::precise::Precise::stringGt(&before, &after)) {
2421                    direction = Value::Str("out".into());
2422                }
2423                if is_true(&crate::precise::Precise::stringGt(&after, &before)) {
2424                    direction = Value::Str("in".into());
2425                }
2426            }
2427        }
2428        let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2429        if (fee != Value::Null) {
2430            { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); };
2431        }
2432        let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
2433        let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2434    let mut m = indexmap::IndexMap::new();
2435    m
2436})]);
2437        return Value::Map({
2438    let mut m = indexmap::IndexMap::new();
2439        m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2440        m.insert("timestamp".to_string(), timestamp.clone());
2441        m.insert("datetime".to_string(), self.iso8601(timestamp));
2442        m.insert("direction".to_string(), direction);
2443        m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2444        m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2445        m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2446        m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2447        m.insert("currency".to_string(), currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null));
2448        m.insert("amount".to_string(), self.parse_number(amount, &[]));
2449        m.insert("before".to_string(), self.parse_number(before, &[]));
2450        m.insert("after".to_string(), self.parse_number(after, &[]));
2451        m.insert("status".to_string(), self.safe_string_k(entry, "status", &[]));
2452        m.insert("fee".to_string(), fee);
2453        m.insert("info".to_string(), info);
2454    m
2455});
2456
2457    Value::Null
2458}
2459
2460    fn safe_currency_structure(&self, mut currency: Value) -> Value {
2461        // derive data from networks: deposit, withdraw, active, fee, limits, precision
2462        let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2463    let mut m = indexmap::IndexMap::new();
2464    m
2465})]);
2466        let mut keys: Value = object_keys(&networks);
2467        let mut length: f64 = ((keys.len() as i64) as f64);
2468        if (length != 0.0) {
2469            {
2470                                let mut i: Value = Value::Int(0);
2471                let mut __for_first_84: bool = true;
2472                while { if !__for_first_84 { 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_84 = false; i.as_f64().unwrap_or(f64::NAN) < length } {
2473                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);
2474                let mut network: Value = networks.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2475                let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
2476                let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
2477                if (currencyDeposit == Value::Null) || (deposit.as_bool() == Some(true)) {
2478                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("deposit".into(), deposit); }
2479                }
2480                let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
2481                let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
2482                if (currencyWithdraw == Value::Null) || (withdraw.as_bool() == Some(true)) {
2483                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("withdraw".into(), withdraw); }
2484                }
2485                // find lowest fee (which is more desired)
2486                let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
2487                let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
2488                if (feeMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&fee, &feeMain)) {
2489                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("fee".into(), self.parse_number(fee.clone(), &[])); }
2490                }
2491                // find lowest precision (which is more desired)
2492                let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
2493                let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
2494                if (precisionMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&precision, &precisionMain)) {
2495                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("precision".into(), self.parse_number(precision.clone(), &[])); }
2496                }
2497                // limits
2498                let mut limits: Value = self.safe_dict_k(network, "limits", &[]);
2499                let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
2500                if (limitsMain == Value::Null) {
2501                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("limits".into(), Value::Map({
2502    let mut m = indexmap::IndexMap::new();
2503    m
2504})); }
2505                }
2506                // deposits
2507                let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2508                let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
2509                if (limitsDepositMain == Value::Null) {
2510                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into()), Value::Map({
2511    let mut m = indexmap::IndexMap::new();
2512    m
2513}));
2514                }
2515                let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
2516                let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit, "max", &[]);
2517                let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
2518                let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain, "max", &[]);
2519                // find min
2520                if (limitsDepositMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain)) {
2521                    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, &[]));
2522                }
2523                // find max
2524                if (limitsDepositMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain)) {
2525                    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, &[]));
2526                }
2527                // withdrawals
2528                let mut limitsWithdraw: Value = self.safe_dict_k(limits, "withdraw", &[]);
2529                let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain, "withdraw", &[]);
2530                if (limitsWithdrawMain == Value::Null) {
2531                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into()), Value::Map({
2532    let mut m = indexmap::IndexMap::new();
2533    m
2534}));
2535                }
2536                let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
2537                let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw, "max", &[]);
2538                let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
2539                let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain, "max", &[]);
2540                // find min
2541                if (limitsWithdrawMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain)) {
2542                    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, &[]));
2543                }
2544                // find max
2545                if (limitsWithdrawMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain)) {
2546                    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, &[]));
2547                }
2548            }
2549            }
2550        }
2551        return self.extend(Value::Map({
2552    let mut m = indexmap::IndexMap::new();
2553        m.insert("info".to_string(), Value::Null);
2554        m.insert("id".to_string(), Value::Null);
2555        m.insert("numericId".to_string(), Value::Null);
2556        m.insert("code".to_string(), Value::Null);
2557        m.insert("precision".to_string(), Value::Null);
2558        m.insert("type".to_string(), Value::Null);
2559        m.insert("name".to_string(), Value::Null);
2560        m.insert("active".to_string(), Value::Null);
2561        m.insert("deposit".to_string(), Value::Null);
2562        m.insert("withdraw".to_string(), Value::Null);
2563        m.insert("fee".to_string(), Value::Null);
2564        m.insert("fees".to_string(), Value::Map({
2565    let mut m = indexmap::IndexMap::new();
2566    m
2567}));
2568        m.insert("networks".to_string(), Value::Map({
2569    let mut m = indexmap::IndexMap::new();
2570    m
2571}));
2572        m.insert("limits".to_string(), Value::Map({
2573    let mut m = indexmap::IndexMap::new();
2574        m.insert("deposit".to_string(), Value::Map({
2575    let mut m = indexmap::IndexMap::new();
2576        m.insert("min".to_string(), Value::Null);
2577        m.insert("max".to_string(), Value::Null);
2578    m
2579}));
2580        m.insert("withdraw".to_string(), Value::Map({
2581    let mut m = indexmap::IndexMap::new();
2582        m.insert("min".to_string(), Value::Null);
2583        m.insert("max".to_string(), Value::Null);
2584    m
2585}));
2586    m
2587}));
2588    m
2589}), &[currency]);
2590
2591    Value::Null
2592}
2593
2594    fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2595        let mut market = get_arg(optional_args, 0, Value::Null);
2596        let mut cleanStructure: Value = Value::Map({
2597            let mut m = indexmap::IndexMap::new();
2598                m.insert("id".to_string(), Value::Null);
2599                m.insert("lowercaseId".to_string(), Value::Null);
2600                m.insert("symbol".to_string(), Value::Null);
2601                m.insert("base".to_string(), Value::Null);
2602                m.insert("quote".to_string(), Value::Null);
2603                m.insert("settle".to_string(), Value::Null);
2604                m.insert("baseId".to_string(), Value::Null);
2605                m.insert("quoteId".to_string(), Value::Null);
2606                m.insert("settleId".to_string(), Value::Null);
2607                m.insert("type".to_string(), Value::Null);
2608                m.insert("spot".to_string(), Value::Null);
2609                m.insert("margin".to_string(), Value::Null);
2610                m.insert("swap".to_string(), Value::Null);
2611                m.insert("future".to_string(), Value::Null);
2612                m.insert("option".to_string(), Value::Null);
2613                m.insert("index".to_string(), Value::Null);
2614                m.insert("active".to_string(), Value::Null);
2615                m.insert("contract".to_string(), Value::Null);
2616                m.insert("linear".to_string(), Value::Null);
2617                m.insert("inverse".to_string(), Value::Null);
2618                m.insert("subType".to_string(), Value::Null);
2619                m.insert("taker".to_string(), Value::Null);
2620                m.insert("maker".to_string(), Value::Null);
2621                m.insert("contractSize".to_string(), Value::Null);
2622                m.insert("expiry".to_string(), Value::Null);
2623                m.insert("expiryDatetime".to_string(), Value::Null);
2624                m.insert("strike".to_string(), Value::Null);
2625                m.insert("optionType".to_string(), Value::Null);
2626                m.insert("precision".to_string(), Value::Map({
2627    let mut m = indexmap::IndexMap::new();
2628        m.insert("amount".to_string(), Value::Null);
2629        m.insert("price".to_string(), Value::Null);
2630        m.insert("cost".to_string(), Value::Null);
2631        m.insert("base".to_string(), Value::Null);
2632        m.insert("quote".to_string(), Value::Null);
2633    m
2634}));
2635                m.insert("limits".to_string(), Value::Map({
2636    let mut m = indexmap::IndexMap::new();
2637        m.insert("leverage".to_string(), Value::Map({
2638    let mut m = indexmap::IndexMap::new();
2639        m.insert("min".to_string(), Value::Null);
2640        m.insert("max".to_string(), Value::Null);
2641    m
2642}));
2643        m.insert("amount".to_string(), Value::Map({
2644    let mut m = indexmap::IndexMap::new();
2645        m.insert("min".to_string(), Value::Null);
2646        m.insert("max".to_string(), Value::Null);
2647    m
2648}));
2649        m.insert("price".to_string(), Value::Map({
2650    let mut m = indexmap::IndexMap::new();
2651        m.insert("min".to_string(), Value::Null);
2652        m.insert("max".to_string(), Value::Null);
2653    m
2654}));
2655        m.insert("cost".to_string(), Value::Map({
2656    let mut m = indexmap::IndexMap::new();
2657        m.insert("min".to_string(), Value::Null);
2658        m.insert("max".to_string(), Value::Null);
2659    m
2660}));
2661    m
2662}));
2663                m.insert("marginModes".to_string(), Value::Map({
2664    let mut m = indexmap::IndexMap::new();
2665        m.insert("cross".to_string(), Value::Null);
2666        m.insert("isolated".to_string(), Value::Null);
2667    m
2668}));
2669                m.insert("created".to_string(), Value::Null);
2670                m.insert("info".to_string(), Value::Null);
2671            m
2672        });
2673        if (market != Value::Null) {
2674            let mut result: Value = self.extend(cleanStructure.clone(), &[market]);
2675            // set undefined swap/future/etc
2676            if is_equal(&result.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2677                if (result.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null) == Value::Null) {
2678                    add_element_to_object(&mut result, &Value::Str("contract".into()), Value::Bool(false));
2679                }
2680                if (result.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null) == Value::Null) {
2681                    add_element_to_object(&mut result, &Value::Str("swap".into()), Value::Bool(false));
2682                }
2683                if (result.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null) == Value::Null) {
2684                    add_element_to_object(&mut result, &Value::Str("future".into()), Value::Bool(false));
2685                }
2686                if (result.as_map().and_then(|__m| __m.get("option")).cloned().unwrap_or(Value::Null) == Value::Null) {
2687                    add_element_to_object(&mut result, &Value::Str("option".into()), Value::Bool(false));
2688                }
2689                if (result.as_map().and_then(|__m| __m.get("index")).cloned().unwrap_or(Value::Null) == Value::Null) {
2690                    add_element_to_object(&mut result, &Value::Str("index".into()), Value::Bool(false));
2691                }
2692            }
2693            return result;
2694        }
2695        return self.extend(cleanStructure, &[]);
2696
2697    Value::Null
2698}
2699
2700    fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2701        let mut currencies = get_arg(optional_args, 0, Value::Null);
2702        let mut values: Value = Value::from(vec![]);
2703        { let __t = self.create_safe_dictionary(&[]); self.markets_by_id = __t; }
2704        // handle marketId conflicts
2705        // we insert spot markets first
2706        let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".into()), &[Value::Bool(true), Value::Bool(true)]);
2707        {
2708                        let mut i: Value = Value::Int(0);
2709            let mut __for_first_86: bool = true;
2710            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) < ((marketValues.len() as i64) as f64) } {
2711            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);
2712            if (in_op(&self.markets_by_id, &crate::value::get_value_k(&value, "id"))) {
2713                let mut marketsByIdArray: Value = get_value(&self.markets_by_id, &crate::value::get_value_k(&value, "id"));
2714                append_to_array(&mut marketsByIdArray, value.clone());
2715                add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), marketsByIdArray);
2716            }  else {
2717                add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), Value::from(vec![value.clone()]));
2718            }
2719            // strip undefined-valued keys from the parsed market before deepExtend,
2720            // otherwise an explicit `taker: undefined` (from safeMarketStructure)
2721            // would clobber the fee defaults from this.fees['trading'] in the merge
2722            let mut valueDefined: Value = Value::Map({
2723                let mut m = indexmap::IndexMap::new();
2724                m
2725            });
2726            let mut valueKeys: Value = object_keys(&value);
2727            {
2728                                let mut j: Value = Value::Int(0);
2729                let mut __for_first_85: bool = true;
2730                while { if !__for_first_85 { 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_85 = false; j.as_f64().unwrap_or(f64::NAN) < ((valueKeys.len() as i64) as f64) } {
2731                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);
2732                if (get_value(&value, &valueKey) != Value::Null) {
2733                    if let Value::Dict(__d) = &mut valueDefined { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&valueKey), get_value(&value, &valueKey)); }
2734                }
2735            }
2736            }
2737            let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2738                let mut m = indexmap::IndexMap::new();
2739                    m.insert("precision".to_string(), self.precision.clone());
2740                    m.insert("limits".to_string(), self.limits.clone());
2741                m
2742            }), self.fees.as_map().and_then(|__m| __m.get("trading")).cloned().unwrap_or(Value::Null), valueDefined]);
2743            if is_equal(&market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2744                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("linear".into()));
2745            }  else if is_equal(&market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2746                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("inverse".into()));
2747            }  else {
2748                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Null);
2749            }
2750            append_to_array(&mut values, market.clone());
2751        }
2752        }
2753        { let __t = self.map_to_safe_map(self.index_by(values.clone(), Value::Str("symbol".into()))); self.markets = __t; }
2754        let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
2755        let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
2756        self.symbols = object_keys(&marketsSortedBySymbol);
2757        self.ids = object_keys(&marketsSortedById);
2758        let mut numCurrencies: Value = Value::Int(0);
2759        if (currencies != Value::Null) {
2760            let mut keys: Value = object_keys(&currencies);
2761            numCurrencies = Value::Int(keys.len() as i64);
2762        }
2763        if numCurrencies.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2764            // currencies is always undefined when called in constructor but not when called from loadMarkets
2765            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2766        }  else {
2767            let mut baseCurrencies: Value = Value::from(vec![]);
2768            let mut quoteCurrencies: Value = Value::from(vec![]);
2769            {
2770                                let mut i: Value = Value::Int(0);
2771                let mut __for_first_87: bool = true;
2772                while { if !__for_first_87 { 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_87 = false; i.as_f64().unwrap_or(f64::NAN) < ((values.len() as i64) as f64) } {
2773                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);
2774                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()), &[]) });
2775                let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2776    let mut m = indexmap::IndexMap::new();
2777    m
2778})]);
2779                if (matches!(&market, Value::Dict(__d) if __d.contains_key("base"))) {
2780                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2781                        let mut m = indexmap::IndexMap::new();
2782                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".into()), Value::Str("base".into()), &[]));
2783                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2784                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2785                            m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".into()), Value::Str("amount".into()), &[defaultCurrencyPrecision.clone()]));
2786                        m
2787                    }));
2788                    append_to_array(&mut baseCurrencies, currency.clone());
2789                }
2790                if (matches!(&market, Value::Dict(__d) if __d.contains_key("quote"))) {
2791                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2792                        let mut m = indexmap::IndexMap::new();
2793                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".into()), Value::Str("quote".into()), &[]));
2794                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2795                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2796                            m.insert("precision".to_string(), self.safe_value2(marketPrecision, Value::Str("quote".into()), Value::Str("price".into()), &[defaultCurrencyPrecision]));
2797                        m
2798                    }));
2799                    append_to_array(&mut quoteCurrencies, currency);
2800                }
2801            }
2802            }
2803            baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2804            quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2805            { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".into()))); self.baseCurrencies = __t; }
2806            { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".into()))); self.quoteCurrencies = __t; }
2807            let mut allCurrencies: Value = self.array_concat(baseCurrencies, quoteCurrencies);
2808            let mut groupedCurrencies: Value = self.group_by(allCurrencies, Value::Str("code".into()), &[]);
2809            let mut codes: Value = object_keys(&groupedCurrencies);
2810            let mut resultingCurrencies: Value = Value::from(vec![]);
2811            {
2812                                let mut i: Value = Value::Int(0);
2813                let mut __for_first_89: bool = true;
2814                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) < ((codes.len() as i64) as f64) } {
2815                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);
2816                let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code, &[Value::from(vec![])]);
2817                let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2818                {
2819                                        let mut j: Value = Value::Int(1);
2820                    let mut __for_first_88: bool = true;
2821                    while { if !__for_first_88 { 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_88 = false; j.as_f64().unwrap_or(f64::NAN) < ((groupedCurrenciesCode.len() as i64) as f64) } {
2822                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2823                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2824                    let mut currentPrecision: Value = self.safe_number_k(currentCurrency.clone(), "precision", &[]);
2825                    let mut highestPrecision: Value = self.safe_number_k(highestPrecisionCurrency.clone(), "precision", &[]);
2826                    if (currentPrecision == Value::Null) || (highestPrecision == Value::Null) {
2827                        continue;
2828                    }
2829                    if (self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64()) {
2830                        if currentPrecision.as_f64().unwrap_or(f64::NAN) < highestPrecision.as_f64().unwrap_or(f64::NAN) {
2831                            highestPrecisionCurrency = currentCurrency.clone();
2832                        }
2833                    }  else if currentPrecision.as_f64().unwrap_or(f64::NAN) > highestPrecision.as_f64().unwrap_or(f64::NAN) {
2834                        highestPrecisionCurrency = currentCurrency;
2835                    }
2836                }
2837                }
2838                append_to_array(&mut resultingCurrencies, highestPrecisionCurrency);
2839            }
2840            }
2841            let mut sortedCurrencies: Value = self.sort_by(resultingCurrencies, Value::Str("code".into()), &[]);
2842            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(sortedCurrencies, Value::Str("code".into()))])); self.currencies = __t; }
2843        }
2844        { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".into())); self.currencies_by_id = __t; }
2845        let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
2846        self.codes = object_keys(&currenciesSortedByCode);
2847        if (self.markets.clone() == Value::Null) {
2848            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" setMarkets() markets not set".into()))));
2849        }
2850        return self.markets.clone();
2851
2852    Value::Null
2853}
2854
2855    fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2856        // Validate that both exchanges are of the same type
2857        if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".into()))) {
2858            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()))));
2859        }
2860        // Validate that source exchange has loaded markets
2861        if (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) || (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) {
2862            panic!("{}", crate::exchange_errors::exchange_error("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function"));
2863        }
2864        // Set all market-related data
2865        self.markets = get_value(&sourceExchange, &Value::Str("markets".into()));
2866        self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".into()));
2867        self.symbols = get_value(&sourceExchange, &Value::Str("symbols".into()));
2868        self.ids = get_value(&sourceExchange, &Value::Str("ids".into()));
2869        self.currencies = get_value(&sourceExchange, &Value::Str("currencies".into()));
2870        self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".into()));
2871        self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".into()));
2872        self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".into()));
2873        self.codes = get_value(&sourceExchange, &Value::Str("codes".into()));
2874        // check marketHelperProps
2875        let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".into())), Value::Str("marketHelperProps".into()), &[Value::from(vec![])]);
2876        {
2877                        let mut i: Value = Value::Int(0);
2878            let mut __for_first_90: bool = true;
2879            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) < ((sourceExchangeHelpers.len() as i64) as f64) } {
2880            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2881            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2882            if (get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper) != Value::Null) {
2883                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)); }
2884            }
2885        }
2886        }
2887        return Value::Null;
2888
2889    Value::Null
2890}
2891
2892    fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2893        let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2894        let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe, &[wsBaseDescribe]);
2895        return superWithRestDescribe;
2896
2897    Value::Null
2898}
2899
2900    fn safe_balance(&self, mut balance: Value) -> Value {
2901        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())]), &[]);
2902        let mut codes: Value = object_keys(&balances);
2903        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("free".into(), Value::Map({
2904    let mut m = indexmap::IndexMap::new();
2905    m
2906})); }
2907        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("used".into(), Value::Map({
2908    let mut m = indexmap::IndexMap::new();
2909    m
2910})); }
2911        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("total".into(), Value::Map({
2912    let mut m = indexmap::IndexMap::new();
2913    m
2914})); }
2915        let mut debtBalance: Value = Value::Map({
2916            let mut m = indexmap::IndexMap::new();
2917            m
2918        });
2919        {
2920                        let mut i: Value = Value::Int(0);
2921            let mut __for_first_91: bool = true;
2922            while { if !__for_first_91 { 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_91 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2923            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);
2924            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()), &[]);
2925            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()), &[]);
2926            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()), &[]);
2927            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()), &[]);
2928            if (total == Value::Null) && (free != Value::Null) && (used != Value::Null) {
2929                total = crate::precise::Precise::stringAdd(&free, &used);
2930            }
2931            if (free == Value::Null) && (total != Value::Null) && (used != Value::Null) {
2932                free = crate::precise::Precise::stringSub(&total, &used);
2933            }
2934            if (used == Value::Null) && (total != Value::Null) && (free != Value::Null) {
2935                used = crate::precise::Precise::stringSub(&total, &free);
2936            }
2937            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".into()), self.parse_number(free, &[]));
2938            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".into()), self.parse_number(used, &[]));
2939            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".into()), self.parse_number(total, &[]));
2940            { 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); };
2941            { 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); };
2942            { 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); };
2943            if (debt != Value::Null) {
2944                add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".into()), self.parse_number(debt, &[]));
2945                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")); }
2946            }
2947        }
2948        }
2949        let mut debtBalanceArray: Value = object_keys(&debtBalance);
2950        let mut length: Value = Value::Int(debtBalanceArray.len() as i64);
2951        if (length != Value::Null) && (length.as_f64() != Some(0.0)) {
2952            if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("debt".into(), debtBalance); }
2953        }
2954        return balance;
2955
2956    Value::Null
2957}
2958
2959    fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2960        let mut market = get_arg(optional_args, 0, Value::Null);
2961        // parses numbers as strings
2962        // * it is important pass the trades as unparsed rawTrades
2963        let mut orderDict: Value = order.clone();
2964        if (order == Value::Null) {
2965            orderDict = Value::Map({
2966                let mut m = indexmap::IndexMap::new();
2967                m
2968            });
2969        }
2970        let mut amount: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "amount", &[]));
2971        let mut remaining: Value = self.safe_string_k(orderDict.clone(), "remaining", &[]);
2972        let mut filled: Value = self.safe_string_k(orderDict.clone(), "filled", &[]);
2973        let mut cost: Value = self.safe_string_k(orderDict.clone(), "cost", &[]);
2974        let mut average: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "average", &[]));
2975        let mut price: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "price", &[]));
2976        let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastTradeTimestamp", &[]);
2977        let mut symbol: Value = self.safe_string_k(orderDict.clone(), "symbol", &[]);
2978        let mut side: Value = self.safe_string_k(orderDict.clone(), "side", &[]);
2979        let mut status: Value = self.safe_string_k(orderDict.clone(), "status", &[]);
2980        let mut parseFilled: bool = filled == Value::Null;
2981        let mut parseCost: bool = cost == Value::Null;
2982        let mut parseLastTradeTimeTimestamp: bool = lastTradeTimeTimestamp == Value::Null;
2983        let mut fee: Value = self.safe_value_k(orderDict.clone(), "fee", &[]);
2984        let mut parseFee: bool = fee == Value::Null;
2985        let mut parseFees: bool = self.safe_value_k(orderDict.clone(), "fees", &[]) == Value::Null;
2986        let mut parseSymbol: bool = symbol == Value::Null;
2987        let mut parseSide: bool = side == Value::Null;
2988        let mut shouldParseFees: bool = parseFee || parseFees;
2989        let mut fees: Value = self.safe_list_k(orderDict.clone(), "fees", &[Value::from(vec![])]);
2990        let mut trades: Value = Value::from(vec![]);
2991        let mut isTriggerOrSLTpOrder: bool = ((self.safe_string_k(orderDict.clone(), "triggerPrice", &[]) != Value::Null) || (self.safe_string_k(orderDict.clone(), "stopLossPrice", &[]) != Value::Null)) || (self.safe_string_k(orderDict.clone(), "takeProfitPrice", &[]) != Value::Null);
2992        if parseFilled || parseCost || shouldParseFees {
2993            let mut rawTrades: Value = self.safe_value_k(orderDict.clone(), "trades", &[trades.clone()]);
2994            // const oldNumber = this.number;
2995            // we parse trades as strings here!
2996            // i don't think this is needed anymore
2997            // (this as any).number = String;
2998            let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
2999            // parse trades if they haven't already been parsed
3000            let mut tradesAreParsed: bool = (firstTrade != Value::Null) && (in_op(&firstTrade, &Value::Str("info".into()))) && (in_op(&firstTrade, &Value::Str("id".into())));
3001            if !tradesAreParsed {
3002                trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
3003            }  else {
3004                trades = rawTrades;
3005            }
3006            // this.number = oldNumber; why parse trades as strings if you read the value using `safeString` ?
3007            let mut tradesLength: Value = Value::Int(0);
3008            let mut isArray: bool = matches!(&trades, Value::Arr(_));
3009            if isArray {
3010                tradesLength = Value::Int(trades.len() as i64);
3011            }
3012            if isArray && (tradesLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) {
3013                // move properties that are defined in trades up into the order
3014                if (orderDict.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) == Value::Null) {
3015                    add_element_to_object(&mut orderDict, &Value::Str("symbol".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "symbol"));
3016                }
3017                if (orderDict.as_map().and_then(|__m| __m.get("side")).cloned().unwrap_or(Value::Null) == Value::Null) {
3018                    add_element_to_object(&mut orderDict, &Value::Str("side".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "side"));
3019                }
3020                if (orderDict.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null) == Value::Null) {
3021                    add_element_to_object(&mut orderDict, &Value::Str("type".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "type"));
3022                }
3023                if (orderDict.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null) == Value::Null) {
3024                    add_element_to_object(&mut orderDict, &Value::Str("id".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "order"));
3025                }
3026                if parseFilled {
3027                    filled = Value::Str("0".into());
3028                }
3029                if parseCost {
3030                    cost = Value::Str("0".into());
3031                }
3032                {
3033                                        let mut i: Value = Value::Int(0);
3034                    let mut __for_first_93: bool = true;
3035                    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) < ((trades.len() as i64) as f64) } {
3036                    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);
3037                    let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3038                    if parseFilled && (tradeAmount != Value::Null) {
3039                        filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
3040                    }
3041                    let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3042                    if parseCost && (tradeCost != Value::Null) {
3043                        cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
3044                    }
3045                    if parseSymbol {
3046                        symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
3047                    }
3048                    if parseSide {
3049                        side = self.safe_string_k(trade.clone(), "side", &[]);
3050                    }
3051                    let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
3052                    if parseLastTradeTimeTimestamp && (tradeTimestamp != Value::Null) {
3053                        if (lastTradeTimeTimestamp == Value::Null) {
3054                            lastTradeTimeTimestamp = tradeTimestamp.clone();
3055                        }  else {
3056                            lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
3057                        }
3058                    }
3059                    if shouldParseFees {
3060                        let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
3061                        if (tradeFees != Value::Null) {
3062                            {
3063                                                                let mut j: Value = Value::Int(0);
3064                                let mut __for_first_92: bool = true;
3065                                while { if !__for_first_92 { 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_92 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&tradeFees).as_f64().unwrap_or(f64::NAN) } {
3066                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3067                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3068                                append_to_array(&mut fees, self.extend(Value::Map({
3069                                    let mut m = indexmap::IndexMap::new();
3070                                    m
3071                                }), &[tradeFee.clone()]));
3072                            }
3073                            }
3074                        }  else {
3075                            let mut tradeFee: Value = self.safe_value_k(trade, "fee", &[]);
3076                            if (tradeFee != Value::Null) {
3077                                append_to_array(&mut fees, self.extend(Value::Map({
3078                                    let mut m = indexmap::IndexMap::new();
3079                                    m
3080                                }), &[tradeFee.clone()]));
3081                            }
3082                        }
3083                    }
3084                }
3085                }
3086            }
3087        }
3088        if shouldParseFees {
3089            let mut reducedFees: Value = fees.clone();
3090            if is_true(&self.reduceFees) {
3091                reducedFees = self.reduce_fees_by_currency(fees);
3092            }
3093            if (reducedFees == Value::Null) {
3094                reducedFees = Value::from(vec![]);
3095            }
3096            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3097            {
3098                                let mut i: Value = Value::Int(0);
3099                let mut __for_first_94: bool = true;
3100                while { if !__for_first_94 { 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_94 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3101                { 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); };
3102                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()))) {
3103                    { 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); };
3104                }
3105            }
3106            }
3107            if !parseFee && (reducedLength == 0.0) {
3108                // copy fee to avoid modification by reference
3109                let mut feeCopy: Value = self.deep_extend(fee, &[]);
3110                { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".into()), __be_tmp); };
3111                if (in_op(&feeCopy, &Value::Str("rate".into()))) {
3112                    { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".into()), __be_tmp); };
3113                }
3114                append_to_array(&mut reducedFees, feeCopy);
3115            }
3116            add_element_to_object(&mut orderDict, &Value::Str("fees".into()), reducedFees.clone());
3117            if parseFee && (reducedLength == 1.0) {
3118                add_element_to_object(&mut orderDict, &Value::Str("fee".into()), reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
3119            }
3120        }
3121        if (amount == Value::Null) {
3122            // ensure amount = filled + remaining
3123            if (filled != Value::Null) && (remaining != Value::Null) {
3124                amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3125            }  else if (status.as_str() == Some("closed")) {
3126                amount = filled.clone();
3127            }
3128        }
3129        if (filled == Value::Null) {
3130            if (amount != Value::Null) && (remaining != Value::Null) {
3131                filled = crate::precise::Precise::stringSub(&amount, &remaining);
3132            }  else if (status.as_str() == Some("closed")) && (amount != Value::Null) {
3133                filled = amount.clone();
3134            }
3135        }
3136        if (remaining == Value::Null) {
3137            if (amount != Value::Null) && (filled != Value::Null) {
3138                remaining = crate::precise::Precise::stringSub(&amount, &filled);
3139            }  else if (status.as_str() == Some("closed")) {
3140                remaining = Value::Str("0".into());
3141            }
3142        }
3143        // ensure that the average field is calculated correctly
3144        let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3145        let mut contractSize: Value = self.number_to_string(self.safe_value_k(market, "contractSize", &[Value::Int(1)]));
3146        // inverse
3147        // price = filled * contract size / cost
3148        //
3149        // linear
3150        // price = cost / (filled * contract size)
3151        if (average == Value::Null) {
3152            if (filled != Value::Null) && (cost != Value::Null) && is_true(&crate::precise::Precise::stringGt(&filled, &Value::Str("0".into()))) {
3153                let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3154                if (inverse.as_bool() == Some(true)) {
3155                    average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3156                }  else {
3157                    average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3158                }
3159            }
3160        }
3161        // similarly
3162        // inverse
3163        // cost = filled * contract size / price
3164        //
3165        // linear
3166        // cost = filled * contract size * price
3167        let mut costPriceExists: bool = (average != Value::Null) || (price != Value::Null);
3168        if parseCost && (filled != Value::Null) && costPriceExists {
3169            let mut multiplyPrice: Value = Value::Null;
3170            if (average == Value::Null) {
3171                multiplyPrice = price.clone();
3172            }  else {
3173                multiplyPrice = average.clone();
3174            }
3175            // contract trading
3176            let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3177            if (inverse.as_bool() == Some(true)) {
3178                cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3179            }  else {
3180                cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3181            }
3182        }
3183        // support for market orders
3184        let mut orderType: Value = self.safe_value_k(orderDict.clone(), "type", &[]);
3185        let mut emptyPrice: bool = (price == Value::Null) || is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".into())));
3186        if emptyPrice && (orderType.as_str() == Some("market")) {
3187            price = average.clone();
3188        }
3189        {
3190                        let mut i: Value = Value::Int(0);
3191            let mut __for_first_96: bool = true;
3192            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) < ((trades.len() as i64) as f64) } {
3193            let mut entry: Value = get_value(&trades, &i);
3194            let mut entry: Value = get_value(&trades, &i);
3195            { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".into()), __be_tmp); };
3196            { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".into()), __be_tmp); };
3197            { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".into()), __be_tmp); };
3198            let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3199    let mut m = indexmap::IndexMap::new();
3200    m
3201})]);
3202            { 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); } }
3203            if (matches!(&tradeFee, Value::Dict(__d) if __d.contains_key("rate"))) {
3204                { 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); } }
3205            }
3206            let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::from(vec![])]);
3207            {
3208                                let mut j: Value = Value::Int(0);
3209                let mut __for_first_95: bool = true;
3210                while { if !__for_first_95 { 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_95 = false; j.as_f64().unwrap_or(f64::NAN) < ((entryFees.len() as i64) as f64) } {
3211                { 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); };
3212            }
3213            }
3214            add_element_to_object(&mut entry, &Value::Str("fees".into()), entryFees);
3215            add_element_to_object(&mut entry, &Value::Str("fee".into()), tradeFee);
3216        }
3217        }
3218        let mut timeInForce: Value = self.safe_string_k(orderDict.clone(), "timeInForce", &[]);
3219        let mut postOnly: Value = self.safe_value_k(orderDict.clone(), "postOnly", &[]);
3220        // timeInForceHandling
3221        if (timeInForce == Value::Null) {
3222            if !isTriggerOrSLTpOrder && (self.safe_string_k(orderDict.clone(), "type", &[]).as_str() == Some("market")) {
3223                timeInForce = Value::Str("IOC".into());
3224            }
3225            // allow postOnly override
3226            if is_equal(&postOnly, &Value::Bool(true)) {
3227                timeInForce = Value::Str("PO".into());
3228            }
3229        }  else if (postOnly == Value::Null) {
3230            // timeInForce is not undefined here
3231            postOnly = Value::Bool(timeInForce.as_str() == Some("PO"));
3232        }
3233        let mut timestamp: Value = self.safe_integer_k(orderDict.clone(), "timestamp", &[]);
3234        let mut lastUpdateTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastUpdateTimestamp", &[]);
3235        let mut datetime: Value = self.safe_string_k(orderDict.clone(), "datetime", &[]);
3236        if (datetime == Value::Null) {
3237            datetime = self.iso8601(timestamp.clone());
3238        }
3239        let mut triggerPrice: Value = self.parse_number(self.safe_string2(orderDict.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]), &[]);
3240        let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "takeProfitPrice", &[]), &[]);
3241        let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "stopLossPrice", &[]), &[]);
3242        return self.extend(orderDict.clone(), &[Value::Map({
3243    let mut m = indexmap::IndexMap::new();
3244        m.insert("id".to_string(), self.safe_string_k(orderDict.clone(), "id", &[]));
3245        m.insert("clientOrderId".to_string(), self.safe_string_k(orderDict.clone(), "clientOrderId", &[]));
3246        m.insert("timestamp".to_string(), timestamp);
3247        m.insert("datetime".to_string(), datetime);
3248        m.insert("symbol".to_string(), symbol);
3249        m.insert("type".to_string(), self.safe_string_k(orderDict.clone(), "type", &[]));
3250        m.insert("side".to_string(), side);
3251        m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp);
3252        m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp);
3253        m.insert("price".to_string(), self.parse_number(price, &[]));
3254        m.insert("amount".to_string(), self.parse_number(amount, &[]));
3255        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3256        m.insert("average".to_string(), self.parse_number(average, &[]));
3257        m.insert("filled".to_string(), self.parse_number(filled, &[]));
3258        m.insert("remaining".to_string(), self.parse_number(remaining, &[]));
3259        m.insert("timeInForce".to_string(), timeInForce);
3260        m.insert("postOnly".to_string(), postOnly);
3261        m.insert("trades".to_string(), trades);
3262        m.insert("reduceOnly".to_string(), self.safe_value_k(orderDict.clone(), "reduceOnly", &[]));
3263        m.insert("stopPrice".to_string(), triggerPrice.clone());
3264        m.insert("triggerPrice".to_string(), triggerPrice);
3265        m.insert("takeProfitPrice".to_string(), takeProfitPrice);
3266        m.insert("stopLossPrice".to_string(), stopLossPrice);
3267        m.insert("status".to_string(), status);
3268        m.insert("fee".to_string(), self.safe_value_k(orderDict, "fee", &[]));
3269    m
3270})]);
3271
3272    Value::Null
3273}
3274
3275    fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3276        let mut market = get_arg(optional_args, 0, Value::Null);
3277        let mut since = get_arg(optional_args, 1, Value::Null);
3278        let mut limit = get_arg(optional_args, 2, Value::Null);
3279        let mut params = get_arg(optional_args, 3, Value::Map({
3280    let mut m = indexmap::IndexMap::new();
3281    m
3282}));
3283        //
3284        // the value of orders is either a dict or a list
3285        //
3286        // dict
3287        //
3288        //     {
3289        //         'id1': { ... },
3290        //         'id2': { ... },
3291        //         'id3': { ... },
3292        //         ...
3293        //     }
3294        //
3295        // list
3296        //
3297        //     [
3298        //         { 'id': 'id1', ... },
3299        //         { 'id': 'id2', ... },
3300        //         { 'id': 'id3', ... },
3301        //         ...
3302        //     ]
3303        //
3304        if (orders == Value::Null) {
3305            return Value::from(vec![]);
3306        }
3307        let mut results: Value = Value::from(vec![]);
3308        if (matches!(&orders, Value::Arr(_))) {
3309            {
3310                                let mut i: Value = Value::Int(0);
3311                let mut __for_first_97: bool = true;
3312                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) < ((orders.len() as i64) as f64) } {
3313                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, get_value(&orders, &i), &[market.clone()]); // don't inline this call
3314                let mut order: Value = self.extend(parsed, &[params.clone()]);
3315                append_to_array(&mut results, order.clone());
3316            }
3317            }
3318        }  else {
3319            let mut ids: Value = object_keys(&orders);
3320            {
3321                                let mut i: Value = Value::Int(0);
3322                let mut __for_first_98: bool = true;
3323                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) < ((ids.len() as i64) as f64) } {
3324                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);
3325                let mut idExtended: Value = self.extend(Value::Map({
3326                    let mut m = indexmap::IndexMap::new();
3327                        m.insert("id".to_string(), id.clone());
3328                    m
3329                }), &[get_value(&orders, &id)]);
3330                let mut parsedOrder: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, idExtended, &[market.clone()]); // don't  inline these calls
3331                let mut order: Value = self.extend(parsedOrder, &[params.clone()]);
3332                append_to_array(&mut results, order);
3333            }
3334            }
3335        }
3336        results = self.sort_by(results.clone(), Value::Str("timestamp".into()), &[]);
3337        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
3338        return self.filter_by_symbol_since_limit(results, &[symbol, since, limit]);
3339
3340    Value::Null
3341}
3342
3343    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 {
3344        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3345        let mut feeRate = get_arg(optional_args, 1, Value::Null);
3346        let mut params = get_arg(optional_args, 2, Value::Map({
3347    let mut m = indexmap::IndexMap::new();
3348    m
3349}));
3350        if (type_var.as_str() == Some("market")) && (takerOrMaker.as_str() == Some("maker")) {
3351            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()))));
3352        }
3353        let mut markets: Value = self.markets.clone();
3354        if (markets == Value::Null) {
3355            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
3356        }
3357        let mut market: Value = get_value(&markets, &symbol);
3358        let mut market: Value = get_value(&markets, &symbol);
3359        let mut feeSide: Option<String> = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".into())]).as_str().map(str::to_owned);
3360        let mut useQuote: Value = Value::Null;
3361        if (feeSide.as_deref() == Some("get")) {
3362            // the fee is always in the currency you get
3363            useQuote = Value::Bool(side.as_str() == Some("sell"));
3364        }  else if (feeSide.as_deref() == Some("give")) {
3365            // the fee is always in the currency you give
3366            useQuote = Value::Bool(side.as_str() == Some("buy"));
3367        }  else {
3368            // the fee is always in feeSide currency
3369            useQuote = Value::Bool(feeSide.as_deref() == Some("quote"));
3370        }
3371        let mut cost: Value = self.number_to_string(amount);
3372        let mut key: Value = Value::Null;
3373        if useQuote.as_bool() == Some(true) {
3374            let mut priceString: Value = self.number_to_string(price);
3375            cost = crate::precise::Precise::stringMul(&cost, &priceString);
3376            key = Value::Str("quote".into());
3377        }  else {
3378            key = Value::Str("base".into());
3379        }
3380        // for derivatives, the fee is in 'settle' currency
3381        if !is_equal(&crate::value::get_value_k(&market, "spot"), &Value::Bool(true)) {
3382            key = Value::Str("settle".into());
3383        }
3384        // even if `takerOrMaker` argument was set to 'maker', for 'market' orders we should forcefully override it to 'taker'
3385        let mut takerOrMakerResolved: Value = (if (type_var.as_str() == Some("market")) { Value::Str("taker".into()) } else { takerOrMaker });
3386        let mut rate: Value = (if (feeRate != Value::Null) { self.number_to_string(feeRate) } else { self.safe_string(market.clone(), takerOrMakerResolved.clone(), &[]) });
3387        cost = crate::precise::Precise::stringMul(&cost, &rate);
3388        return Value::Map({
3389    let mut m = indexmap::IndexMap::new();
3390        m.insert("type".to_string(), takerOrMakerResolved);
3391        m.insert("currency".to_string(), get_value(&market, &key));
3392        m.insert("rate".to_string(), self.parse_number(rate, &[]));
3393        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3394    m
3395});
3396
3397    Value::Null
3398}
3399
3400    fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3401        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3402        let mut params = get_arg(optional_args, 1, Value::Map({
3403    let mut m = indexmap::IndexMap::new();
3404    m
3405}));
3406        return self.calculate_fee_with_rate(symbol, type_var, side, amount, price, &[takerOrMaker, Value::Null, params]);
3407
3408    Value::Null
3409}
3410
3411    fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3412        let mut market = get_arg(optional_args, 0, Value::Null);
3413        let __market_empty = indexmap::IndexMap::new();
3414        let market = market.as_map().unwrap_or(&__market_empty);
3415        let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
3416        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 });
3417        let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
3418        let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3419        let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3420        if (baseValue == Value::Null) && (contracts != Value::Null) && (contractSize != Value::Null) && (price != Value::Null) {
3421            baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
3422        }
3423        if (quoteValue == Value::Null) && (baseValue != Value::Null) && (price != Value::Null) {
3424            quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
3425        }
3426        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(contracts, &[])); }
3427        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(contractSize, &[])); }
3428        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3429        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("baseValue".into(), self.parse_number(baseValue, &[])); }
3430        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("quoteValue".into(), self.parse_number(quoteValue, &[])); }
3431        return liquidation;
3432
3433    Value::Null
3434}
3435
3436    fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3437        let mut market = get_arg(optional_args, 0, Value::Null);
3438        let __market_empty = indexmap::IndexMap::new();
3439        let market = market.as_map().unwrap_or(&__market_empty);
3440        let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3441        let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
3442        let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3443        if (cost == Value::Null) {
3444            // contract trading
3445            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 });
3446            let mut multiplyPrice: Value = price.clone();
3447            if (contractSize != Value::Null) {
3448                let mut inverse: Value = (match market.get("inverse") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) });
3449                if (inverse.as_bool() == Some(true)) {
3450                    multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &price);
3451                }
3452                multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3453            }
3454            cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
3455        }
3456        let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
3457        let mut resultFee: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3458        let mut resultFees: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
3459        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fee".into(), resultFee); }
3460        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fees".into(), resultFees); }
3461        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("amount".into(), self.parse_number(amount, &[])); }
3462        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3463        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("cost".into(), self.parse_number(cost, &[])); }
3464        return trade;
3465
3466    Value::Null
3467}
3468
3469    fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3470        let mut timestamp = get_arg(optional_args, 0, Value::Null);
3471        let mut side = get_arg(optional_args, 1, Value::Null);
3472        let mut amount = get_arg(optional_args, 2, Value::Null);
3473        let mut price = get_arg(optional_args, 3, Value::Null);
3474        let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3475        // this approach is being used by multiple exchanges (mexc, woo, coinsbit, dydx, ...)
3476        let mut id: Value = Value::Null;
3477        if (timestamp != Value::Null) {
3478            id = self.number_to_string(timestamp);
3479            if (side != Value::Null) {
3480                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), side).into())).into());
3481            }
3482            if (amount != Value::Null) {
3483                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(amount)).into())).into());
3484            }
3485            if (price != Value::Null) {
3486                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(price)).into())).into());
3487            }
3488            if (takerOrMaker != Value::Null) {
3489                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), takerOrMaker).into())).into());
3490            }
3491        }
3492        return id;
3493
3494    Value::Null
3495}
3496
3497    fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3498        let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3499        let mut fees: Value = self.safe_list_k(container, "fees", &[]);
3500        let mut feeDefined: bool = fee != Value::Null;
3501        let mut feesDefined: bool = fees != Value::Null;
3502        // parsing only if at least one of them is defined
3503        let mut shouldParseFees: bool = feeDefined || feesDefined;
3504        if shouldParseFees {
3505            if feeDefined {
3506                fee = self.parse_fee_numeric(fee.clone());
3507            }
3508            if !feesDefined {
3509                // just set it directly, no further processing needed.
3510                fees = Value::from(vec![fee.clone()]);
3511            }
3512            // 'fees' were set, so reparse them
3513            let mut reducedFees: Value = fees.clone();
3514            if is_true(&self.reduceFees) {
3515                reducedFees = self.reduce_fees_by_currency(fees.clone());
3516            }
3517            if (reducedFees == Value::Null) {
3518                reducedFees = Value::from(vec![]);
3519            }
3520            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3521            {
3522                                let mut i: Value = Value::Int(0);
3523                let mut __for_first_99: bool = true;
3524                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) < reducedLength } {
3525                { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3526            }
3527            }
3528            fees = reducedFees.clone();
3529            if (reducedLength == 1.0) {
3530                fee = reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3531            }  else if (reducedLength == 0.0) {
3532                fee = Value::Null;
3533            }
3534        }
3535        // in case `fee & fees` are undefined, set `fees` as empty array
3536        if (fee == Value::Null) {
3537            fee = Value::Map({
3538                let mut m = indexmap::IndexMap::new();
3539                    m.insert("cost".to_string(), Value::Null);
3540                    m.insert("currency".to_string(), Value::Null);
3541                m
3542            });
3543        }
3544        if (fees == Value::Null) {
3545            fees = Value::from(vec![]);
3546        }
3547        return Value::from(vec![fee, fees]);
3548
3549    Value::Null
3550}
3551
3552    fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3553        { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); }; // ensure numeric
3554        if (in_op(&fee, &Value::Str("rate".into()))) {
3555            { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".into()), __be_tmp); };
3556        }
3557        return fee;
3558
3559    Value::Null
3560}
3561
3562    fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3563        //  i.e. findNearestCeiling ([ 10, 30, 50],  23) returns 30
3564        let mut length: Value = Value::Int(arr.len() as i64);
3565        {
3566                        let mut i: Value = Value::Int(0);
3567            let mut __for_first_100: bool = true;
3568            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) < length.as_f64().unwrap_or(f64::NAN) } {
3569            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);
3570            if providedValue.as_f64().unwrap_or(f64::NAN) <= current.as_f64().unwrap_or(f64::NAN) {
3571                return current;
3572            }
3573        }
3574        }
3575        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 }));
3576
3577    Value::Null
3578}
3579
3580    fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3581        let mut result: Value = Value::from(vec![]);
3582        let mut keys: Value = object_keys(&obj);
3583        {
3584                        let mut i: Value = Value::Int(0);
3585            let mut __for_first_101: bool = true;
3586            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) } {
3587            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);
3588            let mut item: Value = get_value(&obj, &key);
3589            let mut item: Value = get_value(&obj, &key);
3590            if (item == Value::Null) {
3591                continue;
3592            }
3593            let mut itemWithKey: Value = self.extend(Value::Map({
3594                let mut m = indexmap::IndexMap::new();
3595                m
3596            }), &[item]);
3597            add_element_to_object(&mut itemWithKey, &keyName, key);
3598            append_to_array(&mut result, itemWithKey);
3599        }
3600        }
3601        return result;
3602
3603    Value::Null
3604}
3605
3606    fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3607        let mut reversed: Value = Value::Map({
3608            let mut m = indexmap::IndexMap::new();
3609            m
3610        });
3611        let mut keys: Value = object_keys(&dict);
3612        {
3613                        let mut i: Value = Value::Int(0);
3614            let mut __for_first_102: bool = true;
3615            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) < ((keys.len() as i64) as f64) } {
3616            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);
3617            let mut value: Value = get_value(&dict, &key);
3618            let mut value: Value = get_value(&dict, &key);
3619            if matches!(&value, Value::Str(_)) {
3620                if let Value::Dict(__d) = &mut reversed { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&value), key); }
3621            }
3622        }
3623        }
3624        return reversed;
3625
3626    Value::Null
3627}
3628
3629    fn string_to_base16(&self, mut str_val: Value) -> Value {
3630        return Value::Str(format!("{}{}", Value::Str("0x".into()), self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val, &[]), &[]), &[])).into());
3631
3632    Value::Null
3633}
3634
3635    fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3636        //
3637        // this function takes a list of fee structures having the following format
3638        //
3639        //     string = true
3640        //
3641        //     [
3642        //         { 'currency': 'BTC', 'cost': '0.1' },
3643        //         { 'currency': 'BTC', 'cost': '0.2'  },
3644        //         { 'currency': 'BTC', 'cost': '0.2', 'rate': '0.00123' },
3645        //         { 'currency': 'BTC', 'cost': '0.4', 'rate': '0.00123' },
3646        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3647        //         { 'currency': 'USDT', 'cost': '12.3456' },
3648        //     ]
3649        //
3650        //     string = false
3651        //
3652        //     [
3653        //         { 'currency': 'BTC', 'cost': 0.1 },
3654        //         { 'currency': 'BTC', 'cost': 0.2 },
3655        //         { 'currency': 'BTC', 'cost': 0.2, 'rate': 0.00123 },
3656        //         { 'currency': 'BTC', 'cost': 0.4, 'rate': 0.00123 },
3657        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3658        //         { 'currency': 'USDT', 'cost': 12.3456 },
3659        //     ]
3660        //
3661        // and returns a reduced fee list, where fees are summed per currency and rate (if any)
3662        //
3663        //     string = true
3664        //
3665        //     [
3666        //         { 'currency': 'BTC', 'cost': '0.4'  },
3667        //         { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
3668        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3669        //         { 'currency': 'USDT', 'cost': '12.3456' },
3670        //     ]
3671        //
3672        //     string  = false
3673        //
3674        //     [
3675        //         { 'currency': 'BTC', 'cost': 0.3  },
3676        //         { 'currency': 'BTC', 'cost': 0.6, 'rate': 0.00123 },
3677        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3678        //         { 'currency': 'USDT', 'cost': 12.3456 },
3679        //     ]
3680        //
3681        let mut reduced: Value = Value::Map({
3682            let mut m = indexmap::IndexMap::new();
3683            m
3684        });
3685        {
3686                        let mut i: Value = Value::Int(0);
3687            let mut __for_first_103: bool = true;
3688            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) < get_array_length(&fees).as_f64().unwrap_or(f64::NAN) } {
3689            let mut fee: Value = get_value(&fees, &i);
3690            let mut fee: Value = get_value(&fees, &i);
3691            let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3692            let mut feeCurrencyCode: Value = (if (code != Value::Null) { code.clone() } else { to_string_val(&i) });
3693            if (feeCurrencyCode != Value::Null) {
3694                let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3695                let mut cost: Value = self.safe_string_k(fee, "cost", &[]);
3696                if (cost == Value::Null) {
3697                    continue;
3698                }
3699                if !(in_op(&reduced, &feeCurrencyCode)) {
3700                    if let Value::Dict(__d) = &mut reduced { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&feeCurrencyCode), Value::Map({
3701    let mut m = indexmap::IndexMap::new();
3702    m
3703})); }
3704                }
3705                let mut rateKey: Value = (if (rate == Value::Null) { Value::Str("".into()) } else { rate.clone() });
3706                if (in_op(&reduced.as_map().and_then(|__m| feeCurrencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &rateKey)) {
3707                    { 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); };
3708                }  else {
3709                    add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
3710    let mut m = indexmap::IndexMap::new();
3711        m.insert("currency".to_string(), code);
3712        m.insert("cost".to_string(), cost);
3713    m
3714}));
3715                    if (rate != Value::Null) {
3716                        add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".into()), rate);
3717                    }
3718                }
3719            }
3720        }
3721        }
3722        let mut result: Value = Value::from(vec![]);
3723        let mut feeValues: Value = object_values(&reduced);
3724        {
3725                        let mut i: Value = Value::Int(0);
3726            let mut __for_first_104: bool = true;
3727            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) < ((feeValues.len() as i64) as f64) } {
3728            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));
3729            result = self.array_concat(result.clone(), reducedFeeValues);
3730        }
3731        }
3732        return result;
3733
3734    Value::Null
3735}
3736
3737    fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3738        let mut market = get_arg(optional_args, 0, Value::Null);
3739        let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3740        let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".into()), Value::Str("last".into()), &[]));
3741        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
3742        let mut percentage: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "percentage", &[]));
3743        let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3744        let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3745        let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
3746        let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
3747        if (vwap == Value::Null) {
3748            vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
3749        }
3750        // calculate open
3751        if (change != Value::Null) {
3752            if (close == Value::Null) && (average != Value::Null) {
3753                close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".into())));
3754            }
3755            if (open == Value::Null) && (close != Value::Null) {
3756                open = crate::precise::Precise::stringSub(&close, &change);
3757            }
3758        }  else if (percentage != Value::Null) {
3759            if (close == Value::Null) && (average != Value::Null) {
3760                let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".into()));
3761                // openAddClose = open * (1 + (100 + percentage)/100)
3762                let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3763                let mut calcOpen: Value = (if (open != Value::Null) { open.clone() } else { crate::precise::Precise::stringDiv(&openAddClose, &denominator) });
3764                close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3765            }
3766            if (open == Value::Null) && (close != Value::Null) {
3767                open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3768            }
3769        }
3770        // change
3771        if (change == Value::Null) {
3772            if (close != Value::Null) && (open != Value::Null) {
3773                change = crate::precise::Precise::stringSub(&close, &open);
3774            }  else if (close != Value::Null) && (percentage != Value::Null) {
3775                change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".into())));
3776            }  else if (open != Value::Null) && (percentage != Value::Null) {
3777                change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3778            }
3779        }
3780        // calculate things according to "open" (similar can be done with "close")
3781        if (open != Value::Null) {
3782            // percentage (using change)
3783            if (percentage == Value::Null) && (change != Value::Null) {
3784                percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".into()));
3785            }
3786            // close (using change)
3787            if (close == Value::Null) && (change != Value::Null) {
3788                close = crate::precise::Precise::stringAdd(&open, &change);
3789            }
3790            // close (using average)
3791            if (close == Value::Null) && (average != Value::Null) {
3792                // average is the midpoint of open and close, so twice it is their sum
3793                close = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&average, &Value::Str("2".into())), &open);
3794            }
3795            // average
3796            if (average == Value::Null) && (close != Value::Null) {
3797                let mut precision: Value = Value::Int(18);
3798                if (market != Value::Null) && self.is_tick_precision().as_bool() == Some(true) {
3799                    let mut marketPrecision: Value = self.safe_dict_k(market, "precision", &[]);
3800                    let mut precisionPrice: Value = self.safe_string_k(marketPrecision, "price", &[]);
3801                    if (precisionPrice != Value::Null) {
3802                        precision = self.precision_from_string(precisionPrice);
3803                    }
3804                }
3805                average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".into()), &precision);
3806            }
3807        }
3808        // timestamp and symbol operations don't belong in safeTicker
3809        // they should be done in the derived classes
3810        let mut closeParsed: Value = self.parse_number(self.omit_zero(close), &[]);
3811        return self.extend(ticker.clone(), &[Value::Map({
3812    let mut m = indexmap::IndexMap::new();
3813        m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3814        m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3815        m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3816        m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3817        m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3818        m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3819        m.insert("open".to_string(), self.parse_number(self.omit_zero(open), &[]));
3820        m.insert("close".to_string(), closeParsed.clone());
3821        m.insert("last".to_string(), closeParsed);
3822        m.insert("change".to_string(), self.parse_number(change, &[]));
3823        m.insert("percentage".to_string(), self.parse_number(percentage, &[]));
3824        m.insert("average".to_string(), self.parse_number(average, &[]));
3825        m.insert("vwap".to_string(), self.parse_number(vwap, &[]));
3826        m.insert("baseVolume".to_string(), self.parse_number(baseVolume, &[]));
3827        m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume, &[]));
3828        m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3829        m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3830        m.insert("markPrice".to_string(), self.safe_number_k(ticker, "markPrice", &[]));
3831    m
3832})]);
3833
3834    Value::Null
3835}
3836
3837    fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".into()))));
3843
3844    Value::Null
3845} }
3846
3847    fn repay_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("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 {
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(" repayCrossMargin is not support yet".into()))));
3858
3859    Value::Null
3860} }
3861
3862    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 {
3863        // async-virtual: try the derived exchange first
3864        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 {
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(" repayIsolatedMargin is not support yet".into()))));
3873
3874    Value::Null
3875} }
3876
3877    fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3878        // async-virtual: try the derived exchange first
3879        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 {
3880            if !matches!(__v, crate::Value::Null) { return __v; }
3881        }
3882
3883        let mut params = get_arg(optional_args, 0, Value::Map({
3884    let mut m = indexmap::IndexMap::new();
3885    m
3886}));
3887        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowCrossMargin is not support yet".into()))));
3888
3889    Value::Null
3890} }
3891
3892    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 {
3893        // async-virtual: try the derived exchange first
3894        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 {
3895            if !matches!(__v, crate::Value::Null) { return __v; }
3896        }
3897
3898        let mut params = get_arg(optional_args, 0, Value::Map({
3899    let mut m = indexmap::IndexMap::new();
3900    m
3901}));
3902        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowIsolatedMargin is not support yet".into()))));
3903
3904    Value::Null
3905} }
3906
3907    fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3908        let mut symbol = get_arg(optional_args, 0, Value::Null);
3909        let mut params = get_arg(optional_args, 1, Value::Map({
3910    let mut m = indexmap::IndexMap::new();
3911    m
3912}));
3913        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".into()))));
3914
3915    Value::Null
3916} }
3917
3918    fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3919        let mut symbol = get_arg(optional_args, 0, Value::Null);
3920        let mut params = get_arg(optional_args, 1, Value::Map({
3921    let mut m = indexmap::IndexMap::new();
3922    m
3923}));
3924        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".into()))));
3925
3926    Value::Null
3927} }
3928
3929    fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3930        // async-virtual: try the derived exchange first
3931        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 {
3932            if !matches!(__v, crate::Value::Null) { return __v; }
3933        }
3934
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        let mut message: Value = Value::Str("".into());
3943        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)) {
3944            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());
3945        }
3946        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() is not supported yet".into())).into()), message)));
3947
3948    Value::Null
3949} }
3950
3951    fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3952        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3953        let mut since = get_arg(optional_args, 1, Value::Null);
3954        let mut limit = get_arg(optional_args, 2, Value::Null);
3955        let mut params = get_arg(optional_args, 3, Value::Map({
3956    let mut m = indexmap::IndexMap::new();
3957    m
3958}));
3959        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotOHLCV() is not supported yet".into()))));
3960
3961    Value::Null
3962} }
3963
3964    fn fetch_contract_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(" fetchContractOHLCV() is not supported yet".into()))));
3973
3974    Value::Null
3975} }
3976
3977    fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3978        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3979        let mut since = get_arg(optional_args, 1, Value::Null);
3980        let mut limit = get_arg(optional_args, 2, Value::Null);
3981        let mut params = get_arg(optional_args, 3, Value::Map({
3982    let mut m = indexmap::IndexMap::new();
3983    m
3984}));
3985        let mut message: Value = Value::Str("".into());
3986        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)) {
3987            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());
3988        }
3989        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)));
3990
3991    Value::Null
3992} }
3993
3994    fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3995        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3996        let mut since = get_arg(optional_args, 1, Value::Null);
3997        let mut limit = get_arg(optional_args, 2, Value::Null);
3998        let mut params = get_arg(optional_args, 3, Value::Map({
3999    let mut m = indexmap::IndexMap::new();
4000    m
4001}));
4002        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCV() is not supported yet".into()))));
4003
4004    Value::Null
4005} }
4006
4007    fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4008        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4009        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4010        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4011        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4012        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4013        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4014        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4015        let mut result: Value = Value::from(vec![]);
4016        let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp, &[Value::from(vec![])]);
4017        let mut opens: Value = self.safe_list(ohlcvs.clone(), open, &[Value::from(vec![])]);
4018        let mut highs: Value = self.safe_list(ohlcvs.clone(), high, &[Value::from(vec![])]);
4019        let mut lows: Value = self.safe_list(ohlcvs.clone(), low, &[Value::from(vec![])]);
4020        let mut closes: Value = self.safe_list(ohlcvs.clone(), close, &[Value::from(vec![])]);
4021        let mut volumes: Value = self.safe_list(ohlcvs, 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) < ((timestamps.len() as i64) as f64) } {
4026            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(), &[])]));
4027        }
4028        }
4029        return result;
4030
4031    Value::Null
4032}
4033
4034    fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4035        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4036        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4037        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4038        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4039        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4040        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4041        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4042        let mut result: Value = Value::Map({
4043            let mut m = indexmap::IndexMap::new();
4044            m
4045        });
4046        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&timestamp), Value::from(vec![])); }
4047        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&open), Value::from(vec![])); }
4048        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&high), Value::from(vec![])); }
4049        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&low), Value::from(vec![])); }
4050        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&close), Value::from(vec![])); }
4051        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&volume), Value::from(vec![])); }
4052        {
4053                        let mut i: Value = Value::Int(0);
4054            let mut __for_first_106: bool = true;
4055            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) < ((ohlcvs.len() as i64) as f64) } {
4056            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 })) });
4057            let mut resultTimestamp: Value = get_value(&result, &timestamp);
4058            append_to_array(&mut resultTimestamp, ts);
4059            crate::set_value(&mut result, &timestamp, resultTimestamp);
4060            let mut resultOpen: Value = get_value(&result, &open);
4061            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));
4062            crate::set_value(&mut result, &open, resultOpen);
4063            let mut resultHigh: Value = get_value(&result, &high);
4064            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));
4065            crate::set_value(&mut result, &high, resultHigh);
4066            let mut resultLow: Value = get_value(&result, &low);
4067            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));
4068            crate::set_value(&mut result, &low, resultLow);
4069            let mut resultClose: Value = get_value(&result, &close);
4070            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));
4071            crate::set_value(&mut result, &close, resultClose);
4072            let mut resultVolume: Value = get_value(&result, &volume);
4073            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));
4074            crate::set_value(&mut result, &volume, resultVolume);
4075        }
4076        }
4077        return result;
4078
4079    Value::Null
4080}
4081
4082    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 {
4083        let mut startRegex = get_arg(optional_args, 0, Value::Null);
4084        let mut endRegex = get_arg(optional_args, 1, Value::Null);
4085        let mut errorMessage: Value = Value::Str("".into());
4086        let mut options: Value = self.safe_value(self.options.clone(), method, &[Value::Map({
4087            let mut m = indexmap::IndexMap::new();
4088            m
4089        })]);
4090        let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4091        {
4092            // if it was not explicitly disabled, then don't fetch
4093            if !matches!(self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)]), Value::Bool(true)) {
4094                return Value::Null;
4095            }
4096            let mut maxRetries: Value = self.safe_integer_k(options, "webApiRetries", &[Value::Int(10)]);
4097            let mut response: Value = Value::Null;
4098            let mut retry: f64 = ((0i64) as f64);
4099            let mut shouldBreak: bool = false;
4100            while retry < maxRetries.as_f64().unwrap_or(f64::NAN) {
4101                {
4102                    response = self.call_dynamic_checked(endpointMethod.clone(), vec![(Value::Map({
4103                        let mut m = indexmap::IndexMap::new();
4104                        m
4105                    })).clone()]).await;
4106                    shouldBreak = true;
4107                    break;
4108                }
4109                if shouldBreak {
4110                    break;
4111                }
4112            }
4113            let mut content: Value = response;
4114            if (content == Value::Null) {
4115                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4116            }
4117            if (startRegex != Value::Null) {
4118                let mut splitted_by_start: Value = split(&content, &startRegex);
4119                content = get_value(&splitted_by_start, &Value::Int(1)); // we need second part after start
4120            }
4121            if (content == Value::Null) {
4122                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4123            }
4124            if (endRegex != Value::Null) {
4125                let mut splitted_by_end: Value = split(&content, &endRegex);
4126                content = get_value(&splitted_by_end, &Value::Int(0)); // we need first part after start
4127            }
4128            if (is_equal(&returnAsJson, &Value::Bool(true))) && (matches!(&content, Value::Str(_))) {
4129                let mut jsoned: Value = self.parse_json_value(trim(&content)); // content should be trimmed before json parsing
4130                if (jsoned != Value::Null) && (jsoned != Value::Null) {
4131                    return jsoned;
4132                }  else {
4133                    panic!("{}", crate::exchange_errors::bad_response("could not parse the response into json"));
4134                }
4135            }  else {
4136                return content;
4137            }
4138        }
4139        if (muteOnFailure.as_bool() == Some(true)) {
4140            return Value::Null;
4141        }  else {
4142            panic!("{}", crate::exchange_errors::bad_response(errorMessage));
4143        }
4144} }
4145
4146    fn market_ids(&self, optional_args: &[Value]) -> Value {
4147        let mut symbols = get_arg(optional_args, 0, Value::Null);
4148        /*
4149         * @param {string[]|undefined} symbols list of unified symbols
4150         * @returns {string[]|undefined} list of exchange-specific market ids
4151         * Overloads: non-null `string[]` input yields `string[]`; optional input yields `Strings`.
4152         */
4153        if (symbols == Value::Null) {
4154            return symbols;
4155        }
4156        let mut result: Value = Value::from(vec![]);
4157        {
4158                        let mut i: Value = Value::Int(0);
4159            let mut __for_first_107: bool = true;
4160            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) < ((symbols.len() as i64) as f64) } {
4161            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));
4162            if (id != Value::Null) {
4163                append_to_array(&mut result, id);
4164            }
4165        }
4166        }
4167        return result;
4168
4169    Value::Null
4170}
4171
4172    fn currency_ids(&self, optional_args: &[Value]) -> Value {
4173        let mut codes = get_arg(optional_args, 0, Value::Null);
4174        if (codes == Value::Null) {
4175            return codes;
4176        }
4177        let mut result: Value = Value::from(vec![]);
4178        {
4179                        let mut i: Value = Value::Int(0);
4180            let mut __for_first_108: bool = true;
4181            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) < ((codes.len() as i64) as f64) } {
4182            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));
4183            if (id != Value::Null) {
4184                append_to_array(&mut result, id);
4185            }
4186        }
4187        }
4188        return result;
4189
4190    Value::Null
4191}
4192
4193    fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4194        let mut symbols = get_arg(optional_args, 0, Value::Null);
4195        if (symbols == Value::Null) {
4196            return Value::Null;
4197        }
4198        let mut result: Value = Value::from(vec![]);
4199        {
4200                        let mut i: Value = Value::Int(0);
4201            let mut __for_first_109: bool = true;
4202            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) } {
4203            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)));
4204        }
4205        }
4206        return result;
4207
4208    Value::Null
4209}
4210
4211// allowEmpty: false always returns string[] (throws on empty/undefined at runtime)
4212    fn market_symbols(&self, optional_args: &[Value]) -> Value {
4213        let mut symbols = get_arg(optional_args, 0, Value::Null);
4214        let mut type_var = get_arg(optional_args, 1, Value::Null);
4215        let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4216        let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4217        let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4218        /*
4219         * @param {string[]|undefined} symbols list of unified symbols
4220         * @param {string|undefined} type filter by market type
4221         * @param {boolean} allowEmpty whether empty/undefined symbols is allowed
4222         * @param {boolean} sameTypeOnly require all markets to share type
4223         * @param {boolean} sameSubTypeOnly require all markets to share linear/inverse subType
4224         * @returns {string[]|undefined} validated unified symbols
4225         * Overloads: `allowEmpty: false` or non-null `string[]` input yields `string[]`; permissive form yields `Strings`.
4226         */
4227        if (symbols == Value::Null) {
4228            if !is_true(&allowEmpty) {
4229                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4230            }
4231            return symbols;
4232        }
4233        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
4234        if (symbolsLength == 0.0) {
4235            if !is_true(&allowEmpty) {
4236                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4237            }
4238            return symbols;
4239        }
4240        let mut result: Value = Value::from(vec![]);
4241        let mut marketType: Value = Value::Null;
4242        let mut isLinearSubType: Value = Value::Null;
4243        {
4244                        let mut i: Value = Value::Int(0);
4245            let mut __for_first_110: bool = true;
4246            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) < ((symbols.len() as i64) as f64) } {
4247            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));
4248            if is_true(&sameTypeOnly) && (marketType != Value::Null) {
4249                if (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != marketType.as_str()) {
4250                    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()))));
4251                }
4252            }
4253            if is_true(&sameSubTypeOnly) && (isLinearSubType != Value::Null) {
4254                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() != isLinearSubType.as_bool()) {
4255                    panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same subType, either linear or inverse.".into()))));
4256                }
4257            }
4258            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()) {
4259                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()))));
4260            }
4261            marketType = self.safe_string_k(market.clone(), "type", &[]);
4262            if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
4263                isLinearSubType = self.safe_bool_k(market.clone(), "linear", &[]);
4264            }
4265            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)]);
4266            append_to_array(&mut result, symbol);
4267        }
4268        }
4269        return result;
4270
4271    Value::Null
4272}
4273
4274    fn market_codes(&self, optional_args: &[Value]) -> Value {
4275        let mut codes = get_arg(optional_args, 0, Value::Null);
4276        if (codes == Value::Null) {
4277            return codes;
4278        }
4279        let mut result: Value = Value::from(vec![]);
4280        {
4281                        let mut i: Value = Value::Int(0);
4282            let mut __for_first_111: bool = true;
4283            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) < ((codes.len() as i64) as f64) } {
4284            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)));
4285        }
4286        }
4287        return result;
4288
4289    Value::Null
4290}
4291
4292    fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4293        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4294        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4295        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4296        let mut bidasksValue: Value = self.to_array(bidasks);
4297        let mut result: Value = Value::from(vec![]);
4298        {
4299                        let mut i: Value = Value::Int(0);
4300            let mut __for_first_112: bool = true;
4301            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(&bidasksValue).as_f64().unwrap_or(f64::NAN) } {
4302            append_to_array(&mut result, self.parse_order_book_bid_ask(get_value(&bidasksValue, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4303        }
4304        }
4305        return result;
4306
4307    Value::Null
4308}
4309
4310    fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4311        let mut value = get_arg(optional_args, 0, Value::Null);
4312        if (value == Value::Null) {
4313            return objects;
4314        }
4315        let mut result: Value = Value::from(vec![]);
4316        {
4317                        let mut i: Value = Value::Int(0);
4318            let mut __for_first_113: bool = true;
4319            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) < get_array_length(&objects).as_f64().unwrap_or(f64::NAN) } {
4320            let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
4321            if (objectValue.as_str() == value.as_str()) {
4322                append_to_array(&mut result, get_value(&objects, &i));
4323            }
4324        }
4325        }
4326        return result;
4327
4328    Value::Null
4329}
4330
4331    fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4332        let mut symbol = get_arg(optional_args, 0, Value::Null);
4333        return self.filter_by_key(objects, Value::Str("symbol".into()), &[symbol]);
4334
4335    Value::Null
4336}
4337
4338    fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4339        // virtual-dispatch (static: DerivedExchange::parse_ohlcv(self, ...))
4340        { 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; } }
4341
4342        let mut market = get_arg(optional_args, 0, Value::Null);
4343        if (matches!(&ohlcv, Value::Arr(_))) {
4344            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), &[])]);
4345        }
4346        return ohlcv;
4347
4348    Value::Null
4349}
4350
4351    fn safe_network(&self, mut network: Value) -> Value {
4352        let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
4353        let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
4354        let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
4355        let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4356        let mut deposit: Value = self.safe_dict_k(limits, "deposit", &[]);
4357        let mut isEnabled: Value = withdrawEnabled.clone();
4358        if (withdrawEnabled.as_bool() == Some(true)) {
4359            isEnabled = depositEnabled.clone();
4360        }
4361        return Value::Map({
4362    let mut m = indexmap::IndexMap::new();
4363        m.insert("info".to_string(), crate::value::get_value_k(&network, "info"));
4364        m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
4365        m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
4366        m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
4367        m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled]));
4368        m.insert("deposit".to_string(), depositEnabled);
4369        m.insert("withdraw".to_string(), withdrawEnabled);
4370        m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
4371        m.insert("precision".to_string(), self.safe_number_k(network, "precision", &[]));
4372        m.insert("limits".to_string(), Value::Map({
4373    let mut m = indexmap::IndexMap::new();
4374        m.insert("withdraw".to_string(), Value::Map({
4375    let mut m = indexmap::IndexMap::new();
4376        m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4377        m.insert("max".to_string(), self.safe_number_k(withdraw, "max", &[]));
4378    m
4379}));
4380        m.insert("deposit".to_string(), Value::Map({
4381    let mut m = indexmap::IndexMap::new();
4382        m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4383        m.insert("max".to_string(), self.safe_number_k(deposit, "max", &[]));
4384    m
4385}));
4386    m
4387}));
4388    m
4389});
4390
4391    Value::Null
4392}
4393
4394    fn prioritized_network_aliases(&self, optional_args: &[Value]) -> Value {
4395        let mut networkCode = get_arg(optional_args, 0, Value::Null);
4396        let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4397        let mut allowDefault = get_arg(optional_args, 2, Value::Bool(false));
4398        /*
4399         * @method
4400         * @name Exchange#prioritizedNetworkAliases
4401         * @description returns the chain pair [preferred, alternative] for the given networkCode & currency, e.g:
4402         *   ---------------------------------
4403         *   | input          | output       |
4404         *   --------------------------------|
4405         *   | ETH & USDC     | ERC20, ETH   |
4406         *   | ERC20 & USDC   | ERC20, ETH   |
4407         *   | ETH & ETH      | ETH, ERC20   |
4408         *   | ERC20 & ETH    | ETH, ERC20   |
4409         *   | ERC20          | ERC20, ETH   |
4410         *   | ETH            | ERC20, ETH   |
4411         *   ---------------------------------
4412         * @param {string} networkCode unified network-code
4413         * @param {string} currencyCode unified currency-code
4414         * @param {boolean} allowDefault when currencyCode is undefined, order by replacement's "default" instead of by user input
4415         * @returns {string[]} [preferredChain, alternativeChain]
4416         */
4417        if (networkCode == Value::Null) {
4418            return Value::Null;
4419        }
4420        let mut replacements: Value = self.safe_dict_k(self.options.clone(), "defaultNetworkCodeReplacements", &[Value::Map({
4421    let mut m = indexmap::IndexMap::new();
4422    m
4423})]);
4424        let mut keys: Value = object_keys(&replacements);
4425        {
4426                        let mut i: Value = Value::Int(0);
4427            let mut __for_first_114: bool = true;
4428            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) < ((keys.len() as i64) as f64) } {
4429            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);
4430            let mut entry: Value = replacements.as_map().and_then(|__m| baseCoin.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4431            let mut primary: Value = crate::value::get_value_k(&entry, "primary");
4432            let mut secondary: Value = crate::value::get_value_k(&entry, "secondary");
4433            if !is_equal(&networkCode, &primary) && !is_equal(&networkCode, &secondary) {
4434                continue;
4435            }
4436            // pick which form goes first in the returned pair
4437            let mut preferPrimary: bool = false;
4438            if (currencyCode.as_str() == baseCoin.as_str()) {
4439                preferPrimary = true; // mainnet currency uses primary chain
4440            }  else if (currencyCode != Value::Null) {
4441                preferPrimary = false; // any other (token) currency uses secondary chain
4442            }  else if is_true(&allowDefault) {
4443                preferPrimary = crate::value::get_value_k(&entry, "default").as_str() == Some("primary");
4444            }  else {
4445                preferPrimary = is_equal(&networkCode, &primary); // keep user input first
4446            }
4447            return (if (preferPrimary) { Value::from(vec![primary.clone(), secondary.clone()]) } else { Value::from(vec![secondary, primary]) });
4448        }
4449        }
4450        return Value::from(vec![networkCode.clone(), networkCode.clone()]);
4451
4452    Value::Null
4453}
4454
4455    fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4456        let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4457        /*
4458         * @ignore
4459         * @method
4460         * @name exchange#networkCodeToId
4461         * @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.
4462         * @param {string} networkCode unified network code
4463         * @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
4464         * @returns {string|undefined} exchange-specific network id
4465         */
4466        if (networkCode == Value::Null) {
4467            return Value::Null;
4468        }
4469        let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4470    let mut m = indexmap::IndexMap::new();
4471    m
4472})]);
4473        // try the preferred form first, fall back to its alternative (e.g. when only 'ETH' or only 'ERC20' is defined)
4474        let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(false)]);
4475        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) });
4476        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) });
4477        let mut networkId: Value = self.safe_string2(networkIdsByCodes, preferredChain, alternativeChain, &[]);
4478        if (networkId != Value::Null) {
4479            return networkId;
4480        }
4481        // fall back to scanning loaded currencies
4482        let mut currenciesToCheck: Value = Value::from(vec![]);
4483        if (currencyCode == Value::Null) {
4484            currenciesToCheck = object_keys(&self.currencies);
4485        }  else {
4486            currenciesToCheck = Value::from(vec![self.safe_dict(self.currencies.clone(), currencyCode.clone(), &[])]);
4487        }
4488        {
4489                        let mut i: Value = Value::Int(0);
4490            let mut __for_first_115: bool = true;
4491            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) < ((currenciesToCheck.len() as i64) as f64) } {
4492            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({
4493    let mut m = indexmap::IndexMap::new();
4494    m
4495})]);
4496            if (in_op(&networks, &networkCode)) {
4497                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()), &[]);
4498            }
4499        }
4500        }
4501        // before returning the original input, try to match if it's backward-maintained networkCode
4502        let mut oldCodes: Value = self.safe_dict_k(self.options.clone(), "backwardSupportedNetworkCodes", &[Value::Map({
4503    let mut m = indexmap::IndexMap::new();
4504    m
4505})]);
4506        if (in_op(&oldCodes, &networkCode)) {
4507            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]);
4508        }
4509        return networkCode;
4510
4511    Value::Null
4512}
4513
4514    fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4515        let mut networkId = get_arg(optional_args, 0, Value::Null);
4516        let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4517        /*
4518         * @ignore
4519         * @method
4520         * @name exchange#networkIdToCode
4521         * @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.
4522         * @param {string} networkId exchange specific network id/title, like: TRON, Trc-20, usdt-erc20, etc
4523         * @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
4524         * @returns {string|undefined} unified network code
4525         */
4526        if (networkId == Value::Null) {
4527            return Value::Null;
4528        }
4529        let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4530    let mut m = indexmap::IndexMap::new();
4531    m
4532})]);
4533        let mut networkCode: Value = self.safe_string(networkCodesByIds, networkId.clone(), &[networkId.clone()]);
4534        let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(true)]);
4535        if (chainPair == Value::Null) {
4536            return networkCode;
4537        }
4538        let mut preferredChain: Value = chainPair.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
4539        let mut alternativeChain: Value = chainPair.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
4540        // when the exchange explicitly defines both forms in options.networks (e.g. BTC + BRC20),
4541        // it disambiguates them — trust the direct id→code inversion instead of guessing
4542        if (currencyCode == Value::Null) {
4543            let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4544    let mut m = indexmap::IndexMap::new();
4545    m
4546})]);
4547            if (in_op(&networkIdsByCodes, &preferredChain)) && (in_op(&networkIdsByCodes, &alternativeChain)) {
4548                return networkCode;
4549            }
4550        }
4551        return preferredChain;
4552
4553    Value::Null
4554}
4555
4556    fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4557        let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".into()), Value::Str("network".into()), &[]);
4558        let mut paramsOmitted: Value = (if (networkCodeInParams != Value::Null) { self.omit(params.clone(), Value::from(vec![Value::Str("networkCode".into()), Value::Str("network".into())]), &[]) } else { params });
4559        return Value::from(vec![networkCodeInParams, paramsOmitted]);
4560
4561    Value::Null
4562}
4563
4564    fn default_network_code(&self, mut currencyCode: Value) -> Value {
4565        let mut defaultNetworkCode: Value = Value::Null;
4566        let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4567    let mut m = indexmap::IndexMap::new();
4568    m
4569})]);
4570        if (in_op(&defaultNetworks, &currencyCode)) {
4571            // if currency had set its network in "defaultNetworks", use it
4572            defaultNetworkCode = defaultNetworks.as_map().and_then(|__m| currencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4573        }  else {
4574            // 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)
4575            let mut defaultNetwork: Value = self.safe_string_k(self.options.clone(), "defaultNetwork", &[]);
4576            if (defaultNetwork != Value::Null) {
4577                defaultNetworkCode = defaultNetwork;
4578            }
4579        }
4580        return defaultNetworkCode;
4581
4582    Value::Null
4583}
4584
4585    fn select_network_code_from_unified_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4586        return self.select_network_key_from_networks(currencyCode, networkCode, indexedNetworkEntries, &[Value::Bool(true)]);
4587
4588    Value::Null
4589}
4590
4591    fn select_network_id_from_raw_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4592        return self.select_network_key_from_networks(currencyCode, networkCode, indexedNetworkEntries, &[Value::Bool(false)]);
4593
4594    Value::Null
4595}
4596
4597    fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4598        let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4599        // this method is used against raw & unparse network entries, which are just indexed by network id
4600        let mut chosenNetworkId: Value = Value::Null;
4601        let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4602        let mut responseNetworksLength: f64 = ((availableNetworkIds.len() as i64) as f64);
4603        if (networkCode != Value::Null) {
4604            if (responseNetworksLength == 0.0) {
4605                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), networkCode).into()), Value::Str(" network did not return any result for ".into())).into()), currencyCode)));
4606            }  else {
4607                // if networkCode was provided by user, we should check it after response, as the referenced exchange doesn't support network-code during request
4608                let mut networkIdOrCode: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { networkCode.clone() } else { self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]) });
4609                if (networkIdOrCode == Value::Null) {
4610                    panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), networkCode).into()), Value::Str(" network was not found for ".into())).into()), currencyCode)));
4611                }
4612                if (in_op(&indexedNetworkEntries, &networkIdOrCode)) {
4613                    chosenNetworkId = networkIdOrCode.clone();
4614                }  else {
4615                    panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), networkIdOrCode).into()), Value::Str(" network was not found for ".into())).into()), currencyCode).into()), Value::Str(", use one of ".into())).into()), join(&availableNetworkIds, &Value::Str(", ".into())))));
4616                }
4617            }
4618        }  else {
4619            if (responseNetworksLength == 0.0) {
4620                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - no networks were returned for ".into())).into()), currencyCode)));
4621            }  else {
4622                // 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
4623                let mut defaultNetworkCode: Value = self.default_network_code(currencyCode.clone());
4624                let mut defaultNetworkId: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { defaultNetworkCode.clone() } else { self.network_code_to_id(defaultNetworkCode, &[currencyCode]) });
4625                if (defaultNetworkId == Value::Null) {
4626                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".into()))));
4627                }
4628                if (in_op(&indexedNetworkEntries, &defaultNetworkId)) {
4629                    return defaultNetworkId;
4630                }
4631                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())))));
4632            }
4633        }
4634        return chosenNetworkId;
4635
4636    Value::Null
4637}
4638
4639    fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4640        let mut d = get_arg(optional_args, 0, Value::Null);
4641        let mut value: Value = self.safe_string2(dictionary, key1, key2, &[]);
4642        return self.parse_number(value, &[d]);
4643
4644    Value::Null
4645}
4646
4647    fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4648        // virtual-dispatch (static: DerivedExchange::parse_order_book(self, ...))
4649        { 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; } }
4650
4651        let mut timestamp = get_arg(optional_args, 0, Value::Null);
4652        let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4653        let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4654        let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4655        let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4656        let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4657        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()]);
4658        let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4659        return Value::Map({
4660    let mut m = indexmap::IndexMap::new();
4661        m.insert("symbol".to_string(), symbol);
4662        m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4663        m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4664        m.insert("timestamp".to_string(), timestamp.clone());
4665        m.insert("datetime".to_string(), self.iso8601(timestamp));
4666        m.insert("nonce".to_string(), Value::Null);
4667    m
4668});
4669
4670    Value::Null
4671}
4672
4673    fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4674        let mut market = get_arg(optional_args, 0, Value::Null);
4675        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
4676        let mut since = get_arg(optional_args, 2, Value::Null);
4677        let mut limit = get_arg(optional_args, 3, Value::Null);
4678        let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4679        if (ohlcvs == Value::Null) {
4680            return Value::from(vec![]);
4681        }
4682        let mut results: Value = Value::from(vec![]);
4683        {
4684                        let mut i: Value = Value::Int(0);
4685            let mut __for_first_116: bool = true;
4686            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) < ((ohlcvs.len() as i64) as f64) } {
4687            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()]));
4688        }
4689        }
4690        let mut sorted: Value = self.sort_by(results, Value::Int(0), &[]);
4691        return self.filter_by_since_limit(sorted, &[since, limit, Value::Int(0), tail]);
4692
4693    Value::Null
4694}
4695
4696    fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4697        let mut symbols = get_arg(optional_args, 0, Value::Null);
4698        let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4699        // marketIdKey should only be undefined when response is a dictionary.
4700        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4701        let mut tiers: Value = Value::Map({
4702            let mut m = indexmap::IndexMap::new();
4703            m
4704        });
4705        let mut symbolsLength: Value = Value::Int(0);
4706        if (symbolsNormalized != Value::Null) {
4707            symbolsLength = Value::Int(symbolsNormalized.len() as i64);
4708        }
4709        let mut noSymbols: bool = (symbolsNormalized == Value::Null) || (symbolsLength.as_f64() == Some(0.0));
4710        if (matches!(&response, Value::Arr(_))) {
4711            {
4712                                let mut i: Value = Value::Int(0);
4713                let mut __for_first_117: bool = true;
4714                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) < ((response.len() as i64) as f64) } {
4715                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);
4716                let mut id: Value = (if (marketIdKey == Value::Null) { Value::Null } else { self.safe_string(item.clone(), marketIdKey.clone(), &[]) });
4717                let mut market: Value = self.safe_market(&[id, Value::Null, Value::Null, Value::Str("swap".into())]);
4718                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4719                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4720                if (contract.as_bool() == Some(true)) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4721                    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()])); }
4722                }
4723            }
4724            }
4725        }  else {
4726            let mut keys: Value = object_keys(&response);
4727            {
4728                                let mut i: Value = Value::Int(0);
4729                let mut __for_first_118: bool = true;
4730                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) < ((keys.len() as i64) as f64) } {
4731                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);
4732                let mut item: Value = get_value(&response, &marketId);
4733                let mut item: Value = get_value(&response, &marketId);
4734                let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("swap".into())]);
4735                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4736                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4737                if (contract.as_bool() == Some(true)) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4738                    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])); }
4739                }
4740            }
4741            }
4742        }
4743        return tiers;
4744
4745    Value::Null
4746}
4747
4748    fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4749        let mut symbols = get_arg(optional_args, 0, Value::Null);
4750        let mut reload = get_arg(optional_args, 1, Value::Bool(false));
4751        let mut params = get_arg(optional_args, 2, Value::Map({
4752    let mut m = indexmap::IndexMap::new();
4753    m
4754}));
4755        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)) {
4756            if is_true(&reload) || !(matches!(&self.options, Value::Dict(__d) if __d.contains_key("limitsLoaded"))) {
4757                let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4758                let mut symbolsArray: Value = self.require_value(symbols, &[Value::Str("loadTradingLimits() requires a symbols argument".into())]);
4759                let mut markets: Value = self.markets.clone();
4760                if (markets == Value::Null) {
4761                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
4762                }
4763                {
4764                                        let mut i: Value = Value::Int(0);
4765                    let mut __for_first_119: bool = true;
4766                    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) < get_array_length(&symbolsArray).as_f64().unwrap_or(f64::NAN) } {
4767                    let mut symbol: Value = get_value(&symbolsArray, &i);
4768                    let mut symbol: Value = get_value(&symbolsArray, &i);
4769                    { let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
4770                }
4771                }
4772                { let __be_tmp = self.milliseconds(); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("limitsLoaded".into(), __be_tmp); } }
4773            }
4774        }
4775        return self.markets.clone();
4776
4777    Value::Null
4778} }
4779
4780    fn safe_position(&self, mut position: Value) -> Value {
4781        // simplified version of: /pull/12765/
4782        let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
4783        let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
4784        //
4785        // PERCENTAGE
4786        //
4787        let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
4788        if (percentage == Value::Null) && (unrealizedPnlString != Value::Null) && (initialMarginString != Value::Null) {
4789            // as it was done in all implementations ( aax, btcex, bybit, deribit, gate, kucoinfutures, phemex )
4790            let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".into()));
4791            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("percentage".into(), self.parse_number(percentageString, &[])); }
4792        }
4793        // if contractSize is undefined get from market
4794        let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
4795        let mut symbol: Value = self.safe_string_k(position.clone(), "symbol", &[]);
4796        let mut market: Value = Value::Null;
4797        if (symbol != Value::Null) {
4798            market = self.safe_value(self.markets.clone(), symbol, &[]);
4799        }
4800        if (contractSize == Value::Null) && (market != Value::Null) {
4801            contractSize = self.safe_number_k(market, "contractSize", &[]);
4802            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), contractSize); }
4803        }
4804        return position;
4805
4806    Value::Null
4807}
4808
4809    fn parse_positions(&self, mut positions: Value, optional_args: &[Value]) -> Value {
4810        let mut symbols = get_arg(optional_args, 0, Value::Null);
4811        let mut params = get_arg(optional_args, 1, Value::Map({
4812    let mut m = indexmap::IndexMap::new();
4813    m
4814}));
4815        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4816        let mut positionsArray: Value = self.to_array(positions);
4817        let mut result: Value = Value::from(vec![]);
4818        {
4819                        let mut i: Value = Value::Int(0);
4820            let mut __for_first_120: bool = true;
4821            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) < ((positionsArray.len() as i64) as f64) } {
4822            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()]);
4823            append_to_array(&mut result, position);
4824        }
4825        }
4826        return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbolsNormalized]);
4827
4828    Value::Null
4829}
4830
4831    fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
4832        // virtual-dispatch (static: DerivedExchange::parse_adl_rank(self, ...))
4833        { 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; } }
4834
4835        let mut market = get_arg(optional_args, 0, Value::Null);
4836        if (info == Value::Null) {
4837            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
4838        }
4839        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
4840
4841    Value::Null
4842}
4843
4844    fn parse_adl_ranks(&self, mut ranks: Value, optional_args: &[Value]) -> Value {
4845        let mut symbols = get_arg(optional_args, 0, Value::Null);
4846        let mut params = get_arg(optional_args, 1, Value::Map({
4847    let mut m = indexmap::IndexMap::new();
4848    m
4849}));
4850        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4851        let mut ranksArray: Value = self.to_array(ranks);
4852        let mut result: Value = Value::from(vec![]);
4853        {
4854                        let mut i: Value = Value::Int(0);
4855            let mut __for_first_121: bool = true;
4856            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) < ((ranksArray.len() as i64) as f64) } {
4857            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()]);
4858            append_to_array(&mut result, rank);
4859        }
4860        }
4861        return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbolsNormalized]);
4862
4863    Value::Null
4864}
4865
4866    fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
4867        let mut params = get_arg(optional_args, 0, Value::Map({
4868    let mut m = indexmap::IndexMap::new();
4869    m
4870}));
4871        let mut accountsArray: Value = self.to_array(accounts);
4872        let mut result: Value = Value::from(vec![]);
4873        {
4874                        let mut i: Value = Value::Int(0);
4875            let mut __for_first_122: bool = true;
4876            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) < ((accountsArray.len() as i64) as f64) } {
4877            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()]);
4878            append_to_array(&mut result, account);
4879        }
4880        }
4881        return result;
4882
4883    Value::Null
4884}
4885
4886    fn parse_trades_helper(&self, mut isWs: Value, mut trades: Value, optional_args: &[Value]) -> Value {
4887        let mut market = get_arg(optional_args, 0, Value::Null);
4888        let mut since = get_arg(optional_args, 1, Value::Null);
4889        let mut limit = get_arg(optional_args, 2, Value::Null);
4890        let mut params = get_arg(optional_args, 3, Value::Map({
4891    let mut m = indexmap::IndexMap::new();
4892    m
4893}));
4894        let mut tradesArray: Value = self.to_array(trades);
4895        let mut result: Value = Value::from(vec![]);
4896        {
4897                        let mut i: Value = Value::Int(0);
4898            let mut __for_first_123: bool = true;
4899            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) < ((tradesArray.len() as i64) as f64) } {
4900            let mut parsed: Value = Value::Null;
4901            if is_true(&isWs) {
4902                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()]);
4903            }  else {
4904                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()]);
4905            }
4906            let mut trade: Value = self.extend(parsed, &[params.clone()]);
4907            append_to_array(&mut result, trade);
4908        }
4909        }
4910        result = self.sort_by2(result.clone(), Value::Str("timestamp".into()), Value::Str("id".into()), &[]);
4911        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
4912        return self.filter_by_symbol_since_limit(result, &[symbol, since, limit]);
4913
4914    Value::Null
4915}
4916
4917    fn parse_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4918        let mut market = get_arg(optional_args, 0, Value::Null);
4919        let mut since = get_arg(optional_args, 1, Value::Null);
4920        let mut limit = get_arg(optional_args, 2, Value::Null);
4921        let mut params = get_arg(optional_args, 3, Value::Map({
4922    let mut m = indexmap::IndexMap::new();
4923    m
4924}));
4925        return self.parse_trades_helper(Value::Bool(false), trades, &[market, since, limit, params]);
4926
4927    Value::Null
4928}
4929
4930    fn parse_ws_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4931        let mut market = get_arg(optional_args, 0, Value::Null);
4932        let mut since = get_arg(optional_args, 1, Value::Null);
4933        let mut limit = get_arg(optional_args, 2, Value::Null);
4934        let mut params = get_arg(optional_args, 3, Value::Map({
4935    let mut m = indexmap::IndexMap::new();
4936    m
4937}));
4938        return self.parse_trades_helper(Value::Bool(true), trades, &[market, since, limit, params]);
4939
4940    Value::Null
4941}
4942
4943    fn parse_transactions(&self, mut transactions: 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 transactionsArray: Value = self.to_array(transactions);
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) < ((transactionsArray.len() as i64) as f64) } {
4957            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()]);
4958            append_to_array(&mut result, transaction);
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_transfers(&self, mut transfers: 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 transfersArray: Value = self.to_array(transfers);
4977        let mut result: Value = Value::from(vec![]);
4978        {
4979                        let mut i: Value = Value::Int(0);
4980            let mut __for_first_125: bool = true;
4981            while { if !__for_first_125 { 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_125 = false; i.as_f64().unwrap_or(f64::NAN) < ((transfersArray.len() as i64) as f64) } {
4982            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()]);
4983            append_to_array(&mut result, transfer);
4984        }
4985        }
4986        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
4987        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 });
4988        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
4989
4990    Value::Null
4991}
4992
4993    fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
4994        let mut currency = get_arg(optional_args, 0, Value::Null);
4995        let mut since = get_arg(optional_args, 1, Value::Null);
4996        let mut limit = get_arg(optional_args, 2, Value::Null);
4997        let mut params = get_arg(optional_args, 3, Value::Map({
4998    let mut m = indexmap::IndexMap::new();
4999    m
5000}));
5001        let mut result: Value = Value::from(vec![]);
5002        let mut arrayData: Value = self.to_array(data);
5003        {
5004                        let mut i: Value = Value::Int(0);
5005            let mut __for_first_127: bool = true;
5006            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) < ((arrayData.len() as i64) as f64) } {
5007            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()]);
5008            if (matches!(&itemOrItems, Value::Arr(_))) {
5009                {
5010                                        let mut j: Value = Value::Int(0);
5011                    let mut __for_first_126: bool = true;
5012                    while { if !__for_first_126 { 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_126 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&itemOrItems).as_f64().unwrap_or(f64::NAN) } {
5013                    append_to_array(&mut result, self.extend(get_value(&itemOrItems, &j), &[params.clone()]));
5014                }
5015                }
5016            }  else {
5017                append_to_array(&mut result, self.extend(itemOrItems, &[params.clone()]));
5018            }
5019        }
5020        }
5021        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5022        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 });
5023        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5024
5025    Value::Null
5026}
5027
5028    fn nonce(&self) -> Value {
5029        // virtual-dispatch (static: DerivedExchange::nonce(self, ...))
5030        { let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
5031
5032        return self.seconds();
5033
5034    Value::Null
5035}
5036
5037/*
5038 * @method
5039 * @ignore
5040 * @name Exchange#incrementingNonce
5041 * @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.
5042 * @returns {int} a strictly-increasing nonce in the unit returned by nonce ()
5043 */
5044    fn incrementing_nonce(&mut self) -> Value {
5045        let mut currentNonce: Value = <Self as crate::exchange_generated::ExchangeBase>::nonce(self, );
5046        self.lock_last_nonce(&[]);
5047        let mut lastNonce: Value = self.safe_integer_k(self.options.clone(), "lastNonce", &[Value::Int(0)]);
5048        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 }) });
5049        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("lastNonce".into(), result.clone()); }
5050        self.unlock_last_nonce(&[]);
5051        return result;
5052
5053    Value::Null
5054}
5055
5056    fn set_headers(&self, mut headers: Value) -> Value {
5057        return headers;
5058
5059    Value::Null
5060}
5061
5062    fn currency_id(&self, mut code: Value) -> Value {
5063        if (code == Value::Null) {
5064            return code;
5065        }
5066        let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5067        if (currency == Value::Null) {
5068            currency = self.safe_currency(code.clone(), &[]);
5069        }
5070        if (currency != Value::Null) {
5071            return currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5072        }
5073        return code;
5074
5075    Value::Null
5076}
5077
5078    fn market_id(&self, mut symbol: Value) -> Value {
5079        let mut market: Value = self.market(symbol.clone());
5080        if (market != Value::Null) {
5081            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5082        }
5083        return symbol;
5084
5085    Value::Null
5086}
5087
5088    fn symbol(&self, mut symbol: Value) -> Value {
5089        if (symbol == Value::Null) {
5090            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" symbol() requires a symbol argument".into()))));
5091        }
5092        let mut market: Value = self.market(symbol.clone());
5093        return self.safe_string_k(market, "symbol", &[symbol]);
5094
5095    Value::Null
5096}
5097
5098/* eslint-disable no-unused-vars */
5099/* eslint-enable no-unused-vars */
5100    fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5101        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5102        let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue]);
5103        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5104        return Value::from(vec![value, paramsOmitted]);
5105
5106    Value::Null
5107}
5108
5109/* eslint-disable no-unused-vars */
5110/* eslint-enable no-unused-vars */
5111    fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5112        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5113        let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5114        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5115        return Value::from(vec![value, paramsOmitted]);
5116
5117    Value::Null
5118}
5119
5120    fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5121        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5122        let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue]);
5123        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5124        return Value::from(vec![value, paramsOmitted]);
5125
5126    Value::Null
5127}
5128
5129    fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5130        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5131        let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5132        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5133        return Value::from(vec![value, paramsOmitted]);
5134
5135    Value::Null
5136}
5137
5138    fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5139        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5140        let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue]);
5141        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5142        return Value::from(vec![value, paramsOmitted]);
5143
5144    Value::Null
5145}
5146
5147    fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5148        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5149        let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5150        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5151        return Value::from(vec![value, paramsOmitted]);
5152
5153    Value::Null
5154}
5155
5156/*
5157 * @param {object} params - extra parameters
5158 * @param {object} request - existing dictionary of request
5159 * @param {string} exchangeSpecificKey - the key for chain id to be set in request
5160 * @param {object} currencyCode - (optional) existing dictionary of request
5161 * @param {boolean} isRequired - (optional) whether that param is required to be present
5162 * @returns {object[]} - returns [request, params] where request is the modified request object and params is the modified params object
5163 */
5164    fn handle_request_network(&self, mut params: Value, mut request: Value, mut exchangeSpecificKey: Value, optional_args: &[Value]) -> Value {
5165        let mut currencyCode = get_arg(optional_args, 0, Value::Null);
5166        let mut isRequired = get_arg(optional_args, 1, Value::Bool(false));
5167        let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(params);
5168        let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5169        let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5170        if (networkCode != Value::Null) {
5171            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])); }
5172        }  else if is_true(&isRequired) {
5173            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" - \"network\" param is required for this request".into()))));
5174        }
5175        return Value::from(vec![request, paramsNetworkCode]);
5176
5177    Value::Null
5178}
5179
5180    fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5181        return Value::from(vec![self.implode_params(path.clone(), params.clone()), self.omit(params, self.extract_params(path), &[])]);
5182
5183    Value::Null
5184}
5185
5186    fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5187        let mut newArray: Value = objects.clone();
5188        if !(matches!(&objects, Value::Arr(_))) {
5189            newArray = self.to_array(objects.clone());
5190        }
5191        let mut results: Value = Value::from(vec![]);
5192        {
5193                        let mut i: Value = Value::Int(0);
5194            let mut __for_first_128: bool = true;
5195            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(&newArray).as_f64().unwrap_or(f64::NAN) } {
5196            append_to_array(&mut results, get_value(&get_value(&newArray, &i), &key));
5197        }
5198        }
5199        return results;
5200
5201    Value::Null
5202}
5203
5204    fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5205        let mut marketType = get_arg(optional_args, 0, Value::Null);
5206        let mut subType = get_arg(optional_args, 1, Value::Null);
5207        let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5208        let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5209        let mut filteredMarkets: Value = self.markets.clone();
5210        if (marketType != Value::Null) {
5211            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".into()), marketType, &[]);
5212        }
5213        if (subType != Value::Null) {
5214            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())])]);
5215            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".into()), subType, &[]);
5216        }
5217        let mut activeStatuses: Value = Value::from(vec![]);
5218        if is_true(&symbolWithActiveStatus) {
5219            append_to_array(&mut activeStatuses, Value::Bool(true));
5220        }
5221        if is_true(&symbolWithUnknownStatus) {
5222            append_to_array(&mut activeStatuses, Value::Null);
5223        }
5224        filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".into()), &[activeStatuses, Value::Bool(false)]);
5225        return self.get_list_from_object_values(filteredMarkets, Value::Str("symbol".into()));
5226
5227    Value::Null
5228}
5229
5230    fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5231        let mut values = get_arg(optional_args, 0, Value::Null);
5232        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5233        let mut objectsValue: Value = self.to_array(objects);
5234        // return all of them if no values were passed
5235        if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5236            // return indexed ? this.indexBy (objects, key) : objects;
5237            if is_true(&indexed) {
5238                return self.index_by(objectsValue.clone(), key.clone());
5239            }  else {
5240                return objectsValue;
5241            }
5242        }
5243        let mut results: Value = Value::from(vec![]);
5244        {
5245                        let mut i: Value = Value::Int(0);
5246            let mut __for_first_129: bool = true;
5247            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(&objectsValue).as_f64().unwrap_or(f64::NAN) } {
5248            if self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true) {
5249                append_to_array(&mut results, get_value(&objectsValue, &i));
5250            }
5251        }
5252        }
5253        // return indexed ? this.indexBy (results, key) : results;
5254        if is_true(&indexed) {
5255            return self.index_by(results.clone(), key);
5256        }
5257        return results;
5258
5259    Value::Null
5260}
5261
5262    fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5263        let mut values = get_arg(optional_args, 0, Value::Null);
5264        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5265        let mut objectsValue: Value = self.to_array(objects);
5266        // return all of them if no values were passed
5267        if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5268            // return indexed ? this.indexBy (objects, key) : objects;
5269            if is_true(&indexed) {
5270                return self.index_by(objectsValue.clone(), key.clone());
5271            }  else {
5272                return objectsValue;
5273            }
5274        }
5275        let mut results: Value = Value::from(vec![]);
5276        {
5277                        let mut i: Value = Value::Int(0);
5278            let mut __for_first_130: bool = true;
5279            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) < get_array_length(&objectsValue).as_f64().unwrap_or(f64::NAN) } {
5280            if !(self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true)) {
5281                append_to_array(&mut results, get_value(&objectsValue, &i));
5282            }
5283        }
5284        }
5285        // return indexed ? this.indexBy (results, key) : results;
5286        if is_true(&indexed) {
5287            return self.index_by(results.clone(), key);
5288        }
5289        return results;
5290
5291    Value::Null
5292}
5293
5294    fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5295        let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
5296        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5297        let mut params = get_arg(optional_args, 2, Value::Map({
5298    let mut m = indexmap::IndexMap::new();
5299    m
5300}));
5301        let mut headers = get_arg(optional_args, 3, Value::Null);
5302        let mut body = get_arg(optional_args, 4, Value::Null);
5303        let mut config = get_arg(optional_args, 5, Value::Map({
5304    let mut m = indexmap::IndexMap::new();
5305    m
5306}));
5307        if is_true(&self.enableRateLimit) {
5308            let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config]);
5309            self.throttle(&[cost]).await;
5310        }
5311        let mut retries: Value = Value::Int(0);
5312        // implicit endpoints may pass a list body as params: keep it an untyped box
5313        let mut requestParams: Value = params;
5314        let mut retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable = self.handle_option_integer_and_params(requestParams, path.clone(), Value::Str("maxRetriesOnFailure".into()), &[retries]);
5315        let mut retriesMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5316        let mut paramsMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5317        let mut retryDelay: Value = Value::Int(0);
5318        let mut retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable = self.handle_option_integer_and_params(paramsMaxRetriesOnFailure, path.clone(), Value::Str("maxRetriesOnFailureDelay".into()), &[retryDelay]);
5319        let mut retryDelayMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5320        let mut paramsMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5321        let mut fetchDataCacheEnabled: bool = self.fetchHistoryCacheSize.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64);
5322        {
5323                        let mut i: Value = Value::Int(0);
5324            let mut __for_first_131: bool = true;
5325            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) < add(&retriesMaxRetriesOnFailure, &Value::Int(1)).as_f64().unwrap_or(f64::NAN) } {
5326            let mut fetchData: Value = Value::Null;
5327            if fetchDataCacheEnabled {
5328                fetchData = Value::Map({
5329                    let mut m = indexmap::IndexMap::new();
5330                        m.insert("request".to_string(), Value::Null);
5331                        m.insert("response".to_string(), Value::Map({
5332    let mut m = indexmap::IndexMap::new();
5333        m.insert("body".to_string(), Value::Null);
5334    m
5335}));
5336                        m.insert("error".to_string(), Value::Null);
5337                    m
5338                });
5339            }
5340            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5341                self.set_last_rest_request_timestamp();
5342                let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), paramsMaxRetriesOnFailureDelay.clone(), headers.clone(), body.clone()]);
5343                if (fetchData != Value::Null) {
5344                    add_element_to_object(&mut fetchData, &Value::Str("request".into()), request.clone());
5345                }
5346                self.set_last_request(request.clone());
5347                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;
5348                if (fetchData != Value::Null) {
5349                    add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".into())), &Value::Str("body".into()), response.clone());
5350                    self.add_fetch_cache(fetchData.clone());
5351                }
5352                return response;
5353             #[allow(unreachable_code)] { Value::Null }})).await;
5354match _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); 
5355                if (fetchData != Value::Null) {
5356                    add_element_to_object(&mut fetchData, &Value::Str("error".into()), e.clone());
5357                    self.add_fetch_cache(fetchData);
5358                }
5359                if is_instance(&e, &Value::Str("OperationFailed".into())) {
5360                    if i.as_f64().unwrap_or(f64::NAN) < retriesMaxRetriesOnFailure.as_f64().unwrap_or(f64::NAN) {
5361                        if is_true(&self.verbose) {
5362                            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 });
5363                            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(&retriesMaxRetriesOnFailure)).into()), Value::Str("...".into())).into()));
5364                        }
5365                        if (retryDelayMaxRetriesOnFailureDelay != Value::Null) && (retryDelayMaxRetriesOnFailureDelay.as_f64() != Some(0.0)) {
5366                            self.sleep(retryDelayMaxRetriesOnFailureDelay.clone()).await;
5367                        }
5368                    }  else {
5369                        panic!("{}", e);
5370                    }
5371                }  else {
5372                    panic!("{}", e);
5373                }
5374             } }
5375        }
5376        }
5377        return Value::Null;
5378
5379    Value::Null
5380} }
5381
5382    fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5383        let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
5384        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5385        let mut params = get_arg(optional_args, 2, Value::Map({
5386    let mut m = indexmap::IndexMap::new();
5387    m
5388}));
5389        let mut headers = get_arg(optional_args, 3, Value::Null);
5390        let mut body = get_arg(optional_args, 4, Value::Null);
5391        let mut config = get_arg(optional_args, 5, Value::Map({
5392    let mut m = indexmap::IndexMap::new();
5393    m
5394}));
5395        return self.fetch2(path, &[api, method, params, headers, body, config]).await;
5396
5397    Value::Null
5398} }
5399
5400    fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5401        let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5402        let mut params = get_arg(optional_args, 1, Value::Map({
5403    let mut m = indexmap::IndexMap::new();
5404    m
5405}));
5406        if is_true(&reload) {
5407            { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5408        }  else {
5409            if (self.accounts.clone() != Value::Null) {
5410                return self.accounts.clone();
5411            }  else {
5412                { let __t = self.fetch_accounts(&[params]).await; self.accounts = __t; }
5413            }
5414        }
5415        { let __t = self.index_by(self.accounts.clone(), Value::Str("id".into())); self.accountsById = __t; }
5416        return self.accounts.clone();
5417
5418    Value::Null
5419} }
5420
5421    fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5422        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
5423        let mut since = get_arg(optional_args, 1, Value::Int(0));
5424        let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5425        // given a sorted arrays of trades (recent last) and a timeframe builds an array of OHLCV candles
5426        // note, default limit value (2147483647) is max int32 value
5427        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 });
5428        let mut ohlcvs: Value = Value::from(vec![]);
5429        let mut i_timestamp: Value = Value::Int(0);
5430        // const open = 1;
5431        let mut i_high: Value = Value::Int(2);
5432        let mut i_low: Value = Value::Int(3);
5433        let mut i_close: Value = Value::Int(4);
5434        let mut i_volume: Value = Value::Int(5);
5435        let mut i_count: Value = Value::Int(6);
5436        let mut tradesLength: Value = Value::Int(trades.len() as i64);
5437        let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5438        let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5439    let mut m = indexmap::IndexMap::new();
5440    m
5441})]);
5442        let mut skipZeroPrices: Value = self.safe_bool_k(options, "skipZeroPrices", &[Value::Bool(true)]);
5443        {
5444                        let mut i: Value = Value::Int(0);
5445            let mut __for_first_132: bool = true;
5446            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) < oldest.as_f64().unwrap_or(f64::NAN) } {
5447            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);
5448            let mut ts: Value = trade.as_map().and_then(|__m| __m.get("timestamp")).cloned().unwrap_or(Value::Null);
5449            let mut price: Value = trade.as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null);
5450            if (ts == Value::Null) || (price == Value::Null) {
5451                continue;
5452            }
5453            if ts.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5454                continue;
5455            }
5456            if (ts == Value::Null) {
5457                panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing ts".into()))));
5458            }
5459            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)
5460            if openingTime.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5461                continue;
5462            }
5463            let mut ohlcv_length: Value = Value::Int(ohlcvs.len() as i64);
5464            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 });
5465            if (price == Value::Null) {
5466                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() requires a price argument".into()))));
5467            }
5468            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)) {
5469                continue;
5470            }
5471            let mut isNewCandle: bool = candle.as_f64() == Value::Int(-1).as_f64();
5472            if !isNewCandle {
5473                let mut candleTimestamp: Value = 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);
5474                if (candleTimestamp == Value::Null) {
5475                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing candle timestamp".into()))));
5476                }
5477                isNewCandle = openingTime.as_f64().unwrap_or(f64::NAN) >= (match (&(candleTimestamp), &(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 }).as_f64().unwrap_or(f64::NAN);
5478            }
5479            if isNewCandle {
5480                // moved to a new timeframe -> create a new candle from opening trade
5481                append_to_array(&mut ohlcvs, Value::from(vec![openingTime, 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)]));
5482            }  else {
5483                // still processing the same timeframe -> update opening trade
5484                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);
5485                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);
5486                let mut prevHighValue: Value = (if (prevHigh == Value::Null) { price.clone() } else { prevHigh });
5487                let mut prevLowValue: Value = (if (prevLow == Value::Null) { price.clone() } else { prevLow });
5488                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
5489                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
5490                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price);
5491                { 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); };
5492                { 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); };
5493            }
5494        }
5495        }
5496        return ohlcvs;
5497
5498    Value::Null
5499}
5500
5501    fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5502        let mut market = get_arg(optional_args, 0, Value::Null);
5503        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
5504        let mut since = get_arg(optional_args, 2, Value::Null);
5505        let mut limit = get_arg(optional_args, 3, Value::Null);
5506        let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs, &[]);
5507        return self.parse_ohlc_vs(result, &[market, timeframe, since, limit]);
5508
5509    Value::Null
5510}
5511
5512    fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5513        let mut code = get_arg(optional_args, 0, Value::Null);
5514        let mut symbol = get_arg(optional_args, 1, Value::Null);
5515        let mut since = get_arg(optional_args, 2, Value::Null);
5516        let mut limit = get_arg(optional_args, 3, Value::Null);
5517        let mut params = get_arg(optional_args, 4, Value::Map({
5518    let mut m = indexmap::IndexMap::new();
5519    m
5520}));
5521        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowInterest() is not supported yet".into()))));
5522
5523    Value::Null
5524} }
5525
5526    fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5527        // async-virtual: try the derived exchange first
5528        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 {
5529            if !matches!(__v, crate::Value::Null) { return __v; }
5530        }
5531
5532        let mut code = get_arg(optional_args, 0, Value::Null);
5533        let mut since = get_arg(optional_args, 1, Value::Null);
5534        let mut limit = get_arg(optional_args, 2, Value::Null);
5535        let mut params = get_arg(optional_args, 3, Value::Map({
5536    let mut m = indexmap::IndexMap::new();
5537    m
5538}));
5539        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedger() is not supported yet".into()))));
5540
5541    Value::Null
5542} }
5543
5544    fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5545        let mut code = get_arg(optional_args, 0, Value::Null);
5546        let mut params = get_arg(optional_args, 1, Value::Map({
5547    let mut m = indexmap::IndexMap::new();
5548    m
5549}));
5550        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedgerEntry() is not supported yet".into()))));
5551
5552    Value::Null
5553} }
5554
5555    fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5556        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5557        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5558        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5559        let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5560        let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5561        let mut countOrId: Value = self.safe_integer(bidask, countOrIdKey, &[]);
5562        let mut bidAsk: Value = Value::from(vec![price, amount]);
5563        if (countOrId != Value::Null) {
5564            append_to_array(&mut bidAsk, countOrId);
5565        }
5566        return bidAsk;
5567
5568    Value::Null
5569}
5570
5571    fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5572        let mut currency = get_arg(optional_args, 0, Value::Null);
5573        if (currencyId == Value::Null) && (currency != Value::Null) {
5574            return currency;
5575        }
5576        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) {
5577            return get_value(&self.currencies_by_id, &currencyId);
5578        }
5579        let mut code: Value = currencyId.clone();
5580        if (currencyId != Value::Null) {
5581            code = self.common_currency_code(to_upper(&currencyId));
5582        }
5583        return self.safe_currency_structure(Value::Map({
5584    let mut m = indexmap::IndexMap::new();
5585        m.insert("id".to_string(), currencyId);
5586        m.insert("code".to_string(), code);
5587        m.insert("precision".to_string(), Value::Null);
5588    m
5589}));
5590
5591    Value::Null
5592}
5593
5594    fn safe_market(&self, optional_args: &[Value]) -> Value {
5595        let mut marketId = get_arg(optional_args, 0, Value::Null);
5596        let mut market = get_arg(optional_args, 1, Value::Null);
5597        let mut delimiter = get_arg(optional_args, 2, Value::Null);
5598        let mut marketType = get_arg(optional_args, 3, Value::Null);
5599        if (marketId != Value::Null) {
5600            if (self.markets_by_id.clone() != Value::Null) && (in_op(&self.markets_by_id, &marketId)) {
5601                let mut markets: Value = get_value(&self.markets_by_id, &marketId);
5602                let mut numMarkets: Value = get_array_length(&markets);
5603                if is_equal(&numMarkets, &Value::Int(1)) {
5604                    return get_value(&markets, &Value::Int(0));
5605                }  else {
5606                    if (marketType == Value::Null) && (market == Value::Null) {
5607                        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()))));
5608                    }
5609                    let mut marketTypeResolved: Value = (if (marketType == Value::Null) { self.safe_string_k(market.clone(), "type", &[Value::Str("".into())]) } else { marketType });
5610                    {
5611                                                let mut i: Value = Value::Int(0);
5612                        let mut __for_first_133: bool = true;
5613                        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) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
5614                        let mut currentMarket: Value = get_value(&markets, &i);
5615                        let mut currentMarket: Value = get_value(&markets, &i);
5616                        if is_equal(&get_value(&currentMarket, &marketTypeResolved), &Value::Bool(true)) {
5617                            return currentMarket;
5618                        }
5619                    }
5620                    }
5621                }
5622            }  else if (delimiter != Value::Null) && (delimiter.as_str() != Some("")) {
5623                let mut parts: Value = split(&marketId, &delimiter);
5624                let mut partsLength: f64 = ((parts.len() as i64) as f64);
5625                let mut result: Value = self.safe_market_structure(&[Value::Map({
5626    let mut m = indexmap::IndexMap::new();
5627        m.insert("symbol".to_string(), marketId.clone());
5628        m.insert("marketId".to_string(), marketId.clone());
5629    m
5630})]);
5631                if (result == Value::Null) {
5632                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5633                }
5634                if (partsLength == 2.0) {
5635                    let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
5636                    let mut quoteId: Value = self.safe_string(parts, Value::Int(1), &[]);
5637                    let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
5638                    let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
5639                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("baseId".into(), baseId); }
5640                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quoteId); }
5641                    if (base != Value::Null) {
5642                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("base".into(), base.clone()); }
5643                    }
5644                    if (quote != Value::Null) {
5645                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quote".into(), quote.clone()); }
5646                    }
5647                    if (base != Value::Null) && (quote != Value::Null) {
5648                        add_element_to_object(&mut result, &Value::Str("symbol".into()), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
5649                    }
5650                }
5651                return result;
5652            }
5653        }
5654        if (market != Value::Null) {
5655            return market;
5656        }
5657        let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5658    let mut m = indexmap::IndexMap::new();
5659        m.insert("symbol".to_string(), marketId.clone());
5660        m.insert("marketId".to_string(), marketId);
5661    m
5662})]);
5663        if (emptyMarket == Value::Null) {
5664            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5665        }
5666        return emptyMarket;
5667
5668    Value::Null
5669}
5670
5671    fn market_or_null(&self, optional_args: &[Value]) -> Value {
5672        let mut symbol = get_arg(optional_args, 0, Value::Null);
5673        if (symbol == Value::Null) {
5674            return Value::Null;
5675        }
5676        return self.market(symbol);
5677
5678    Value::Null
5679}
5680
5681    fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5682        let mut error = get_arg(optional_args, 0, Value::Bool(true));
5683        /*
5684         * @ignore
5685         * @method
5686         * @param {boolean} error throw an error that a credential is required if true
5687         * @returns {boolean} true if all required credentials have been set, otherwise false or an error is thrown is param error=true
5688         */
5689        let mut keys: Value = object_keys(&self.requiredCredentials);
5690        {
5691                        let mut i: Value = Value::Int(0);
5692            let mut __for_first_134: bool = true;
5693            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) } {
5694            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);
5695            let mut credentialValue: Value = self.prop(&key);
5696            let mut credentialMissing: bool = (credentialValue == Value::Null) || (credentialValue == Value::Null) || (is_equal(&credentialValue, &Value::Bool(false))) || (credentialValue.as_str() == Some(""));
5697            if (get_value(&self.requiredCredentials, &key).as_bool() == Some(true)) && credentialMissing {
5698                if is_true(&error) {
5699                    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()))));
5700                }  else {
5701                    return Value::Bool(false);
5702                }
5703            }
5704        }
5705        }
5706        return Value::Bool(true);
5707
5708    Value::Null
5709}
5710
5711    fn oath(&self) -> Value {
5712        if (self.twofa.clone() != Value::Null) {
5713            return totp(self.twofa.clone());
5714        }  else {
5715            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".into()))));
5716        }
5717
5718    Value::Null
5719}
5720
5721    fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5722        // async-virtual: try the derived exchange first
5723        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 {
5724            if !matches!(__v, crate::Value::Null) { return __v; }
5725        }
5726
5727        let mut params = get_arg(optional_args, 0, Value::Map({
5728    let mut m = indexmap::IndexMap::new();
5729    m
5730}));
5731        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalance() is not supported yet".into()))));
5732
5733    Value::Null
5734} }
5735
5736    fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5737        let mut params = get_arg(optional_args, 0, Value::Map({
5738    let mut m = indexmap::IndexMap::new();
5739    m
5740}));
5741        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalanceWs() is not supported yet".into()))));
5742
5743    Value::Null
5744} }
5745
5746    fn parse_balance(&self, mut response: Value) -> Value {
5747        // virtual-dispatch (static: DerivedExchange::parse_balance(self, ...))
5748        { let __v = crate::exchange::DerivedExchange::parse_balance(self, response); if !matches!(__v, crate::Value::Null) { return __v; } }
5749
5750        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBalance() is not supported yet".into()))));
5751
5752    Value::Null
5753}
5754
5755    fn watch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5756        let mut params = get_arg(optional_args, 0, Value::Map({
5757    let mut m = indexmap::IndexMap::new();
5758    m
5759}));
5760        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBalance() is not supported yet".into()))));
5761
5762    Value::Null
5763} }
5764
5765    fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5766        let mut params = get_arg(optional_args, 0, Value::Map({
5767    let mut m = indexmap::IndexMap::new();
5768    m
5769}));
5770        let mut balance: Value = self.fetch_balance(&[params]).await;
5771        return get_value(&balance, &part);
5772
5773    Value::Null
5774} }
5775
5776    fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5777        let mut params = get_arg(optional_args, 0, Value::Map({
5778    let mut m = indexmap::IndexMap::new();
5779    m
5780}));
5781        return self.fetch_partial_balance(Value::Str("free".into()), &[params]).await;
5782
5783    Value::Null
5784} }
5785
5786    fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5787        let mut params = get_arg(optional_args, 0, Value::Map({
5788    let mut m = indexmap::IndexMap::new();
5789    m
5790}));
5791        return self.fetch_partial_balance(Value::Str("used".into()), &[params]).await;
5792
5793    Value::Null
5794} }
5795
5796    fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5797        let mut params = get_arg(optional_args, 0, Value::Map({
5798    let mut m = indexmap::IndexMap::new();
5799    m
5800}));
5801        return self.fetch_partial_balance(Value::Str("total".into()), &[params]).await;
5802
5803    Value::Null
5804} }
5805
5806    fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5807        // async-virtual: try the derived exchange first
5808        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 {
5809            if !matches!(__v, crate::Value::Null) { return __v; }
5810        }
5811
5812        let mut params = get_arg(optional_args, 0, 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(" fetchStatus() is not supported yet".into()))));
5817
5818    Value::Null
5819} }
5820
5821    fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5822        let mut params = get_arg(optional_args, 0, Value::Map({
5823    let mut m = indexmap::IndexMap::new();
5824    m
5825}));
5826        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)) {
5827            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFee() is not supported yet".into()))));
5828        }
5829        return self.fetch_transaction_fees(&[Value::from(vec![code]), params]).await;
5830
5831    Value::Null
5832} }
5833
5834    fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5835        let mut codes = get_arg(optional_args, 0, Value::Null);
5836        let mut params = get_arg(optional_args, 1, Value::Map({
5837    let mut m = indexmap::IndexMap::new();
5838    m
5839}));
5840        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFees() is not supported yet".into()))));
5841
5842    Value::Null
5843} }
5844
5845    fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5846        // async-virtual: try the derived exchange first
5847        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 {
5848            if !matches!(__v, crate::Value::Null) { return __v; }
5849        }
5850
5851        let mut codes = get_arg(optional_args, 0, Value::Null);
5852        let mut params = get_arg(optional_args, 1, Value::Map({
5853    let mut m = indexmap::IndexMap::new();
5854    m
5855}));
5856        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFees() is not supported yet".into()))));
5857
5858    Value::Null
5859} }
5860
5861    fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5862        // async-virtual: try the derived exchange first
5863        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 {
5864            if !matches!(__v, crate::Value::Null) { return __v; }
5865        }
5866
5867        let mut params = get_arg(optional_args, 0, Value::Map({
5868    let mut m = indexmap::IndexMap::new();
5869    m
5870}));
5871        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)) {
5872            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFee() is not supported yet".into()))));
5873        }
5874        let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::from(vec![code.clone()]), params]).await;
5875        return self.safe_value(fees, code, &[]);
5876
5877    Value::Null
5878} }
5879
5880    fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
5881        let mut mapping = get_arg(optional_args, 0, Value::Map({
5882    let mut m = indexmap::IndexMap::new();
5883    m
5884}));
5885        if (key == Value::Null) {
5886            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" getSupportedMapping() requires a key argument".into()))));
5887        }
5888        if (in_op(&mapping, &key)) {
5889            return mapping.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
5890        }  else {
5891            let mut keys: Value = object_keys(&mapping);
5892            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), key).into()), Value::Str(" does not have a value in mapping".into())).into()), Value::Str(", must be one of ".into())).into()), join(&keys, &Value::Str(", ".into())))));
5893        }
5894
5895    Value::Null
5896}
5897
5898    fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5899        let mut params = get_arg(optional_args, 0, Value::Map({
5900    let mut m = indexmap::IndexMap::new();
5901    m
5902}));
5903        self.load_markets(&[]).await;
5904        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)) {
5905            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() is not supported yet".into()))));
5906        }
5907        let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params]).await;
5908        let mut rate: Value = self.safe_dict(borrowRates, code.clone(), &[]);
5909        if (rate == Value::Null) {
5910            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)));
5911        }
5912        return rate;
5913
5914    Value::Null
5915} }
5916
5917    fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5918        let mut params = get_arg(optional_args, 0, Value::Map({
5919    let mut m = indexmap::IndexMap::new();
5920    m
5921}));
5922        self.load_markets(&[]).await;
5923        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)) {
5924            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() is not supported yet".into()))));
5925        }
5926        let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params]).await;
5927        let mut rate: Value = self.safe_dict(borrowRates, symbol.clone(), &[]);
5928        if (rate == Value::Null) {
5929            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)));
5930        }
5931        return rate;
5932
5933    Value::Null
5934} }
5935
5936/* eslint-disable no-unused-vars */
5937/* eslint-enable no-unused-vars */
5938    fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
5939        let mut message = get_arg(optional_args, 0, Value::Null);
5940        if (value == Value::Null) {
5941            let mut errorMessage: Value = (if (message != Value::Null) { message } else { Value::Str("value is required".into()) });
5942            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), errorMessage)));
5943        }
5944        return value;
5945
5946    Value::Null
5947}
5948
5949/* eslint-disable no-unused-vars */
5950/* eslint-enable no-unused-vars */
5951    fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5952        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5953        // This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
5954        let mut defaultOptionName: Value = Value::Str(format!("{}{}", Value::Str("default".into()), self.capitalize(optionName.clone())).into()); // we also need to check the 'defaultXyzWhatever'
5955        // check if params contain the key
5956        let mut value: Value = self.safe_value2(params.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
5957        if (value != Value::Null) {
5958            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
5959            return Value::from(vec![value.clone(), paramsOmitted]);
5960        }  else {
5961            // handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
5962            let mut callerMethodNameparamsCallerMethodNameVariable = self.handle_param_string(params, Value::Str("callerMethodName".into()), &[methodName]);
5963            let mut callerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5964            let mut paramsCallerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5965            // check if exchange has properties for this method
5966            let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), callerMethodName, &[]);
5967            if (exchangeWideMethodOptions != Value::Null) {
5968                // check if the option is defined inside this method's props
5969                value = self.safe_value2(exchangeWideMethodOptions, optionName.clone(), defaultOptionName.clone(), &[]);
5970            }
5971            if (value == Value::Null) {
5972                // if it's still undefined, check if global exchange-wide option exists
5973                value = self.safe_value2(self.options.clone(), optionName, defaultOptionName, &[]);
5974            }
5975            // if it's still undefined, use the default value
5976            value = (if (value != Value::Null) { value.clone() } else { defaultValue });
5977            return Value::from(vec![value, paramsCallerMethodName]);
5978        }
5979
5980    Value::Null
5981}
5982
5983/* eslint-disable no-unused-vars */
5984/* eslint-enable no-unused-vars */
5985    fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
5986        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5987        let mut valueparamsOption1Variable = self.handle_option_and_params(params, methodName1.clone(), optionName1, &[]);
5988        let mut value: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5989        let mut paramsOption1: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5990        if (value != Value::Null) {
5991            // omit optionName2 too from params
5992            let mut paramsOmitted: Value = self.omit(paramsOption1.clone(), optionName2.clone(), &[]);
5993            return Value::from(vec![value, paramsOmitted]);
5994        }
5995        return self.handle_option_and_params(paramsOption1, methodName1, optionName2, &[defaultValue]);
5996
5997    Value::Null
5998}
5999
6000/* eslint-disable no-unused-vars */
6001/* eslint-enable no-unused-vars */
6002    fn handle_option_string_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6003        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6004        // handleOptionAndParams read as a string; the statically typed ports throw on another type
6005        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6006        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6007        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6008        return Value::from(vec![self.check_option_string(methodName, optionName, value), newParams]);
6009
6010    Value::Null
6011}
6012
6013/* eslint-disable no-unused-vars */
6014/* eslint-enable no-unused-vars */
6015    fn handle_option_string_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6016        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6017        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6018        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6019        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6020        return Value::from(vec![self.check_option_string(methodName, optionName1, value), newParams]);
6021
6022    Value::Null
6023}
6024
6025/* eslint-disable no-unused-vars */
6026/* eslint-enable no-unused-vars */
6027    fn handle_option_bool_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6028        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6029        // handleOptionAndParams read as a boolean; the statically typed ports throw on another type
6030        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6031        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6032        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6033        return Value::from(vec![self.check_option_bool(methodName, optionName, value), newParams]);
6034
6035    Value::Null
6036}
6037
6038/* eslint-disable no-unused-vars */
6039/* eslint-enable no-unused-vars */
6040    fn handle_option_bool_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6041        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6042        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6043        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6044        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6045        return Value::from(vec![self.check_option_bool(methodName, optionName1, value), newParams]);
6046
6047    Value::Null
6048}
6049
6050/* eslint-disable no-unused-vars */
6051/* eslint-enable no-unused-vars */
6052    fn handle_option_integer_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6053        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6054        // handleOptionAndParams read as an integer; the statically typed ports throw on another type
6055        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6056        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6057        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6058        return Value::from(vec![self.check_option_integer(methodName, optionName, value), newParams]);
6059
6060    Value::Null
6061}
6062
6063/* eslint-disable no-unused-vars */
6064/* eslint-enable no-unused-vars */
6065    fn handle_option_integer_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6066        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6067        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6068        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6069        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6070        return Value::from(vec![self.check_option_integer(methodName, optionName1, value), newParams]);
6071
6072    Value::Null
6073}
6074
6075    fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6076        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6077        let mut res: Value = self.handle_option_and_params(Value::Map({
6078    let mut m = indexmap::IndexMap::new();
6079    m
6080}), methodName, optionName, &[defaultValue]);
6081        return self.safe_value(res, Value::Int(0), &[]);
6082
6083    Value::Null
6084}
6085
6086    fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6087        let mut market = get_arg(optional_args, 0, Value::Null);
6088        let mut params = get_arg(optional_args, 1, Value::Map({
6089    let mut m = indexmap::IndexMap::new();
6090    m
6091}));
6092        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6093        /*
6094         * @ignore
6095         * @method
6096         * @name exchange#handleMarketTypeAndParams
6097         * @param methodName the method calling handleMarketTypeAndParams
6098         * @param {Market} market
6099         * @param {object} params
6100         * @param {string} [params.type] type assigned by user
6101         * @param {string} [params.defaultType] same as params.type
6102         * @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
6103         * @returns {[string, object]} the market type and params with type and defaultType omitted
6104         */
6105        // type from param
6106        let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6107        if (type_var != Value::Null) {
6108            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("defaultType".into()), Value::Str("type".into())]), &[]);
6109            return Value::from(vec![type_var, paramsOmitted]);
6110        }
6111        // type from market
6112        if (market != Value::Null) {
6113            return Value::from(vec![market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), params.clone()]);
6114        }
6115        // type from default-argument
6116        if (defaultValue != Value::Null) {
6117            return Value::from(vec![defaultValue, params.clone()]);
6118        }
6119        let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName, &[]);
6120        if (methodOptions != Value::Null) {
6121            if matches!(&methodOptions, Value::Str(_)) {
6122                return Value::from(vec![methodOptions.clone(), params.clone()]);
6123            }  else {
6124                let mut typeFromMethod: Value = self.safe_string2(methodOptions, Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6125                if (typeFromMethod != Value::Null) {
6126                    return Value::from(vec![typeFromMethod, params.clone()]);
6127                }
6128            }
6129        }
6130        let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[Value::Str("spot".into())]);
6131        return Value::from(vec![defaultType, params]);
6132
6133    Value::Null
6134}
6135
6136    fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6137        let mut market = get_arg(optional_args, 0, Value::Null);
6138        let mut params = get_arg(optional_args, 1, Value::Map({
6139    let mut m = indexmap::IndexMap::new();
6140    m
6141}));
6142        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6143        let mut subType: Value = Value::Null;
6144        // if set in params, it takes precedence
6145        let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".into()), Value::Str("defaultSubType".into()), &[]);
6146        // avoid omitting if it's not present
6147        if (subTypeInParams != Value::Null) {
6148            if (subTypeInParams.as_str() == Some("linear")) || (subTypeInParams.as_str() == Some("inverse")) {
6149                subType = subTypeInParams;
6150            }
6151            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("subType".into()), Value::Str("defaultSubType".into())]), &[]);
6152            return Value::from(vec![subType.clone(), paramsOmitted]);
6153        }  else {
6154            // at first, check from market object
6155            if (market != Value::Null) {
6156                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6157                    subType = Value::Str("linear".into());
6158                }  else if (market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6159                    subType = Value::Str("inverse".into());
6160                }
6161            }
6162            // if it was not defined in market object
6163            if (subType == Value::Null) {
6164                let mut values: Value = self.handle_option_and_params(Value::Map({
6165    let mut m = indexmap::IndexMap::new();
6166    m
6167}), methodName, Value::Str("subType".into()), &[defaultValue]); // no need to re-test params here
6168                subType = values.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6169            }
6170        }
6171        return Value::from(vec![subType, params]);
6172
6173    Value::Null
6174}
6175
6176    fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6177        let mut params = get_arg(optional_args, 0, Value::Map({
6178    let mut m = indexmap::IndexMap::new();
6179    m
6180}));
6181        let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6182        return self.handle_option_string_and_params(params, methodName, Value::Str("marginMode".into()), &[defaultValue]);
6183
6184    Value::Null
6185}
6186
6187    fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6188        if (string == Value::Null) {
6189            return;
6190        }
6191        if (in_op(&exact, &string)) {
6192            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
6193        }
6194}
6195
6196    fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6197        let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string);
6198        if (broadKey != Value::Null) {
6199            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
6200        }
6201}
6202
6203    fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6204        // a helper for matching error strings exactly vs broadly
6205        let mut keys: Value = object_keys(&broad);
6206        {
6207                        let mut i: Value = Value::Int(0);
6208            let mut __for_first_135: bool = true;
6209            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) < ((keys.len() as i64) as f64) } {
6210            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);
6211            if (string != Value::Null) {
6212                if get_index_of(&string, &key).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
6213                    return key;
6214                }
6215            }
6216        }
6217        }
6218        return Value::Null;
6219
6220    Value::Null
6221}
6222
6223    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 {
6224        // virtual-dispatch (static: DerivedExchange::handle_errors(self, ...))
6225        { 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; } }
6226
6227        return Value::Null;
6228
6229    Value::Null
6230}
6231
6232    fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6233        let mut config = get_arg(optional_args, 0, Value::Map({
6234    let mut m = indexmap::IndexMap::new();
6235    m
6236}));
6237        let __config_empty = indexmap::IndexMap::new();
6238        let config = config.as_map().unwrap_or(&__config_empty);
6239        return (match config.get("cost") { Some(__v) if !matches!(__v, Value::Null) && !matches!(__v, Value::Str(__s) if __s.is_empty()) => __v.clone(), _ => Value::Int(1) });
6240
6241    Value::Null
6242}
6243
6244    fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6245        let mut symbols = get_arg(optional_args, 0, Value::Null);
6246        let mut params = get_arg(optional_args, 1, Value::Map({
6247    let mut m = indexmap::IndexMap::new();
6248    m
6249}));
6250        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotTickers() is not supported yet".into()))));
6251
6252    Value::Null
6253} }
6254
6255    fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6256        let mut symbols = get_arg(optional_args, 0, Value::Null);
6257        let mut params = get_arg(optional_args, 1, Value::Map({
6258    let mut m = indexmap::IndexMap::new();
6259    m
6260}));
6261        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractTickers() is not supported yet".into()))));
6262
6263    Value::Null
6264} }
6265
6266    fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6267        let mut symbols = get_arg(optional_args, 0, Value::Null);
6268        let mut limit = get_arg(optional_args, 1, Value::Null);
6269        let mut params = get_arg(optional_args, 2, Value::Map({
6270    let mut m = indexmap::IndexMap::new();
6271    m
6272}));
6273        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBooks() is not supported yet".into()))));
6274
6275    Value::Null
6276} }
6277
6278    fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6279        let mut symbols = get_arg(optional_args, 0, Value::Null);
6280        let mut params = get_arg(optional_args, 1, Value::Map({
6281    let mut m = indexmap::IndexMap::new();
6282    m
6283}));
6284        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTickers() is not supported yet".into()))));
6285
6286    Value::Null
6287} }
6288
6289    fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6290        let mut params = get_arg(optional_args, 0, Value::Map({
6291    let mut m = indexmap::IndexMap::new();
6292    m
6293}));
6294        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRate() is not supported yet".into()))));
6295
6296    Value::Null
6297} }
6298
6299    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 {
6300        let mut params = get_arg(optional_args, 0, Value::Map({
6301    let mut m = indexmap::IndexMap::new();
6302    m
6303}));
6304        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTwapOrder() is not supported yet".into()))));
6305
6306    Value::Null
6307} }
6308
6309    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 {
6310        let mut amount = get_arg(optional_args, 0, Value::Null);
6311        let mut params = get_arg(optional_args, 1, Value::Map({
6312    let mut m = indexmap::IndexMap::new();
6313    m
6314}));
6315        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() is not supported yet".into()))));
6316
6317    Value::Null
6318} }
6319
6320    fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6321        let mut code = get_arg(optional_args, 0, Value::Null);
6322        let mut params = get_arg(optional_args, 1, Value::Map({
6323    let mut m = indexmap::IndexMap::new();
6324    m
6325}));
6326        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTrade() is not supported yet".into()))));
6327
6328    Value::Null
6329} }
6330
6331    fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6332        let mut code = get_arg(optional_args, 0, Value::Null);
6333        let mut since = get_arg(optional_args, 1, Value::Null);
6334        let mut limit = get_arg(optional_args, 2, Value::Null);
6335        let mut params = get_arg(optional_args, 3, Value::Map({
6336    let mut m = indexmap::IndexMap::new();
6337    m
6338}));
6339        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTradeHistory() is not supported yet".into()))));
6340
6341    Value::Null
6342} }
6343
6344    fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6345        // async-virtual: try the derived exchange first
6346        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 {
6347            if !matches!(__v, crate::Value::Null) { return __v; }
6348        }
6349
6350        let mut symbol = get_arg(optional_args, 0, Value::Null);
6351        let mut params = get_arg(optional_args, 1, Value::Map({
6352    let mut m = indexmap::IndexMap::new();
6353    m
6354}));
6355        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionMode() is not supported yet".into()))));
6356
6357    Value::Null
6358} }
6359
6360    fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6361        let mut params = get_arg(optional_args, 0, Value::Map({
6362    let mut m = indexmap::IndexMap::new();
6363    m
6364}));
6365        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchADLRank() is not supported yet".into()))));
6366
6367    Value::Null
6368} }
6369
6370    fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6371        // async-virtual: try the derived exchange first
6372        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 {
6373            if !matches!(__v, crate::Value::Null) { return __v; }
6374        }
6375
6376        let mut symbols = get_arg(optional_args, 0, Value::Null);
6377        let mut params = get_arg(optional_args, 1, Value::Map({
6378    let mut m = indexmap::IndexMap::new();
6379    m
6380}));
6381        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6382
6383    Value::Null
6384} }
6385
6386    fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6387        // async-virtual: try the derived exchange first
6388        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 {
6389            if !matches!(__v, crate::Value::Null) { return __v; }
6390        }
6391
6392        let mut params = get_arg(optional_args, 0, Value::Map({
6393    let mut m = indexmap::IndexMap::new();
6394    m
6395}));
6396        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)) {
6397            self.load_markets(&[]).await;
6398            let mut market: Value = self.market(symbol);
6399            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
6400            let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::from(vec![symbolResolved.clone()]), params]).await;
6401            let mut rank: Value = self.safe_dict(ranks, Value::Int(0), &[]);
6402            if (rank == Value::Null) {
6403                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() could not find a rank for ".into())).into()), symbolResolved)));
6404            }  else {
6405                return rank;
6406            }
6407        }  else {
6408            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6409        }
6410
6411    Value::Null
6412} }
6413
6414    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 {
6415        let mut price = get_arg(optional_args, 0, Value::Null);
6416        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6417        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6418        let mut params = get_arg(optional_args, 3, Value::Map({
6419    let mut m = indexmap::IndexMap::new();
6420    m
6421}));
6422        if (takeProfit == Value::Null) && (stopLoss == Value::Null) {
6423            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".into()))));
6424        }
6425        if (takeProfit != Value::Null) {
6426            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), Value::Map({
6427    let mut m = indexmap::IndexMap::new();
6428        m.insert("triggerPrice".to_string(), takeProfit);
6429    m
6430})); }
6431        }
6432        if (stopLoss != Value::Null) {
6433            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), Value::Map({
6434    let mut m = indexmap::IndexMap::new();
6435        m.insert("triggerPrice".to_string(), stopLoss);
6436    m
6437})); }
6438        }
6439        let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
6440        let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
6441        let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
6442        let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
6443        let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
6444        let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
6445        let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
6446        let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
6447        if (takeProfitType != Value::Null) {
6448            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("type".into()), takeProfitType);
6449        }
6450        if (takeProfitPriceType != Value::Null) {
6451            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("priceType".into()), takeProfitPriceType);
6452        }
6453        if (takeProfitLimitPrice != Value::Null) {
6454            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("price".into()), self.parse_to_numeric(takeProfitLimitPrice));
6455        }
6456        if (takeProfitAmount != Value::Null) {
6457            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("amount".into()), self.parse_to_numeric(takeProfitAmount));
6458        }
6459        if (stopLossType != Value::Null) {
6460            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("type".into()), stopLossType);
6461        }
6462        if (stopLossPriceType != Value::Null) {
6463            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("priceType".into()), stopLossPriceType);
6464        }
6465        if (stopLossLimitPrice != Value::Null) {
6466            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("price".into()), self.parse_to_numeric(stopLossLimitPrice));
6467        }
6468        if (stopLossAmount != Value::Null) {
6469            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("amount".into()), self.parse_to_numeric(stopLossAmount));
6470        }
6471        let mut paramsOmitted: Value = self.omit(params, 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())]), &[]);
6472        return paramsOmitted;
6473
6474    Value::Null
6475}
6476
6477    fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6478        let mut params = get_arg(optional_args, 0, Value::Map({
6479    let mut m = indexmap::IndexMap::new();
6480    m
6481}));
6482        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSpotOrders() is not supported yet".into()))));
6483
6484    Value::Null
6485} }
6486
6487    fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6488        let mut params = get_arg(optional_args, 0, Value::Map({
6489    let mut m = indexmap::IndexMap::new();
6490    m
6491}));
6492        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createContractOrders() is not supported yet".into()))));
6493
6494    Value::Null
6495} }
6496
6497    fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6498        let mut symbol = get_arg(optional_args, 0, Value::Null);
6499        let mut params = get_arg(optional_args, 1, Value::Map({
6500    let mut m = indexmap::IndexMap::new();
6501    m
6502}));
6503        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelSpotOrder() is not supported yet".into()))));
6504
6505    Value::Null
6506} }
6507
6508    fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6509        let mut symbol = get_arg(optional_args, 0, Value::Null);
6510        let mut params = get_arg(optional_args, 1, Value::Map({
6511    let mut m = indexmap::IndexMap::new();
6512    m
6513}));
6514        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelContractOrder() is not supported yet".into()))));
6515
6516    Value::Null
6517} }
6518
6519    fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6520        let mut symbol = get_arg(optional_args, 0, Value::Null);
6521        let mut params = get_arg(optional_args, 1, Value::Map({
6522    let mut m = indexmap::IndexMap::new();
6523    m
6524}));
6525        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllSpotOrders() is not supported yet".into()))));
6526
6527    Value::Null
6528} }
6529
6530    fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6531        let mut symbol = get_arg(optional_args, 0, Value::Null);
6532        let mut params = get_arg(optional_args, 1, Value::Map({
6533    let mut m = indexmap::IndexMap::new();
6534    m
6535}));
6536        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllContractOrders() is not supported yet".into()))));
6537
6538    Value::Null
6539} }
6540
6541    fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6542        let mut params = get_arg(optional_args, 0, Value::Map({
6543    let mut m = indexmap::IndexMap::new();
6544    m
6545}));
6546        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersAfter() is not supported yet".into()))));
6547
6548    Value::Null
6549} }
6550
6551    fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6552        let mut params = get_arg(optional_args, 0, Value::Map({
6553    let mut m = indexmap::IndexMap::new();
6554    m
6555}));
6556        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersForSymbols() is not supported yet".into()))));
6557
6558    Value::Null
6559} }
6560
6561    fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6562        let mut symbol = get_arg(optional_args, 0, Value::Null);
6563        let mut since = get_arg(optional_args, 1, Value::Null);
6564        let mut limit = get_arg(optional_args, 2, Value::Null);
6565        let mut params = get_arg(optional_args, 3, Value::Map({
6566    let mut m = indexmap::IndexMap::new();
6567    m
6568}));
6569        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() is not supported yet".into()))));
6570
6571    Value::Null
6572} }
6573
6574    fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6575        let mut since = get_arg(optional_args, 0, Value::Null);
6576        let mut limit = get_arg(optional_args, 1, Value::Null);
6577        let mut params = get_arg(optional_args, 2, 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(" fetchLiquidations() is not supported yet".into()))));
6582
6583    Value::Null
6584} }
6585
6586    fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6587        let mut params = get_arg(optional_args, 0, Value::Map({
6588    let mut m = indexmap::IndexMap::new();
6589    m
6590}));
6591        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchGreeks() is not supported yet".into()))));
6592
6593    Value::Null
6594} }
6595
6596    fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6597        let mut symbols = get_arg(optional_args, 0, Value::Null);
6598        let mut params = get_arg(optional_args, 1, Value::Map({
6599    let mut m = indexmap::IndexMap::new();
6600    m
6601}));
6602        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAllGreeks() is not supported yet".into()))));
6603
6604    Value::Null
6605} }
6606
6607    fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6608        let mut params = get_arg(optional_args, 0, Value::Map({
6609    let mut m = indexmap::IndexMap::new();
6610    m
6611}));
6612        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOptionChain() is not supported yet".into()))));
6613
6614    Value::Null
6615} }
6616
6617    fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6618        let mut params = get_arg(optional_args, 0, Value::Map({
6619    let mut m = indexmap::IndexMap::new();
6620    m
6621}));
6622        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOption() is not supported yet".into()))));
6623
6624    Value::Null
6625} }
6626
6627    fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6628        let mut amount = get_arg(optional_args, 0, Value::Null);
6629        let mut params = get_arg(optional_args, 1, Value::Map({
6630    let mut m = indexmap::IndexMap::new();
6631    m
6632}));
6633        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertQuote() is not supported yet".into()))));
6634
6635    Value::Null
6636} }
6637
6638    fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6639        // async-virtual: try the derived exchange first
6640        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 {
6641            if !matches!(__v, crate::Value::Null) { return __v; }
6642        }
6643
6644        let mut code = get_arg(optional_args, 0, Value::Null);
6645        let mut since = get_arg(optional_args, 1, Value::Null);
6646        let mut limit = get_arg(optional_args, 2, Value::Null);
6647        let mut params = get_arg(optional_args, 3, Value::Map({
6648    let mut m = indexmap::IndexMap::new();
6649    m
6650}));
6651        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWithdrawals() is not supported yet".into()))));
6652
6653    Value::Null
6654} }
6655
6656    fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6657        // async-virtual: try the derived exchange first
6658        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 {
6659            if !matches!(__v, crate::Value::Null) { return __v; }
6660        }
6661
6662        let mut code = get_arg(optional_args, 0, Value::Null);
6663        let mut since = get_arg(optional_args, 1, Value::Null);
6664        let mut limit = get_arg(optional_args, 2, Value::Null);
6665        let mut params = get_arg(optional_args, 3, Value::Map({
6666    let mut m = indexmap::IndexMap::new();
6667    m
6668}));
6669        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposits() is not supported yet".into()))));
6670
6671    Value::Null
6672} }
6673
6674    fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6675        // async-virtual: try the derived exchange first
6676        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 {
6677            if !matches!(__v, crate::Value::Null) { return __v; }
6678        }
6679
6680        let mut code = get_arg(optional_args, 0, Value::Null);
6681        let mut since = get_arg(optional_args, 1, Value::Null);
6682        let mut limit = get_arg(optional_args, 2, Value::Null);
6683        let mut params = get_arg(optional_args, 3, Value::Map({
6684    let mut m = indexmap::IndexMap::new();
6685    m
6686}));
6687        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawals() is not supported yet".into()))));
6688
6689    Value::Null
6690} }
6691
6692    fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6693        let mut code = get_arg(optional_args, 0, Value::Null);
6694        let mut since = get_arg(optional_args, 1, Value::Null);
6695        let mut limit = get_arg(optional_args, 2, Value::Null);
6696        let mut params = get_arg(optional_args, 3, Value::Map({
6697    let mut m = indexmap::IndexMap::new();
6698    m
6699}));
6700        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWs() is not supported yet".into()))));
6701
6702    Value::Null
6703} }
6704
6705    fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6706        let mut code = get_arg(optional_args, 0, Value::Null);
6707        let mut since = get_arg(optional_args, 1, Value::Null);
6708        let mut limit = get_arg(optional_args, 2, Value::Null);
6709        let mut params = get_arg(optional_args, 3, Value::Map({
6710    let mut m = indexmap::IndexMap::new();
6711    m
6712}));
6713        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawalsWs() is not supported yet".into()))));
6714
6715    Value::Null
6716} }
6717
6718    fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6719        // async-virtual: try the derived exchange first
6720        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 {
6721            if !matches!(__v, crate::Value::Null) { return __v; }
6722        }
6723
6724        let mut symbol = get_arg(optional_args, 0, Value::Null);
6725        let mut since = get_arg(optional_args, 1, Value::Null);
6726        let mut limit = get_arg(optional_args, 2, Value::Null);
6727        let mut params = get_arg(optional_args, 3, Value::Map({
6728    let mut m = indexmap::IndexMap::new();
6729    m
6730}));
6731        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() is not supported yet".into()))));
6732
6733    Value::Null
6734} }
6735
6736    fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6737        let mut symbol = get_arg(optional_args, 0, Value::Null);
6738        let mut since = get_arg(optional_args, 1, Value::Null);
6739        let mut limit = get_arg(optional_args, 2, Value::Null);
6740        let mut params = get_arg(optional_args, 3, Value::Map({
6741    let mut m = indexmap::IndexMap::new();
6742    m
6743}));
6744        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() is not supported yet".into()))));
6745
6746    Value::Null
6747} }
6748
6749    fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
6750        // virtual-dispatch (static: DerivedExchange::parse_last_price(self, ...))
6751        { 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; } }
6752
6753        let mut market = get_arg(optional_args, 0, Value::Null);
6754        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLastPrice() is not supported yet".into()))));
6755
6756    Value::Null
6757}
6758
6759    fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6760        // async-virtual: try the derived exchange first
6761        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 {
6762            if !matches!(__v, crate::Value::Null) { return __v; }
6763        }
6764
6765        let mut params = get_arg(optional_args, 0, Value::Map({
6766    let mut m = indexmap::IndexMap::new();
6767    m
6768}));
6769        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)) {
6770            let mut depositAddresses: Value = self.fetch_deposit_addresses(&[Value::from(vec![code.clone()]), params.clone()]).await;
6771            let mut depositAddress: Value = self.safe_value(depositAddresses, code.clone(), &[]);
6772            if (depositAddress == Value::Null) {
6773                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()))));
6774            }  else {
6775                return depositAddress;
6776            }
6777        }  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)) {
6778            let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
6779            let mut paramsOmitted: Value = self.omit(params, Value::Str("network".into()), &[]);
6780            let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code, &[paramsOmitted]).await;
6781            if (network != Value::Null) {
6782                return self.safe_dict(addressStructures.clone(), network, &[]);
6783            }  else {
6784                let mut keys: Value = object_keys(&addressStructures);
6785                let mut key: Value = keys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6786                return self.safe_dict(addressStructures, key, &[]);
6787            }
6788        }  else {
6789            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() is not supported yet".into()))));
6790        }
6791
6792    Value::Null
6793} }
6794
6795    fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6796        let mut params = get_arg(optional_args, 0, Value::Map({
6797    let mut m = indexmap::IndexMap::new();
6798    m
6799}));
6800        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractDepositAddress() is not supported yet".into()))));
6801
6802    Value::Null
6803} }
6804
6805    fn account(&self) -> Value {
6806        return Value::Map({
6807    let mut m = indexmap::IndexMap::new();
6808        m.insert("free".to_string(), Value::Null);
6809        m.insert("used".to_string(), Value::Null);
6810        m.insert("total".to_string(), Value::Null);
6811    m
6812});
6813
6814    Value::Null
6815}
6816
6817/*
6818 * @ignore
6819 * @method
6820 * @description merges a per-market (isolated margin) account into a flat code-keyed balance dict, summing string fields when the code recurs across markets
6821 * @param {object} result the code-keyed balance dict being built
6822 * @param {string} code unified currency code
6823 * @param {object} account a balance account with string free/used/total/debt
6824 * @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
6825 */
6826    fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
6827        if !(in_op(&result, &code)) {
6828            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
6829            return result;
6830        }
6831        let mut fields: Value = Value::from(vec![Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into()), Value::Str("debt".into())]);
6832        {
6833                        let mut i: Value = Value::Int(0);
6834            let mut __for_first_136: bool = true;
6835            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) < ((fields.len() as i64) as f64) } {
6836            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);
6837            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(), &[]);
6838            let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
6839            if (current == Value::Null) {
6840                add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
6841            }  else if (incoming != Value::Null) {
6842                add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(&current, &incoming));
6843            }
6844        }
6845        }
6846        return result;
6847
6848    Value::Null
6849}
6850
6851    fn common_currency_code(&self, mut code: Value) -> Value {
6852        if !is_true(&self.substituteCommonCurrencyCodes) {
6853            return code;
6854        }
6855        return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
6856
6857    Value::Null
6858}
6859
6860    fn currency(&self, mut code: Value) -> Value {
6861        if (code == Value::Null) {
6862            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currency() requires a code argument".into()))));
6863        }
6864        let mut keys: Value = object_keys(&self.currencies);
6865        let mut numCurrencies: f64 = ((keys.len() as i64) as f64);
6866        if (numCurrencies == 0.0) {
6867            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" currencies not loaded".into()))));
6868        }
6869        if matches!(&code, Value::Str(_)) {
6870            let mut currencies: Value = self.currencies.clone();
6871            let mut currenciesById: Value = self.currencies_by_id.clone();
6872            if (in_op(&currencies, &code)) {
6873                return currencies.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6874            }  else if (currenciesById != Value::Null) && (in_op(&currenciesById, &code)) {
6875                return currenciesById.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6876            }
6877        }
6878        panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have currency code ".into())).into()), code)));
6879
6880    Value::Null
6881}
6882
6883    fn market(&self, mut symbol: Value) -> Value {
6884        if (symbol == Value::Null) {
6885            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" market() requires a symbol argument".into()))));
6886        }
6887        let mut markets: Value = self.markets.clone();
6888        if (markets == Value::Null) {
6889            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
6890        }
6891        let mut marketsById: Value = self.markets_by_id.clone();
6892        if (in_op(&markets, &symbol)) {
6893            return get_value(&markets, &symbol);
6894        }  else if (marketsById != Value::Null) && (in_op(&marketsById, &symbol)) {
6895            let mut marketsList: Value = get_value(&marketsById, &symbol);
6896            let mut marketsList: Value = get_value(&marketsById, &symbol);
6897            let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("defaultSubType".into()), &[Value::Str("spot".into())]);
6898            {
6899                                let mut i: Value = Value::Int(0);
6900                let mut __for_first_137: bool = true;
6901                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) < get_array_length(&marketsList).as_f64().unwrap_or(f64::NAN) } {
6902                let mut market: Value = get_value(&marketsList, &i);
6903                let mut market: Value = get_value(&marketsList, &i);
6904                if is_equal(&get_value(&market, &defaultType), &Value::Bool(true)) {
6905                    return market;
6906                }
6907            }
6908            }
6909            return get_value(&marketsList, &Value::Int(0));
6910        }  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()))) {
6911            return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
6912        }
6913        panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have market symbol ".into())).into()), symbol)));
6914
6915    Value::Null
6916}
6917
6918    fn create_expired_option_market(&self, mut symbol: Value) -> Value {
6919        // virtual-dispatch (static: DerivedExchange::create_expired_option_market(self, ...))
6920        { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol); if !matches!(__v, crate::Value::Null) { return __v; } }
6921
6922        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createExpiredOptionMarket () is not supported yet".into()))));
6923
6924    Value::Null
6925}
6926
6927    fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
6928        let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
6929        let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
6930        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())]);
6931        {
6932                        let mut i: Value = Value::Int(0);
6933            let mut __for_first_138: bool = true;
6934            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) < ((leverageSuffixes.len() as i64) as f64) } {
6935            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);
6936            let mut endsWithSuffix: bool = ends_with(&currencyCode, &leverageSuffix);
6937            if endsWithSuffix {
6938                if !is_true(&checkBaseCoin) {
6939                    return Value::Bool(true);
6940                }  else {
6941                    // check if base currency is inside dict
6942                    let mut baseCurrencyCode: Value = replace_str(&currencyCode, &leverageSuffix, &Value::Str("".into()));
6943                    if (existingCurrencies != Value::Null) && (in_op(&existingCurrencies, &baseCurrencyCode)) {
6944                        return Value::Bool(true);
6945                    }
6946                }
6947            }
6948        }
6949        }
6950        return Value::Bool(false);
6951
6952    Value::Null
6953}
6954
6955    fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
6956        if (cost == Value::Null) {
6957            return Value::Null;
6958        }
6959        let mut market: Value = self.market(symbol);
6960        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()]);
6961
6962    Value::Null
6963}
6964
6965    fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
6966        if (price == Value::Null) {
6967            return Value::Null;
6968        }
6969        let mut market: Value = self.market(symbol);
6970        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()]);
6971        if (result.as_str() == Some("0")) {
6972            let mut pricePrecision: Value = 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));
6973            if (pricePrecision == Value::Null) {
6974                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" priceToPrecision() market ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" has no price precision".into()))));
6975            }
6976            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()), pricePrecision)));
6977        }
6978        return result;
6979
6980    Value::Null
6981}
6982
6983    fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
6984        if (amount == Value::Null) {
6985            return Value::Null;
6986        }
6987        let mut market: Value = self.market(symbol);
6988        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()]);
6989        if (result.as_str() == Some("0")) {
6990            let mut amountPrecision: Value = 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));
6991            if (amountPrecision == Value::Null) {
6992                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" amountToPrecision() market ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" has no amount precision".into()))));
6993            }
6994            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()), amountPrecision)));
6995        }
6996        return result;
6997
6998    Value::Null
6999}
7000
7001    fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
7002        if (fee == Value::Null) {
7003            return Value::Null;
7004        }
7005        let mut market: Value = self.market(symbol);
7006        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()]);
7007
7008    Value::Null
7009}
7010
7011    fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
7012        let mut networkCode = get_arg(optional_args, 0, Value::Null);
7013        if (code == Value::Null) {
7014            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currencyToPrecision() requires a code argument".into()))));
7015        }
7016        let mut currency: Value = get_value(&self.currencies, &code);
7017        let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
7018        if (networkCode != Value::Null) {
7019            let mut networks: Value = self.safe_dict_k(currency, "networks", &[Value::Map({
7020    let mut m = indexmap::IndexMap::new();
7021    m
7022})]);
7023            let mut networkItem: Value = self.safe_dict(networks, networkCode, &[Value::Map({
7024    let mut m = indexmap::IndexMap::new();
7025    m
7026})]);
7027            precision = self.safe_value_k(networkItem, "precision", &[precision.clone()]);
7028        }
7029        if (precision == Value::Null) {
7030            return self.force_string(fee.clone());
7031        }  else {
7032            let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
7033            return self.decimal_to_precision(fee, roundingMode, precision, &[self.precisionMode.clone(), self.paddingMode.clone()]);
7034        }
7035
7036    Value::Null
7037}
7038
7039    fn force_string(&self, mut value: Value) -> Value {
7040        if !matches!(&value, Value::Str(_)) {
7041            return self.number_to_string(value.clone());
7042        }
7043        return value;
7044
7045    Value::Null
7046}
7047
7048    fn is_tick_precision(&self) -> Value {
7049        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64());
7050
7051    Value::Null
7052}
7053
7054    fn is_significant_precision(&self) -> Value {
7055        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::SIGNIFICANT_DIGITS).as_f64());
7056
7057    Value::Null
7058}
7059
7060    fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
7061        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7062        let mut value: Value = self.safe_string(obj, key, &[]);
7063        return self.parse_number(value, &[defaultNumber]);
7064
7065    Value::Null
7066}
7067
7068    fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
7069        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7070        let mut value: Value = self.safe_string_n(obj, arr, &[]);
7071        return self.parse_number(value, &[defaultNumber]);
7072
7073    Value::Null
7074}
7075
7076    fn parse_precision(&self, optional_args: &[Value]) -> Value {
7077        let mut precision = get_arg(optional_args, 0, Value::Null);
7078        /*
7079         * @ignore
7080         * @method
7081         * @param {string} precision The number of digits to the right of the decimal
7082         * @returns {string} a string number equal to 1e-precision
7083         */
7084        if (precision == Value::Null) {
7085            return Value::Null;
7086        }
7087        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 });
7088        if (precisionNumber.as_f64() == Some(0.0)) {
7089            return Value::Str("1".into());
7090        }
7091        if precisionNumber.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
7092            let mut parsedPrecision: Value = Value::Str("0.".into());
7093            {
7094                                let mut i: Value = Value::Int(0);
7095                let mut __for_first_139: bool = true;
7096                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 (&(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) } {
7097                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7098            }
7099            }
7100            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("1".into())).into());
7101        }  else {
7102            let mut parsedPrecision: Value = Value::Str("1".into());
7103            {
7104                                let mut i: Value = Value::Int(0);
7105                let mut __for_first_140: bool = true;
7106                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 (&((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) } {
7107                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7108            }
7109            }
7110            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7111        }
7112
7113    Value::Null
7114}
7115
7116    fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7117        /*
7118         * @ignore
7119         * @method
7120         * @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
7121         * @param {string} precision The number of digits to the right of the decimal
7122         * @returns {string} a string number equal to 1e-precision
7123         */
7124        if (precision == Value::Null) {
7125            return Value::Null;
7126        }
7127        if is_true(&crate::precise::Precise::stringGe(&precision, &Value::Str("0".into()))) {
7128            return self.parse_precision(&[precision.clone()]);
7129        }  else {
7130            let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7131            if (positivePrecisionString == Value::Null) {
7132                return Value::Null;
7133            }
7134            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 });
7135            let mut parsedPrecision: Value = Value::Str("1".into());
7136            {
7137                                let mut i: Value = Value::Int(0);
7138                let mut __for_first_141: bool = true;
7139                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) < (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) } {
7140                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7141            }
7142            }
7143            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7144        }
7145}
7146
7147    fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7148        let mut params = get_arg(optional_args, 0, Value::Map({
7149    let mut m = indexmap::IndexMap::new();
7150    m
7151}));
7152        let mut serverTime: Value = self.fetch_time(&[params]).await;
7153        let mut after: Value = self.milliseconds();
7154        if (serverTime == Value::Null) {
7155            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" loadTimeDifference() missing serverTime".into()))));
7156        }
7157        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 })); }
7158        return self.options.as_map().and_then(|__m| __m.get("timeDifference")).cloned().unwrap_or(Value::Null);
7159
7160    Value::Null
7161} }
7162
7163    fn implode_hostname(&self, mut url: Value) -> Value {
7164        return self.implode_params(url, Value::Map({
7165    let mut m = indexmap::IndexMap::new();
7166        m.insert("hostname".to_string(), self.hostname.clone());
7167    m
7168}));
7169
7170    Value::Null
7171}
7172
7173    fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7174        // async-virtual: try the derived exchange first
7175        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 {
7176            if !matches!(__v, crate::Value::Null) { return __v; }
7177        }
7178
7179        let mut params = get_arg(optional_args, 0, Value::Map({
7180    let mut m = indexmap::IndexMap::new();
7181    m
7182}));
7183        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)) {
7184            let mut market: Value = self.market(symbol.clone());
7185            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7186                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() supports contract markets only".into()))));
7187            }
7188            let mut tiers: Value = self.fetch_leverage_tiers(&[Value::from(vec![symbol.clone()])]).await;
7189            return self.safe_value(tiers, symbol, &[]);
7190        }  else {
7191            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() is not supported yet".into()))));
7192        }
7193
7194    Value::Null
7195} }
7196
7197    fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7198        let mut params = get_arg(optional_args, 0, Value::Map({
7199    let mut m = indexmap::IndexMap::new();
7200    m
7201}));
7202        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSubAccount() is not supported yet".into()))));
7203
7204    Value::Null
7205} }
7206
7207    fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7208        let mut currency = get_arg(optional_args, 0, Value::Null);
7209        let mut currencyResolved: Value = self.safe_currency(currencyId, &[currency]);
7210        return currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
7211
7212    Value::Null
7213}
7214
7215    fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7216        let mut symbol = get_arg(optional_args, 0, Value::Null);
7217        let mut since = get_arg(optional_args, 1, Value::Null);
7218        let mut limit = get_arg(optional_args, 2, Value::Null);
7219        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7220        return self.filter_by_value_since_limit(array, Value::Str("symbol".into()), &[symbol, since, limit, Value::Str("timestamp".into()), tail]);
7221
7222    Value::Null
7223}
7224
7225    fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7226        let mut code = get_arg(optional_args, 0, Value::Null);
7227        let mut since = get_arg(optional_args, 1, Value::Null);
7228        let mut limit = get_arg(optional_args, 2, Value::Null);
7229        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7230        return self.filter_by_value_since_limit(array, Value::Str("currency".into()), &[code, since, limit, Value::Str("timestamp".into()), tail]);
7231
7232    Value::Null
7233}
7234
7235    fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7236        let mut symbols = get_arg(optional_args, 0, Value::Null);
7237        let mut since = get_arg(optional_args, 1, Value::Null);
7238        let mut limit = get_arg(optional_args, 2, Value::Null);
7239        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7240        let mut result: Value = self.filter_by_array(array, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
7241        return self.filter_by_since_limit(result, &[since, limit, Value::Str("timestamp".into()), tail]);
7242
7243    Value::Null
7244}
7245
7246    fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7247        let mut symbols = get_arg(optional_args, 0, Value::Null);
7248        let mut params = get_arg(optional_args, 1, Value::Map({
7249    let mut m = indexmap::IndexMap::new();
7250    m
7251}));
7252        //
7253        // the value of tickers is either a dict or a list
7254        //
7255        // dict
7256        //
7257        //     {
7258        //         'marketId1': { ... },
7259        //         'marketId2': { ... },
7260        //         ...
7261        //     }
7262        //
7263        // list
7264        //
7265        //     [
7266        //         { 'market': 'marketId1', ... },
7267        //         { 'market': 'marketId2', ... },
7268        //         ...
7269        //     ]
7270        //
7271        let mut results: Value = Value::from(vec![]);
7272        if (matches!(&pricesData, Value::Arr(_))) {
7273            {
7274                                let mut i: Value = Value::Int(0);
7275                let mut __for_first_142: bool = true;
7276                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) < ((pricesData.len() as i64) as f64) } {
7277                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()]);
7278                append_to_array(&mut results, priceData.clone());
7279            }
7280            }
7281        }  else {
7282            let mut marketIds: Value = object_keys(&pricesData);
7283            {
7284                                let mut i: Value = Value::Int(0);
7285                let mut __for_first_143: bool = true;
7286                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) < ((marketIds.len() as i64) as f64) } {
7287                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);
7288                let mut market: Value = self.safe_market(&[marketId.clone()]);
7289                let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market]), &[params.clone()]);
7290                append_to_array(&mut results, priceData);
7291            }
7292            }
7293        }
7294        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7295        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbolsNormalized]);
7296
7297    Value::Null
7298}
7299
7300    fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7301        let mut symbols = get_arg(optional_args, 0, Value::Null);
7302        let mut params = get_arg(optional_args, 1, Value::Map({
7303    let mut m = indexmap::IndexMap::new();
7304    m
7305}));
7306        //
7307        // the value of tickers is either a dict or a list
7308        //
7309        //
7310        // dict
7311        //
7312        //     {
7313        //         'marketId1': { ... },
7314        //         'marketId2': { ... },
7315        //         'marketId3': { ... },
7316        //         ...
7317        //     }
7318        //
7319        // list
7320        //
7321        //     [
7322        //         { 'market': 'marketId1', ... },
7323        //         { 'market': 'marketId2', ... },
7324        //         { 'market': 'marketId3', ... },
7325        //         ...
7326        //     ]
7327        //
7328        let mut results: Value = Value::from(vec![]);
7329        if (matches!(&tickers, Value::Arr(_))) {
7330            {
7331                                let mut i: Value = Value::Int(0);
7332                let mut __for_first_144: bool = true;
7333                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) < ((tickers.len() as i64) as f64) } {
7334                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), &[]);
7335                let mut ticker: Value = self.extend(parsedTicker, &[params.clone()]);
7336                append_to_array(&mut results, ticker.clone());
7337            }
7338            }
7339        }  else {
7340            let mut marketIds: Value = object_keys(&tickers);
7341            {
7342                                let mut i: Value = Value::Int(0);
7343                let mut __for_first_145: bool = true;
7344                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) < ((marketIds.len() as i64) as f64) } {
7345                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);
7346                let mut market: Value = self.safe_market(&[marketId.clone()]);
7347                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market]);
7348                let mut ticker: Value = self.extend(parsed, &[params.clone()]);
7349                append_to_array(&mut results, ticker);
7350            }
7351            }
7352        }
7353        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7354        return self.filter_by_array_tickers(results, Value::Str("symbol".into()), &[symbolsNormalized]);
7355
7356    Value::Null
7357}
7358
7359    fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7360        let mut codes = get_arg(optional_args, 0, Value::Null);
7361        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7362        let mut params = get_arg(optional_args, 2, Value::Map({
7363    let mut m = indexmap::IndexMap::new();
7364    m
7365}));
7366        let mut result: Value = Value::from(vec![]);
7367        {
7368                        let mut i: Value = Value::Int(0);
7369            let mut __for_first_146: bool = true;
7370            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(&addresses).as_f64().unwrap_or(f64::NAN) } {
7371            let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7372            append_to_array(&mut result, address);
7373        }
7374        }
7375        if (codes != Value::Null) {
7376            result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[codes, Value::Bool(false)]);
7377        }
7378        if is_true(&indexed) {
7379            result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[Value::Null, indexed.clone()]);
7380        }
7381        return result;
7382
7383    Value::Null
7384}
7385
7386    fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7387        let mut market = get_arg(optional_args, 0, Value::Null);
7388        let mut interests: Value = Value::from(vec![]);
7389        {
7390                        let mut i: Value = Value::Int(0);
7391            let mut __for_first_147: bool = true;
7392            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) } {
7393            let mut row: Value = get_value(&response, &i);
7394            let mut row: Value = get_value(&response, &i);
7395            append_to_array(&mut interests, <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row, &[market.clone()]));
7396        }
7397        }
7398        return interests;
7399
7400    Value::Null
7401}
7402
7403    fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7404        // virtual-dispatch (static: DerivedExchange::parse_borrow_rate(self, ...))
7405        { 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; } }
7406
7407        let mut currency = get_arg(optional_args, 0, Value::Null);
7408        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowRate() is not supported yet".into()))));
7409
7410    Value::Null
7411}
7412
7413    fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7414        let mut result: Value = Value::from(vec![]);
7415        {
7416                        let mut i: Value = Value::Int(0);
7417            let mut __for_first_148: bool = true;
7418            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(&response).as_f64().unwrap_or(f64::NAN) } {
7419            let mut item: Value = get_value(&response, &i);
7420            let mut item: Value = get_value(&response, &i);
7421            let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item, &[]);
7422            append_to_array(&mut result, borrowRate);
7423        }
7424        }
7425        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
7426        return self.filter_by_currency_since_limit(sorted, &[code, since, limit]);
7427
7428    Value::Null
7429}
7430
7431    fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7432        let mut result: Value = Value::Map({
7433            let mut m = indexmap::IndexMap::new();
7434            m
7435        });
7436        {
7437                        let mut i: Value = Value::Int(0);
7438            let mut __for_first_149: bool = true;
7439            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(&info).as_f64().unwrap_or(f64::NAN) } {
7440            let mut item: Value = get_value(&info, &i);
7441            let mut item: Value = get_value(&info, &i);
7442            let mut borrowRate: Value = self.parse_isolated_borrow_rate(item, &[]);
7443            let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
7444            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), borrowRate); }
7445        }
7446        }
7447        return result;
7448
7449    Value::Null
7450}
7451
7452    fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7453        let mut market = get_arg(optional_args, 0, Value::Null);
7454        let mut since = get_arg(optional_args, 1, Value::Null);
7455        let mut limit = get_arg(optional_args, 2, Value::Null);
7456        let mut rates: Value = Value::from(vec![]);
7457        {
7458                        let mut i: Value = Value::Int(0);
7459            let mut __for_first_150: bool = true;
7460            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) } {
7461            let mut entry: Value = get_value(&response, &i);
7462            let mut entry: Value = get_value(&response, &i);
7463            append_to_array(&mut rates, <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry, &[market.clone()]));
7464        }
7465        }
7466        let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7467        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) });
7468        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7469
7470    Value::Null
7471}
7472
7473    fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7474        let mut market = get_arg(optional_args, 0, Value::Null);
7475        let mut delimiter = get_arg(optional_args, 1, Value::Null);
7476        let mut marketType = get_arg(optional_args, 2, Value::Null);
7477        let mut marketResolved: Value = self.safe_market(&[marketId, market, delimiter, marketType]);
7478        return marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7479
7480    Value::Null
7481}
7482
7483    fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7484        // virtual-dispatch (static: DerivedExchange::parse_funding_rate(self, ...))
7485        { 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; } }
7486
7487        let mut market = get_arg(optional_args, 0, Value::Null);
7488        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRate() is not supported yet".into()))));
7489
7490    Value::Null
7491}
7492
7493    fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7494        let mut symbols = get_arg(optional_args, 0, Value::Null);
7495        let mut fundingRates: Value = Value::Map({
7496            let mut m = indexmap::IndexMap::new();
7497            m
7498        });
7499        {
7500                        let mut i: Value = Value::Int(0);
7501            let mut __for_first_151: bool = true;
7502            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) } {
7503            let mut entry: Value = get_value(&response, &i);
7504            let mut entry: Value = get_value(&response, &i);
7505            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry, &[]);
7506            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7507                add_element_to_object(&mut fundingRates, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7508            }
7509        }
7510        }
7511        return self.index_by(self.filter_by_array(fundingRates, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]), Value::Str("symbol".into()));
7512
7513    Value::Null
7514}
7515
7516    fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7517        let mut market = get_arg(optional_args, 0, Value::Null);
7518        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLongShortRatio() is not supported yet".into()))));
7519
7520    Value::Null
7521}
7522
7523    fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7524        let mut market = get_arg(optional_args, 0, Value::Null);
7525        let mut since = get_arg(optional_args, 1, Value::Null);
7526        let mut limit = get_arg(optional_args, 2, Value::Null);
7527        let mut rates: Value = Value::from(vec![]);
7528        {
7529                        let mut i: Value = Value::Int(0);
7530            let mut __for_first_152: bool = true;
7531            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) } {
7532            let mut entry: Value = get_value(&response, &i);
7533            let mut entry: Value = get_value(&response, &i);
7534            append_to_array(&mut rates, self.parse_long_short_ratio(entry, &[market.clone()]));
7535        }
7536        }
7537        let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7538        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) });
7539        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7540
7541    Value::Null
7542}
7543
7544    fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7545        let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7546        //
7547        let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
7548        let mut triggerPriceStr: Value = Value::Null;
7549        let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7550        let mut stopLossPriceStr: Value = Value::Null;
7551        let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7552        let mut takeProfitPriceStr: Value = Value::Null;
7553        //
7554        let mut keysToOmit: Value = Value::from(vec![]);
7555        if (triggerPrice != Value::Null) {
7556            if is_true(&omitParams) {
7557                append_to_array(&mut keysToOmit, Value::Str("triggerPrice".into()));
7558                append_to_array(&mut keysToOmit, Value::Str("stopPrice".into()));
7559            }
7560            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 }));
7561        }
7562        if (stopLossPrice != Value::Null) {
7563            if is_true(&omitParams) {
7564                append_to_array(&mut keysToOmit, Value::Str("stopLossPrice".into()));
7565            }
7566            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 }));
7567        }
7568        if (takeProfitPrice != Value::Null) {
7569            if is_true(&omitParams) {
7570                append_to_array(&mut keysToOmit, Value::Str("takeProfitPrice".into()));
7571            }
7572            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 }));
7573        }
7574        let mut keysToOmitLength: f64 = ((keysToOmit.len() as i64) as f64);
7575        let mut paramsOmitted: Value = (if (keysToOmitLength > ((0i64) as f64)) { self.omit(params.clone(), keysToOmit, &[]) } else { params });
7576        return Value::from(vec![triggerPriceStr, stopLossPriceStr, takeProfitPriceStr, paramsOmitted]);
7577
7578    Value::Null
7579}
7580
7581    fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7582        let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7583        let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7584        /*
7585         * @ignore
7586         * @method
7587         * @returns {[string, object]} the trigger-direction value and omited params
7588         */
7589        let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7590        let mut exchangeSpecificDefined: bool = (exchangeSpecificKey != Value::Null) && (in_op(&params, &exchangeSpecificKey));
7591        let mut paramsOmitted: Value = (if (triggerDirection != Value::Null) { self.omit(params.clone(), Value::Str("triggerDirection".into()), &[]) } else { params });
7592        // throw exception if:
7593        // A) if provided value is not unified (support old "up/down" strings too)
7594        // B) if exchange specific "trigger direction key" (eg. "stopPriceSide") was not provided
7595        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) {
7596            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()))));
7597        }
7598        // if old format was provided, overwrite to new
7599        if (triggerDirection.as_str() == Some("up")) || (triggerDirection.as_str() == Some("above")) {
7600            triggerDirection = Value::Str("ascending".into());
7601        }  else if (triggerDirection.as_str() == Some("down")) || (triggerDirection.as_str() == Some("below")) {
7602            triggerDirection = Value::Str("descending".into());
7603        }
7604        return Value::from(vec![triggerDirection, paramsOmitted]);
7605
7606    Value::Null
7607}
7608
7609    fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7610        let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[]);
7611        let mut paramsOmitted: Value = (if (isTrigger.as_bool() == Some(true)) { self.omit(params.clone(), Value::from(vec![Value::Str("trigger".into()), Value::Str("stop".into())]), &[]) } else { params });
7612        return Value::from(vec![isTrigger, paramsOmitted]);
7613
7614    Value::Null
7615}
7616
7617    fn is_trigger_order(&self, mut params: Value) -> Value {
7618        return self.handle_trigger_and_params(params);
7619
7620    Value::Null
7621}
7622
7623    fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7624        let mut params = get_arg(optional_args, 0, Value::Map({
7625    let mut m = indexmap::IndexMap::new();
7626    m
7627}));
7628        /*
7629         * @ignore
7630         * @method
7631         * @param {string} type Order type
7632         * @param {boolean} exchangeSpecificParam exchange specific postOnly
7633         * @param {object} [params] exchange specific params
7634         * @returns {boolean} true if a post only order, false otherwise
7635         */
7636        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7637        let mut postOnly: Value = self.safe_bool2(params, Value::Str("postOnly".into()), Value::Str("post_only".into()), &[Value::Bool(false)]);
7638        // we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
7639        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7640        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7641        let mut timeInForcePostOnly: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7642        if (postOnly.as_bool() != Some(true)) {
7643            postOnly = timeInForcePostOnly;
7644        }
7645        if (postOnly.as_bool() != Some(true)) {
7646            postOnly = exchangeSpecificParam;
7647        }
7648        if (postOnly.as_bool() == Some(true)) {
7649            if ioc || fok {
7650                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)));
7651            }  else if is_true(&isMarketOrder) {
7652                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7653            }  else {
7654                return Value::Bool(true);
7655            }
7656        }  else {
7657            return Value::Bool(false);
7658        }
7659
7660    Value::Null
7661}
7662
7663    fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7664        let mut params = get_arg(optional_args, 0, Value::Map({
7665    let mut m = indexmap::IndexMap::new();
7666    m
7667}));
7668        /*
7669         * @ignore
7670         * @method
7671         * @param {string} type Order type
7672         * @param {boolean} exchangeSpecificBoolean exchange specific postOnly
7673         * @param {object} [params] exchange specific params
7674         * @returns {Array}
7675         */
7676        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7677        let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
7678        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7679        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7680        let mut po: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7681        if (postOnly.as_bool() != Some(true)) {
7682            postOnly = po.clone();
7683        }
7684        if (postOnly.as_bool() != Some(true)) {
7685            postOnly = exchangeSpecificPostOnlyOption;
7686        }
7687        if (postOnly.as_bool() == Some(true)) {
7688            if ioc || fok {
7689                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)));
7690            }  else if is_true(&isMarketOrder) {
7691                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7692            }  else {
7693                let mut keysToOmit: Value = Value::Null;
7694                if matches!(&po, Value::Bool(true)) {
7695                    keysToOmit = Value::from(vec![Value::Str("timeInForce".into()), Value::Str("postOnly".into())]);
7696                }  else {
7697                    keysToOmit = Value::from(vec![Value::Str("postOnly".into())]);
7698                }
7699                let mut paramsOmitted: Value = self.omit(params.clone(), keysToOmit, &[]);
7700                return Value::from(vec![Value::Bool(true), paramsOmitted]);
7701            }
7702        }
7703        return Value::from(vec![Value::Bool(false), params]);
7704
7705    Value::Null
7706}
7707
7708    fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7709        let mut symbols = get_arg(optional_args, 0, Value::Null);
7710        let mut params = get_arg(optional_args, 1, Value::Map({
7711    let mut m = indexmap::IndexMap::new();
7712    m
7713}));
7714        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLastPrices() is not supported yet".into()))));
7715
7716    Value::Null
7717} }
7718
7719    fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7720        // async-virtual: try the derived exchange first
7721        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 {
7722            if !matches!(__v, crate::Value::Null) { return __v; }
7723        }
7724
7725        let mut params = get_arg(optional_args, 0, Value::Map({
7726    let mut m = indexmap::IndexMap::new();
7727    m
7728}));
7729        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFees() is not supported yet".into()))));
7730
7731    Value::Null
7732} }
7733
7734    fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7735        let mut params = get_arg(optional_args, 0, Value::Map({
7736    let mut m = indexmap::IndexMap::new();
7737    m
7738}));
7739        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFeesWs() is not supported yet".into()))));
7740
7741    Value::Null
7742} }
7743
7744    fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7745        let mut params = get_arg(optional_args, 0, Value::Map({
7746    let mut m = indexmap::IndexMap::new();
7747    m
7748}));
7749        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertCurrencies() is not supported yet".into()))));
7750
7751    Value::Null
7752} }
7753
7754    fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
7755        // virtual-dispatch (static: DerivedExchange::parse_open_interest(self, ...))
7756        { 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; } }
7757
7758        let mut market = get_arg(optional_args, 0, Value::Null);
7759        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOpenInterest () is not supported yet".into()))));
7760
7761    Value::Null
7762}
7763
7764    fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7765        let mut symbols = get_arg(optional_args, 0, Value::Null);
7766        let mut result: Value = Value::Map({
7767            let mut m = indexmap::IndexMap::new();
7768            m
7769        });
7770        {
7771                        let mut i: Value = Value::Int(0);
7772            let mut __for_first_153: bool = true;
7773            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) } {
7774            let mut entry: Value = get_value(&response, &i);
7775            let mut entry: Value = get_value(&response, &i);
7776            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[]);
7777            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7778                add_element_to_object(&mut result, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7779            }
7780        }
7781        }
7782        return self.filter_by_array(result, Value::Str("symbol".into()), &[symbols]);
7783
7784    Value::Null
7785}
7786
7787    fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7788        let mut market = get_arg(optional_args, 0, Value::Null);
7789        let mut since = get_arg(optional_args, 1, Value::Null);
7790        let mut limit = get_arg(optional_args, 2, Value::Null);
7791        let mut interests: Value = Value::from(vec![]);
7792        {
7793                        let mut i: Value = Value::Int(0);
7794            let mut __for_first_154: bool = true;
7795            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(&response).as_f64().unwrap_or(f64::NAN) } {
7796            let mut entry: Value = get_value(&response, &i);
7797            let mut entry: Value = get_value(&response, &i);
7798            let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[market.clone()]);
7799            append_to_array(&mut interests, interest);
7800        }
7801        }
7802        let mut sorted: Value = self.sort_by(interests, Value::Str("timestamp".into()), &[]);
7803        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
7804        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7805
7806    Value::Null
7807}
7808
7809    fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7810        // async-virtual: try the derived exchange first
7811        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 {
7812            if !matches!(__v, crate::Value::Null) { return __v; }
7813        }
7814
7815        let mut params = get_arg(optional_args, 0, Value::Map({
7816    let mut m = indexmap::IndexMap::new();
7817    m
7818}));
7819        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)) {
7820            self.load_markets(&[]).await;
7821            let mut market: Value = self.market(symbol);
7822            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7823            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7824                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports contract markets only".into()))));
7825            }
7826            let mut rates: Value = self.fetch_funding_rates(&[Value::from(vec![symbolResolved.clone()]), params]).await;
7827            let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
7828            if (rate == Value::Null) {
7829                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () returned no data for ".into())).into()), symbolResolved)));
7830            }  else {
7831                return rate;
7832            }
7833        }  else {
7834            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () is not supported yet".into()))));
7835        }
7836
7837    Value::Null
7838} }
7839
7840    fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7841        // async-virtual: try the derived exchange first
7842        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 {
7843            if !matches!(__v, crate::Value::Null) { return __v; }
7844        }
7845
7846        let mut params = get_arg(optional_args, 0, Value::Map({
7847    let mut m = indexmap::IndexMap::new();
7848    m
7849}));
7850        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)) {
7851            self.load_markets(&[]).await;
7852            let mut market: Value = self.market(symbol);
7853            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7854            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7855                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() supports contract markets only".into()))));
7856            }
7857            let mut rates: Value = self.fetch_funding_intervals(&[Value::from(vec![symbolResolved.clone()]), params]).await;
7858            let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
7859            if (rate == Value::Null) {
7860                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() returned no data for ".into())).into()), symbolResolved)));
7861            }  else {
7862                return rate;
7863            }
7864        }  else {
7865            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() is not supported yet".into()))));
7866        }
7867
7868    Value::Null
7869} }
7870
7871    fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7872        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7873        let mut since = get_arg(optional_args, 1, Value::Null);
7874        let mut limit = get_arg(optional_args, 2, Value::Null);
7875        let mut params = get_arg(optional_args, 3, Value::Map({
7876    let mut m = indexmap::IndexMap::new();
7877    m
7878}));
7879        /*
7880         * @method
7881         * @name exchange#fetchMarkOHLCV
7882         * @description fetches historical mark price candlestick data containing the open, high, low, and close price of a market
7883         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7884         * @param {string} timeframe the length of time each candle represents
7885         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7886         * @param {int} [limit] the maximum amount of candles to fetch
7887         * @param {object} [params] extra parameters specific to the exchange API endpoint
7888         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
7889         */
7890        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)) {
7891            let mut request: Value = Value::Map({
7892                let mut m = indexmap::IndexMap::new();
7893                    m.insert("price".to_string(), Value::Str("mark".into()));
7894                m
7895            });
7896            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7897        }  else {
7898            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkOHLCV () is not supported yet".into()))));
7899        }
7900} }
7901
7902    fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7903        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7904        let mut since = get_arg(optional_args, 1, Value::Null);
7905        let mut limit = get_arg(optional_args, 2, Value::Null);
7906        let mut params = get_arg(optional_args, 3, Value::Map({
7907    let mut m = indexmap::IndexMap::new();
7908    m
7909}));
7910        /*
7911         * @method
7912         * @name exchange#fetchIndexOHLCV
7913         * @description fetches historical index price candlestick data containing the open, high, low, and close price of a market
7914         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7915         * @param {string} timeframe the length of time each candle represents
7916         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7917         * @param {int} [limit] the maximum amount of candles to fetch
7918         * @param {object} [params] extra parameters specific to the exchange API endpoint
7919         * @returns {} A list of candles ordered as timestamp, open, high, low, close, undefined
7920         */
7921        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)) {
7922            let mut request: Value = Value::Map({
7923                let mut m = indexmap::IndexMap::new();
7924                    m.insert("price".to_string(), Value::Str("index".into()));
7925                m
7926            });
7927            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7928        }  else {
7929            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIndexOHLCV () is not supported yet".into()))));
7930        }
7931} }
7932
7933    fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7934        // async-virtual: try the derived exchange first
7935        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 {
7936            if !matches!(__v, crate::Value::Null) { return __v; }
7937        }
7938
7939        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7940        let mut since = get_arg(optional_args, 1, Value::Null);
7941        let mut limit = get_arg(optional_args, 2, Value::Null);
7942        let mut params = get_arg(optional_args, 3, Value::Map({
7943    let mut m = indexmap::IndexMap::new();
7944    m
7945}));
7946        /*
7947         * @method
7948         * @name exchange#fetchPremiumIndexOHLCV
7949         * @description fetches historical premium index price candlestick data containing the open, high, low, and close price of a market
7950         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7951         * @param {string} timeframe the length of time each candle represents
7952         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7953         * @param {int} [limit] the maximum amount of candles to fetch
7954         * @param {object} [params] extra parameters specific to the exchange API endpoint
7955         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
7956         */
7957        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)) {
7958            let mut request: Value = Value::Map({
7959                let mut m = indexmap::IndexMap::new();
7960                    m.insert("price".to_string(), Value::Str("premiumIndex".into()));
7961                m
7962            });
7963            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7964        }  else {
7965            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".into()))));
7966        }
7967} }
7968
7969    fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
7970        let mut params = get_arg(optional_args, 0, Value::Map({
7971    let mut m = indexmap::IndexMap::new();
7972    m
7973}));
7974        /*
7975         * @ignore
7976         * @method
7977         * Must add timeInForce to this.options to use this method
7978         * @returns {string} returns the exchange specific value for timeInForce
7979         */
7980        let mut timeInForce: Value = self.safe_string_upper_k(params, "timeInForce", &[]); // supported values GTC, IOC, PO
7981        if (timeInForce != Value::Null) {
7982            let mut exchangeValue: Value = self.safe_string(self.options.as_map().and_then(|__m| __m.get("timeInForce")).cloned().unwrap_or(Value::Null), timeInForce.clone(), &[]);
7983            if (exchangeValue == Value::Null) {
7984                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()))));
7985            }
7986            return exchangeValue;
7987        }
7988        return Value::Null;
7989
7990    Value::Null
7991}
7992
7993    fn convert_type_to_account(&self, mut account: Value) -> Value {
7994        /*
7995         * @ignore
7996         * @method
7997         * Must add accountsByType to this.options to use this method
7998         * @param {string} account key for account name in this.options['accountsByType']
7999         * @returns the exchange specific account name or the isolated margin id for transfers
8000         */
8001        let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
8002    let mut m = indexmap::IndexMap::new();
8003    m
8004})]);
8005        let mut lowercaseAccount: Value = to_lower(&account);
8006        if (in_op(&accountsByType, &lowercaseAccount)) {
8007            return get_value(&accountsByType, &lowercaseAccount);
8008        }
8009        let mut markets: Value = self.markets.clone();
8010        let mut marketsById: Value = self.markets_by_id.clone();
8011        if ((markets != Value::Null) && (in_op(&markets, &account))) || ((marketsById != Value::Null) && (in_op(&marketsById, &account))) {
8012            let mut market: Value = self.market(account.clone());
8013            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
8014        }  else {
8015            return account;
8016        }
8017
8018    Value::Null
8019}
8020
8021    fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
8022        let mut options = get_arg(optional_args, 0, Value::from(vec![]));
8023        /*
8024         * @ignore
8025         * @method
8026         * @param {string} methodName the name of the method that the argument is being checked for
8027         * @param {string} argument the argument's actual value provided
8028         * @param {string} argumentName the name of the argument being checked (for logging purposes)
8029         * @param {string[]} options a list of options that the argument can be
8030         * @returns {undefined}
8031         */
8032        let mut optionsLength: f64 = ((options.len() as i64) as f64);
8033        if (argument == Value::Null) || ((optionsLength > ((0i64) as f64)) && (!(self.in_array(argument, options.clone()).as_bool() == Some(true)))) {
8034            let mut messageOptions: Value = join(&options, &Value::Str(", ".into()));
8035            let mut message: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", 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).into()), Value::Str(" argument".into())).into());
8036            if (messageOptions.as_str() != Some("")) {
8037                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());
8038            }
8039            panic!("{}", crate::exchange_errors::arguments_required(message));
8040        }
8041}
8042
8043    fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
8044        /*
8045         * @ignore
8046         * @method
8047         * @param {string} symbol unified symbol of the market
8048         * @param {string} methodName name of the method that requires a symbol
8049         * @param {string} marginMode is either 'isolated' or 'cross'
8050         */
8051        if (marginMode.as_str() == Some("isolated")) && (symbol == Value::Null) {
8052            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()))));
8053        }  else if (marginMode.as_str() == Some("cross")) && (symbol != Value::Null) {
8054            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()))));
8055        }
8056}
8057
8058    fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
8059        let mut codes = get_arg(optional_args, 0, Value::Null);
8060        let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
8061        /*
8062         * @ignore
8063         * @method
8064         * @param {object[]|object} response unparsed response from the exchange
8065         * @param {string[]|undefined} codes the unified currency codes to fetch transactions fees for, returns all currencies when undefined
8066         * @param {str} currencyIdKey *should only be undefined when response is a dictionary* the object key that corresponds to the currency id
8067         * @returns {object} objects with withdraw and deposit fees, indexed by currency codes
8068         */
8069        let mut depositWithdrawFees: Value = Value::Map({
8070            let mut m = indexmap::IndexMap::new();
8071            m
8072        });
8073        let mut isArray: bool = matches!(&response, Value::Arr(_));
8074        let mut responseKeys: Value = response.clone();
8075        if !isArray {
8076            responseKeys = object_keys(&response);
8077        }
8078        {
8079                        let mut i: Value = Value::Int(0);
8080            let mut __for_first_155: bool = true;
8081            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) < get_array_length(&responseKeys).as_f64().unwrap_or(f64::NAN) } {
8082            let mut entry: Value = get_value(&responseKeys, &i);
8083            let mut entry: Value = get_value(&responseKeys, &i);
8084            let mut dictionary: Value = (if isArray { entry.clone() } else { get_value(&response, &entry) });
8085            let mut currencyId: Value = entry;
8086            if isArray {
8087                currencyId = (if (currencyIdKey == Value::Null) { Value::Null } else { self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]) });
8088            }
8089            let mut currency: Value = self.safe_currency(currencyId, &[]);
8090            let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
8091            if (codes == Value::Null) || self.in_array(code.clone(), codes.clone()).as_bool() == Some(true) {
8092                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])); }
8093            }
8094        }
8095        }
8096        return depositWithdrawFees;
8097
8098    Value::Null
8099}
8100
8101    fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8102        // virtual-dispatch (static: DerivedExchange::parse_deposit_withdraw_fee(self, ...))
8103        { 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; } }
8104
8105        let mut currency = get_arg(optional_args, 0, Value::Null);
8106        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositWithdrawFee() is not supported yet".into()))));
8107
8108    Value::Null
8109}
8110
8111    fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8112        return Value::Map({
8113    let mut m = indexmap::IndexMap::new();
8114        m.insert("info".to_string(), info);
8115        m.insert("withdraw".to_string(), Value::Map({
8116    let mut m = indexmap::IndexMap::new();
8117        m.insert("fee".to_string(), Value::Null);
8118        m.insert("percentage".to_string(), Value::Null);
8119    m
8120}));
8121        m.insert("deposit".to_string(), Value::Map({
8122    let mut m = indexmap::IndexMap::new();
8123        m.insert("fee".to_string(), Value::Null);
8124        m.insert("percentage".to_string(), Value::Null);
8125    m
8126}));
8127        m.insert("networks".to_string(), Value::Map({
8128    let mut m = indexmap::IndexMap::new();
8129    m
8130}));
8131    m
8132});
8133
8134    Value::Null
8135}
8136
8137    fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8138        let mut currency = get_arg(optional_args, 0, Value::Null);
8139        let __currency_empty = indexmap::IndexMap::new();
8140        let currency = currency.as_map().unwrap_or(&__currency_empty);
8141        /*
8142         * @ignore
8143         * @method
8144         * @description Takes a depositWithdrawFee structure and assigns the default values for withdraw and deposit
8145         * @param {object} fee A deposit withdraw fee structure
8146         * @param {object} currency A currency structure, the response from this.currency ()
8147         * @returns {object} A deposit withdraw fee structure
8148         */
8149        let mut networkKeys: Value = object_keys(&crate::value::get_value_k(&fee, "networks"));
8150        let mut numNetworks: f64 = ((networkKeys.len() as i64) as f64);
8151        if (numNetworks == 1.0) {
8152            { 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); };
8153            { 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); };
8154            return fee;
8155        }
8156        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 });
8157        {
8158                        let mut i: Value = Value::Int(0);
8159            let mut __for_first_156: bool = true;
8160            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) < numNetworks } {
8161            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);
8162            if (network.as_str() == currencyCode.as_str()) {
8163                { 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); };
8164                { 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); };
8165            }
8166        }
8167        }
8168        return fee;
8169
8170    Value::Null
8171}
8172
8173    fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8174        // virtual-dispatch (static: DerivedExchange::parse_income(self, ...))
8175        { 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; } }
8176
8177        let mut market = get_arg(optional_args, 0, Value::Null);
8178        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIncome () is not supported yet".into()))));
8179
8180    Value::Null
8181}
8182
8183    fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8184        let mut market = get_arg(optional_args, 0, Value::Null);
8185        let mut since = get_arg(optional_args, 1, Value::Null);
8186        let mut limit = get_arg(optional_args, 2, Value::Null);
8187        /*
8188         * @ignore
8189         * @method
8190         * @description parses funding fee info from exchange response
8191         * @param {object[]} incomes each item describes once instance of currency being received or paid
8192         * @param {object} market ccxt market
8193         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
8194         * @param {int} [limit] limits the number of items in the response
8195         * @returns {object[]} an array of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure}
8196         */
8197        let mut result: Value = Value::from(vec![]);
8198        {
8199                        let mut i: Value = Value::Int(0);
8200            let mut __for_first_157: bool = true;
8201            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) < get_array_length(&incomes).as_f64().unwrap_or(f64::NAN) } {
8202            let mut entry: Value = get_value(&incomes, &i);
8203            let mut entry: Value = get_value(&incomes, &i);
8204            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry, &[market.clone()]);
8205            append_to_array(&mut result, parsed);
8206        }
8207        }
8208        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8209        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8210        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8211
8212    Value::Null
8213}
8214
8215    fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8216        let mut symbols = get_arg(optional_args, 0, Value::Null);
8217        /*
8218         * @param {string[]|undefined} symbols list of unified symbols (first element selects the market)
8219         * @returns {MarketInterface|undefined} market structure for the first symbol, or undefined if symbols is undefined
8220         * Overloads: non-null `string[]` input yields `MarketInterface`; optional input yields `Market`.
8221         */
8222        if (symbols == Value::Null) {
8223            return Value::Null;
8224        }
8225        let mut firstMarket: Value = self.safe_string(symbols, Value::Int(0), &[]);
8226        if (firstMarket == Value::Null) {
8227            return Value::Null;
8228        }
8229        let mut market: Value = self.market(firstMarket);
8230        return market;
8231
8232    Value::Null
8233}
8234
8235    fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8236        let mut market = get_arg(optional_args, 0, Value::Null);
8237        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
8238        let mut since = get_arg(optional_args, 2, Value::Null);
8239        let mut limit = get_arg(optional_args, 3, Value::Null);
8240        let mut results: Value = Value::from(vec![]);
8241        {
8242                        let mut i: Value = Value::Int(0);
8243            let mut __for_first_158: bool = true;
8244            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) < ((ohlcvs.len() as i64) as f64) } {
8245            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()]));
8246        }
8247        }
8248        return results;
8249
8250    Value::Null
8251}
8252
8253    fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8254        let mut code = get_arg(optional_args, 0, Value::Null);
8255        let mut since = get_arg(optional_args, 1, Value::Null);
8256        let mut limit = get_arg(optional_args, 2, Value::Null);
8257        let mut params = get_arg(optional_args, 3, Value::Map({
8258    let mut m = indexmap::IndexMap::new();
8259    m
8260}));
8261        /*
8262         * @method
8263         * @name exchange#fetchTransactions
8264         * @deprecated
8265         * @description *DEPRECATED* use fetchDepositsWithdrawals instead
8266         * @param {string} code unified currency code for the currency of the deposit/withdrawals, default is undefined
8267         * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
8268         * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
8269         * @param {object} [params] extra parameters specific to the exchange API endpoint
8270         * @returns {object} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
8271         */
8272        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)) {
8273            return self.fetch_deposits_withdrawals(&[code, since, limit, params]).await;
8274        }  else {
8275            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactions () is not supported yet".into()))));
8276        }
8277} }
8278
8279    fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8280        let mut values = get_arg(optional_args, 0, Value::Null);
8281        return self.to_array(self.filter_by_array(objects, key, &[values, Value::Bool(false)]));
8282
8283    Value::Null
8284}
8285
8286    fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8287        let mut values = get_arg(optional_args, 0, Value::Null);
8288        return self.index_by(self.filter_by_array(objects, key.clone(), &[values, Value::Bool(false)]), key);
8289
8290    Value::Null
8291}
8292
8293    fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8294        let mut values = get_arg(optional_args, 0, Value::Null);
8295        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8296        return self.filter_by_array(objects, key, &[values, indexed]);
8297
8298    Value::Null
8299}
8300
8301    fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8302        let mut res: Value = Value::Map({
8303            let mut m = indexmap::IndexMap::new();
8304            m
8305        });
8306        if let Value::Dict(__d) = &mut res { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
8307    let mut m = indexmap::IndexMap::new();
8308    m
8309})); }
8310        add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data);
8311        return res;
8312
8313    Value::Null
8314}
8315
8316    fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8317        let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8318        let mut params = get_arg(optional_args, 1, Value::Map({
8319    let mut m = indexmap::IndexMap::new();
8320    m
8321}));
8322        let mut newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable = self.handle_option_integer_and_params(params, method, Value::Str("maxEntriesPerRequest".into()), &[]);
8323        let mut newMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8324        let mut paramsMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8325        let mut maxEntriesPerRequestOption: Value = (if (newMaxEntriesPerRequest != Value::Null) { newMaxEntriesPerRequest } else { maxEntriesPerRequest });
8326        let mut maxEntriesPerRequestResolved: Value = (if (maxEntriesPerRequestOption == Value::Null) { Value::Int(1000) } else { maxEntriesPerRequestOption }); // default to 1000
8327        return Value::from(vec![maxEntriesPerRequestResolved, paramsMaxEntriesPerRequest]);
8328
8329    Value::Null
8330}
8331
8332    fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8333        let mut symbol = get_arg(optional_args, 0, Value::Null);
8334        let mut since = get_arg(optional_args, 1, Value::Null);
8335        let mut limit = get_arg(optional_args, 2, Value::Null);
8336        let mut params = get_arg(optional_args, 3, Value::Map({
8337    let mut m = indexmap::IndexMap::new();
8338    m
8339}));
8340        let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8341        let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8342        let mut maxCalls: Value = Value::Int(10);
8343        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8344        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8345        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8346        let mut maxRetries: Value = Value::Int(3);
8347        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8348        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8349        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8350        let mut paginationDirectionparamsPaginationDirectionVariable = self.handle_option_and_params(paramsMaxRetries, method.clone(), Value::Str("paginationDirection".into()), &[Value::Str("backward".into())]);
8351        let mut paginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8352        let mut paramsPaginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8353        let mut paginationTimestamp: Value = Value::Null;
8354        let mut removeRepeatedOptionparamsRemoveRepeatedVariable = self.handle_option_and_params(paramsPaginationDirection, method.clone(), Value::Str("removeRepeated".into()), &[removeRepeated]);
8355        let mut removeRepeatedOption: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8356        let mut paramsRemoveRepeated: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8357        let mut calls: Value = Value::Int(0);
8358        let mut result: Value = Value::from(vec![]);
8359        let mut errors: Value = Value::Int(0);
8360        let mut until: Value = self.safe_integer_n(paramsRemoveRepeated.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("untill".into()), Value::Str("till".into())]), &[]); // do not omit it from params here
8361        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsRemoveRepeated]);
8362        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8363        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8364        if (paginationDirection.as_str() == Some("forward")) {
8365            if (since == Value::Null) {
8366                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" pagination requires a since argument when paginationDirection set to forward".into()))));
8367            }
8368            paginationTimestamp = since.clone();
8369        }
8370        while (calls.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN)) {
8371            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 });
8372            {
8373                if (paginationDirection.as_str() == Some("backward")) {
8374                    // do it backwards, starting from the last
8375                    // UNTIL filtering is required in order to work
8376                    if (paginationTimestamp != Value::Null) {
8377                        add_element_to_object(&mut paramsMaxEntriesPerRequest, &Value::Str("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 }));
8378                    }
8379                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (Value::Null).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8380                    let mut responseLength: Value = get_array_length(&response);
8381                    if is_true(&self.verbose) {
8382                        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());
8383                        if (paginationTimestamp != Value::Null) {
8384                            backwardMessage = Value::Str(format!("{}{}", backwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8385                        }
8386                        self.log(backwardMessage);
8387                    }
8388                    if (responseLength.as_f64() == Some(0.0)) {
8389                        break;
8390                    }
8391                    errors = Value::Int(0);
8392                    result = self.array_concat(result.clone(), response.clone());
8393                    let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
8394                    paginationTimestamp = self.safe_integer2(firstElement, Value::Str("timestamp".into()), Value::Int(0), &[]);
8395                    if (paginationTimestamp == Value::Null) {
8396                        break;
8397                    }
8398                    if (since != Value::Null) && (paginationTimestamp.as_f64().unwrap_or(f64::NAN) <= since.as_f64().unwrap_or(f64::NAN)) {
8399                        break;
8400                    }
8401                }  else {
8402                    // do it forwards, starting from the since
8403                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paginationTimestamp).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8404                    let mut responseLength: Value = get_array_length(&response);
8405                    if is_true(&self.verbose) {
8406                        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());
8407                        if (paginationTimestamp != Value::Null) {
8408                            forwardMessage = Value::Str(format!("{}{}", forwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8409                        }
8410                        self.log(forwardMessage);
8411                    }
8412                    if (responseLength.as_f64() == Some(0.0)) {
8413                        break;
8414                    }
8415                    errors = Value::Int(0);
8416                    result = self.array_concat(result.clone(), response.clone());
8417                    let mut last: Value = self.safe_value(response, (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 }), &[]);
8418                    let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[Value::Int(0)]);
8419                    if (lastTimestamp == Value::Null) {
8420                        break;
8421                    }
8422                    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 });
8423                    paginationTimestamp = nextPaginationTimestamp.clone();
8424                    if (until != Value::Null) && (nextPaginationTimestamp.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8425                        break;
8426                    }
8427                }
8428            }
8429        }
8430        let mut uniqueResults: Value = result.clone();
8431        if is_true(&removeRepeatedOption) {
8432            uniqueResults = self.remove_repeated_elements_from_array(result, &[]);
8433        }
8434        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8435        let mut sortedRes: Value = self.sort_by(uniqueResults, key.clone(), &[]);
8436        return self.filter_by_since_limit(sortedRes, &[since, limit, key]);
8437
8438    Value::Null
8439} }
8440
8441    fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8442        let mut symbol = get_arg(optional_args, 0, Value::Null);
8443        let mut since = get_arg(optional_args, 1, Value::Null);
8444        let mut limit = get_arg(optional_args, 2, Value::Null);
8445        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8446        let mut params = get_arg(optional_args, 4, Value::Map({
8447    let mut m = indexmap::IndexMap::new();
8448    m
8449}));
8450        let mut maxRetries: Value = Value::Int(3);
8451        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8452        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8453        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8454        let mut errors: Value = Value::Int(0);
8455        while is_less_than_or_equal(&errors, &maxRetriesOption) {
8456            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8457                if ((timeframe != Value::Null) && (timeframe.as_str() != Some(""))) && (method.as_str() != Some("fetchFundingRateHistory")) {
8458                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8459                }  else {
8460                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8461                }
8462             #[allow(unreachable_code)] { Value::Null }})).await;
8463match _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); 
8464                if matches!(&e, Value::Str(__s) if __s.contains("[RateLimitExceeded]")) {
8465                    panic!("{}", e);
8466                }
8467                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 });
8468                if errors.as_f64().unwrap_or(f64::NAN) > maxRetriesOption.as_f64().unwrap_or(f64::NAN) {
8469                    panic!("{}", e);
8470                }
8471             } }
8472        }
8473        return Value::from(vec![]);
8474
8475    Value::Null
8476} }
8477
8478    fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8479        let mut symbol = get_arg(optional_args, 0, Value::Null);
8480        let mut since = get_arg(optional_args, 1, Value::Null);
8481        let mut limit = get_arg(optional_args, 2, Value::Null);
8482        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8483        let mut params = get_arg(optional_args, 4, Value::Map({
8484    let mut m = indexmap::IndexMap::new();
8485    m
8486}));
8487        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8488        let mut maxCalls: Value = Value::Int(10);
8489        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8490        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8491        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8492        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsPaginationCalls]);
8493        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8494        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8495        // paginationDirection is only relevant to fetchPaginatedCallDynamic/Cursor; deterministic
8496        // pagination always walks forward internally, so strip it here to avoid leaking an
8497        // unrecognized param into the underlying exchange request (e.g. binance -1104 errors)
8498        let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("paginationDirection".into()), &[]);
8499        let mut current: Value = self.milliseconds();
8500        let mut tasks: Value = Value::from(vec![]);
8501        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 });
8502        let mut maxEntriesPerRequestValue: Value = self.require_value(maxEntriesPerRequestOption, &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".into())]);
8503        let mut step: Value = multiply(&time, &maxEntriesPerRequestValue);
8504        let mut until: Value = self.safe_integer2(paramsOmitted.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]); // do not omit it here
8505        let mut currentSince: Value = (match (&((match (&(current), &((multiply(&maxCallsPaginationCalls, &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(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 });
8506        if (since != Value::Null) {
8507            if (until != Value::Null) {
8508                // the recent-window floor below would jump past a fully-historical [ since, until ]
8509                // range and return an empty result - requiredCalls is validated against maxCalls
8510                // further down, so anchoring at since directly is safe here,
8511                // see https://github.com/ccxt/ccxt/issues/26252
8512                currentSince = since.clone();
8513            }  else {
8514                currentSince = crate::runtime::Math::max(&currentSince, &since);
8515            }
8516        }  else {
8517            currentSince = crate::runtime::Math::max(&currentSince, &Value::Int(1241440531000)); // avoid timestamps older than 2009
8518        }
8519        if (until != Value::Null) {
8520            if (since == Value::Null) {
8521                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".into()))));
8522            }
8523            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 }));
8524            if requiredCalls.as_f64().unwrap_or(f64::NAN) > maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8525                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(&maxCallsPaginationCalls)).into()), Value::Str(" required calls is ".into())).into()), to_string_val(&requiredCalls))));
8526            }
8527        }
8528        {
8529                        let mut i: Value = Value::Int(0);
8530            let mut __for_first_159: bool = true;
8531            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) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) } {
8532            if (until != Value::Null) && (currentSince.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8533                break;
8534            }
8535            if currentSince.as_f64().unwrap_or(f64::NAN) >= current.as_f64().unwrap_or(f64::NAN) {
8536                break;
8537            }
8538            append_to_array(&mut tasks, self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequestValue.clone(), timeframe.clone(), paramsOmitted.clone()]).await);
8539            currentSince = (match (&((match (&(currentSince), &(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(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 });
8540        }
8541        }
8542        let mut results: Value = promise_all(&tasks).await;
8543        let mut result: Value = Value::from(vec![]);
8544        {
8545                        let mut i: Value = Value::Int(0);
8546            let mut __for_first_160: bool = true;
8547            while { if !__for_first_160 { 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_160 = false; i.as_f64().unwrap_or(f64::NAN) < ((results.len() as i64) as f64) } {
8548            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));
8549        }
8550        }
8551        let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result, &[]);
8552        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8553        return self.filter_by_since_limit(uniqueResults, &[since, limit, key]);
8554
8555    Value::Null
8556} }
8557
8558// the 'symbol' slot is forwarded to `this[method]` untouched and is only compared against
8559// undefined here, so fetchPositions/fetchPositionsHistory legitimately pass a symbol list
8560    fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8561        let mut symbol = get_arg(optional_args, 0, Value::Null);
8562        let mut since = get_arg(optional_args, 1, Value::Null);
8563        let mut limit = get_arg(optional_args, 2, Value::Null);
8564        let mut params = get_arg(optional_args, 3, Value::Map({
8565    let mut m = indexmap::IndexMap::new();
8566    m
8567}));
8568        let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8569        let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8570        let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8571        let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8572        let mut maxCalls: Value = Value::Int(10);
8573        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8574        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8575        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8576        let mut maxRetries: Value = Value::Int(3);
8577        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8578        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8579        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8580        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8581        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8582        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8583        let mut cursorValue: Value = Value::Null;
8584        let mut i: Value = Value::Int(0);
8585        let mut errors: Value = Value::Int(0);
8586        let mut result: Value = Value::from(vec![]);
8587        let mut timeframe: Value = self.safe_string_k(paramsMaxEntriesPerRequest.clone(), "timeframe", &[]);
8588        let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("timeframe".into()), &[]); // reading the timeframe from the method arguments to avoid changing the signature
8589        while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8590            {
8591                if (cursorValue != Value::Null) {
8592                    if (cursorIncrement != Value::Null) {
8593                        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 });
8594                    }
8595                    add_element_to_object(&mut paramsOmitted, &cursorSent, cursorValue.clone());
8596                }
8597                let mut response: Value = Value::Null;
8598                if (method.as_str() == Some("fetchAccounts")) {
8599                    response = self.call_dynamic_checked(method.clone(), vec![(paramsOmitted).clone()]).await;
8600                }  else if (method.as_str() == Some("getLeverageTiersPaginated")) || (method.as_str() == Some("fetchPositions")) {
8601                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paramsOmitted).clone()]).await;
8602                }  else if (method.as_str() == Some("fetchOpenInterestHistory")) {
8603                    if !matches!(&symbol, Value::Str(_)) {
8604                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".into()))));
8605                    }
8606                    if (timeframe == Value::Null) {
8607                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".into()))));
8608                    }
8609                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8610                }  else {
8611                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8612                }
8613                errors = Value::Int(0);
8614                if (response == Value::Null) {
8615                    panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() returned empty response".into()))));
8616                }
8617                let mut responseLength: Value = Value::Int(response.len() as i64);
8618                if is_true(&self.verbose) {
8619                    let mut cursorString: Value = (if (cursorValue == Value::Null) { Value::Str("".into()) } else { cursorValue.clone() });
8620                    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 }));
8621                    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);
8622                    self.log(cursorMessage);
8623                }
8624                if (responseLength.as_f64() == Some(0.0)) {
8625                    break;
8626                }
8627                if (response != Value::Null) {
8628                    result = self.array_concat(result.clone(), response.clone());
8629                }
8630                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 }), &[]);
8631                // cursorValue = this.safeValue (last['info'], cursorReceived);
8632                cursorValue = Value::Null; // search for the cursor
8633                {
8634                                        let mut j: Value = Value::Int(0);
8635                    let mut __for_first_161: bool = true;
8636                    while { if !__for_first_161 { 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_161 = false; j.as_f64().unwrap_or(f64::NAN) < responseLength.as_f64().unwrap_or(f64::NAN) } {
8637                    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 });
8638                    let mut entry: Value = self.safe_dict(response.clone(), index, &[]);
8639                    let mut info: Value = self.safe_dict_k(entry, "info", &[]);
8640                    let mut cursor: Value = (if (cursorReceived == Value::Null) { Value::Null } else { self.safe_value(info, cursorReceived.clone(), &[]) });
8641                    if (cursor != Value::Null) {
8642                        cursorValue = cursor;
8643                        break;
8644                    }
8645                }
8646                }
8647                if (cursorValue == Value::Null) {
8648                    break;
8649                }
8650                let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[]);
8651                if (since == Value::Null) {
8652                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a since argument".into()))));
8653                }
8654                if (lastTimestamp != Value::Null) && lastTimestamp.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
8655                    break;
8656                }
8657            }
8658            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 });
8659        }
8660        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8661        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8662        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8663
8664    Value::Null
8665} }
8666
8667    fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8668        let mut symbol = get_arg(optional_args, 0, Value::Null);
8669        let mut since = get_arg(optional_args, 1, Value::Null);
8670        let mut limit = get_arg(optional_args, 2, Value::Null);
8671        let mut params = get_arg(optional_args, 3, Value::Map({
8672    let mut m = indexmap::IndexMap::new();
8673    m
8674}));
8675        let mut pageKey = get_arg(optional_args, 4, Value::Null);
8676        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8677        let mut maxCalls: Value = Value::Int(10);
8678        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8679        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8680        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8681        let mut maxRetries: Value = Value::Int(3);
8682        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8683        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8684        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8685        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8686        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8687        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8688        let mut i: Value = Value::Int(0);
8689        let mut errors: Value = Value::Int(0);
8690        let mut result: Value = Value::from(vec![]);
8691        while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8692            {
8693                add_element_to_object(&mut paramsMaxEntriesPerRequest, &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 }));
8694                let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8695                errors = Value::Int(0);
8696                let mut responseLength: Value = get_array_length(&response);
8697                if is_true(&self.verbose) {
8698                    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 })));
8699                    let mut incrementalMessage: Value = Value::Str(format!("{}{}", 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)).into());
8700                    self.log(incrementalMessage);
8701                }
8702                if (responseLength.as_f64() == Some(0.0)) {
8703                    break;
8704                }
8705                result = self.array_concat(result.clone(), response);
8706            }
8707            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 });
8708        }
8709        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8710        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8711        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8712
8713    Value::Null
8714} }
8715
8716    fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
8717        let mut first: Value = self.safe_value(result.clone(), Value::Int(0), &[]);
8718        if (first != Value::Null) {
8719            if (in_op(&first, &Value::Str("timestamp".into()))) {
8720                return self.sort_by(result.clone(), Value::Str("timestamp".into()), &[Value::Bool(true)]);
8721            }
8722            if (in_op(&first, &Value::Str("id".into()))) {
8723                return self.sort_by(result.clone(), Value::Str("id".into()), &[Value::Bool(true)]);
8724            }
8725        }
8726        return result;
8727
8728    Value::Null
8729}
8730
8731    fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
8732        let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
8733        let mut uniqueDic: Value = Value::Map({
8734            let mut m = indexmap::IndexMap::new();
8735            m
8736        });
8737        let mut uniqueResult: Value = Value::from(vec![]);
8738        {
8739                        let mut i: Value = Value::Int(0);
8740            let mut __for_first_162: bool = true;
8741            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) } {
8742            let mut entry: Value = get_value(&input, &i);
8743            let mut entry: Value = get_value(&input, &i);
8744            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", &[]) });
8745            if (uniqValue != Value::Null) && !(in_op(&uniqueDic, &uniqValue)) {
8746                if let Value::Dict(__d) = &mut uniqueDic { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&uniqValue), Value::Int(1)); }
8747                append_to_array(&mut uniqueResult, entry);
8748            }
8749        }
8750        }
8751        let mut valuesLength: f64 = ((uniqueResult.len() as i64) as f64);
8752        if valuesLength > ((0i64) as f64) {
8753            return uniqueResult;
8754        }
8755        return input;
8756
8757    Value::Null
8758}
8759
8760    fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
8761        let mut uniqueResult: Value = Value::Map({
8762            let mut m = indexmap::IndexMap::new();
8763            m
8764        });
8765        {
8766                        let mut i: Value = Value::Int(0);
8767            let mut __for_first_163: bool = true;
8768            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) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
8769            let mut entry: Value = get_value(&input, &i);
8770            let mut entry: Value = get_value(&input, &i);
8771            let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
8772            if (id == Value::Null) {
8773                let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
8774                let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
8775                let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
8776                let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
8777                // unique trade identifier
8778                if (timestamp == Value::Null) {
8779                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" removeRepeatedTradesFromArray() missing timestamp".into()))));
8780                }
8781                // optional parts are appended only when present, separators keep positions distinct
8782                id = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("t_".into()), to_string_val(&timestamp)).into()), Value::Str("_".into())).into());
8783                if (side != Value::Null) {
8784                    id = Value::Str(format!("{}{}", id, side).into());
8785                }
8786                id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
8787                if (price != Value::Null) {
8788                    id = Value::Str(format!("{}{}", id, price).into());
8789                }
8790                id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
8791                if (amount != Value::Null) {
8792                    id = Value::Str(format!("{}{}", id, amount).into());
8793                }
8794            }
8795            if (id != Value::Null) && !(in_op(&uniqueResult, &id)) {
8796                if let Value::Dict(__d) = &mut uniqueResult { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&id), entry); }
8797            }
8798        }
8799        }
8800        let mut values: Value = object_values(&uniqueResult);
8801        return values;
8802
8803    Value::Null
8804}
8805
8806    fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
8807        let mut keys: Value = object_keys(&dict);
8808        let mut newDict: Value = Value::Map({
8809            let mut m = indexmap::IndexMap::new();
8810            m
8811        });
8812        {
8813                        let mut i: Value = Value::Int(0);
8814            let mut __for_first_164: bool = true;
8815            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) < ((keys.len() as i64) as f64) } {
8816            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);
8817            if !(self.in_array(key.clone(), removeKeys.clone()).as_bool() == Some(true)) {
8818                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)); }
8819            }
8820        }
8821        }
8822        return newDict;
8823
8824    Value::Null
8825}
8826
8827    fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
8828        let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
8829        let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]);
8830        if (until != Value::Null) {
8831            if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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 }))); }
8832        }
8833        let mut paramsOmitted: Value = (if (until != Value::Null) { self.omit(params.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("till".into())]), &[]) } else { params });
8834        return Value::from(vec![request, paramsOmitted]);
8835
8836    Value::Null
8837}
8838
8839    fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
8840        let mut market = get_arg(optional_args, 0, Value::Null);
8841        let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
8842        if (symbol == Value::Null) {
8843            symbol = self.safe_string_k(market, "symbol", &[]);
8844        }
8845        return self.extend(interest.clone(), &[Value::Map({
8846    let mut m = indexmap::IndexMap::new();
8847        m.insert("symbol".to_string(), symbol);
8848        m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
8849        m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
8850        m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
8851        m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
8852        m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
8853        m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
8854        m.insert("info".to_string(), self.safe_value_k(interest, "info", &[]));
8855    m
8856})]);
8857
8858    Value::Null
8859}
8860
8861    fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
8862        // virtual-dispatch (static: DerivedExchange::parse_liquidation(self, ...))
8863        { 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; } }
8864
8865        let mut market = get_arg(optional_args, 0, Value::Null);
8866        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLiquidation () is not supported yet".into()))));
8867
8868    Value::Null
8869}
8870
8871    fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
8872        let mut market = get_arg(optional_args, 0, Value::Null);
8873        let mut since = get_arg(optional_args, 1, Value::Null);
8874        let mut limit = get_arg(optional_args, 2, Value::Null);
8875        /*
8876         * @ignore
8877         * @method
8878         * @description parses liquidation info from the exchange response
8879         * @param {object[]} liquidations each item describes an instance of a liquidation event
8880         * @param {object} market ccxt market
8881         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
8882         * @param {int} [limit] limits the number of items in the response
8883         * @returns {object[]} an array of [liquidation structures]{@link https://docs.ccxt.com/?id=liquidation-structure}
8884         */
8885        let mut result: Value = Value::from(vec![]);
8886        {
8887                        let mut i: Value = Value::Int(0);
8888            let mut __for_first_165: bool = true;
8889            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) < ((liquidations.len() as i64) as f64) } {
8890            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);
8891            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry, &[market.clone()]);
8892            append_to_array(&mut result, parsed);
8893        }
8894        }
8895        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8896        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8897        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8898
8899    Value::Null
8900}
8901
8902    fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8903        // virtual-dispatch (static: DerivedExchange::parse_greeks(self, ...))
8904        { 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; } }
8905
8906        let mut market = get_arg(optional_args, 0, Value::Null);
8907        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseGreeks () is not supported yet".into()))));
8908
8909    Value::Null
8910}
8911
8912    fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8913        let mut symbols = get_arg(optional_args, 0, Value::Null);
8914        let mut params = get_arg(optional_args, 1, Value::Map({
8915    let mut m = indexmap::IndexMap::new();
8916    m
8917}));
8918        //
8919        // the value of greeks is either a dict or a list
8920        //
8921        let mut results: Value = Value::from(vec![]);
8922        if (matches!(&greeks, Value::Arr(_))) {
8923            {
8924                                let mut i: Value = Value::Int(0);
8925                let mut __for_first_166: bool = true;
8926                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) < ((greeks.len() as i64) as f64) } {
8927                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), &[]);
8928                let mut greek: Value = self.extend(parsedTicker, &[params.clone()]);
8929                append_to_array(&mut results, greek.clone());
8930            }
8931            }
8932        }  else {
8933            let mut marketIds: Value = object_keys(&greeks);
8934            {
8935                                let mut i: Value = Value::Int(0);
8936                let mut __for_first_167: bool = true;
8937                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) < ((marketIds.len() as i64) as f64) } {
8938                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);
8939                let mut market: Value = self.safe_market(&[marketId.clone()]);
8940                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market]);
8941                let mut greek: Value = self.extend(parsed, &[params.clone()]);
8942                append_to_array(&mut results, greek);
8943            }
8944            }
8945        }
8946        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
8947        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbolsNormalized]);
8948
8949    Value::Null
8950}
8951
8952    fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
8953        let mut currency = get_arg(optional_args, 0, Value::Null);
8954        let mut market = get_arg(optional_args, 1, Value::Null);
8955        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOption () is not supported yet".into()))));
8956
8957    Value::Null
8958}
8959
8960    fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
8961        let mut currencyKey = get_arg(optional_args, 0, Value::Null);
8962        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8963        let mut optionStructures: Value = Value::Map({
8964            let mut m = indexmap::IndexMap::new();
8965            m
8966        });
8967        {
8968                        let mut i: Value = Value::Int(0);
8969            let mut __for_first_168: bool = true;
8970            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) } {
8971            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);
8972            let mut currencyId: Value = (if (currencyKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), currencyKey.clone(), &[]) });
8973            let mut currency: Value = self.safe_currency(currencyId, &[]);
8974            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
8975            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("option".into())]);
8976            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()]));
8977        }
8978        }
8979        return optionStructures;
8980
8981    Value::Null
8982}
8983
8984    fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
8985        let mut symbols = get_arg(optional_args, 0, Value::Null);
8986        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8987        let mut marketType = get_arg(optional_args, 2, Value::Null);
8988        let mut marginModeStructures: Value = Value::Map({
8989            let mut m = indexmap::IndexMap::new();
8990            m
8991        });
8992        let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); // default to swap
8993        {
8994                        let mut i: Value = Value::Int(0);
8995            let mut __for_first_169: bool = true;
8996            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) } {
8997            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);
8998            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
8999            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9000            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) {
9001                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()]));
9002            }
9003        }
9004        }
9005        return marginModeStructures;
9006
9007    Value::Null
9008}
9009
9010    fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
9011        // virtual-dispatch (static: DerivedExchange::parse_margin_mode(self, ...))
9012        { 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; } }
9013
9014        let mut market = get_arg(optional_args, 0, Value::Null);
9015        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginMode () is not supported yet".into()))));
9016
9017    Value::Null
9018}
9019
9020    fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
9021        let mut symbols = get_arg(optional_args, 0, Value::Null);
9022        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9023        let mut marketType = get_arg(optional_args, 2, Value::Null);
9024        let mut leverageStructures: Value = Value::Map({
9025            let mut m = indexmap::IndexMap::new();
9026            m
9027        });
9028        let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); // default to swap
9029        {
9030                        let mut i: Value = Value::Int(0);
9031            let mut __for_first_170: bool = true;
9032            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) < ((response.len() as i64) as f64) } {
9033            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);
9034            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9035            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9036            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) {
9037                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()]));
9038            }
9039        }
9040        }
9041        return leverageStructures;
9042
9043    Value::Null
9044}
9045
9046    fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
9047        // virtual-dispatch (static: DerivedExchange::parse_leverage(self, ...))
9048        { 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; } }
9049
9050        let mut market = get_arg(optional_args, 0, Value::Null);
9051        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLeverage () is not supported yet".into()))));
9052
9053    Value::Null
9054}
9055
9056    fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
9057        let mut code = get_arg(optional_args, 0, Value::Null);
9058        let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
9059        let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
9060        let mut since = get_arg(optional_args, 3, Value::Null);
9061        let mut limit = get_arg(optional_args, 4, Value::Null);
9062        let mut params = get_arg(optional_args, 5, Value::Map({
9063    let mut m = indexmap::IndexMap::new();
9064    m
9065}));
9066        let mut conversionsArray: Value = self.to_array(conversions);
9067        let mut result: Value = Value::from(vec![]);
9068        let mut fromCurrency: Value = Value::Null;
9069        let mut toCurrency: Value = Value::Null;
9070        {
9071                        let mut i: Value = Value::Int(0);
9072            let mut __for_first_171: bool = true;
9073            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) < ((conversionsArray.len() as i64) as f64) } {
9074            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);
9075            let mut fromId: Value = (if (fromCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]) });
9076            let mut toId: Value = (if (toCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]) });
9077            if (fromId != Value::Null) {
9078                fromCurrency = self.safe_currency(fromId, &[]);
9079            }
9080            if (toId != Value::Null) {
9081                toCurrency = self.safe_currency(toId, &[]);
9082            }
9083            let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry, &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
9084            append_to_array(&mut result, conversion);
9085        }
9086        }
9087        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
9088        if (code == Value::Null) {
9089            return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
9090        }
9091        let mut currency: Value = self.safe_currency(code, &[]);
9092        if (currency == Value::Null) {
9093            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseConversions() could not resolve currency".into()))));
9094        }
9095        let mut currencyCode: Value = currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
9096        let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".into()), currencyCode.clone(), &[]);
9097        let mut toConversion: Value = self.filter_by(sorted, Value::Str("toCurrency".into()), currencyCode, &[]);
9098        let mut both: Value = self.array_concat(fromConversion, toConversion);
9099        return self.filter_by_since_limit(both, &[since, limit]);
9100
9101    Value::Null
9102}
9103
9104    fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
9105        // virtual-dispatch (static: DerivedExchange::parse_conversion(self, ...))
9106        { 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; } }
9107
9108        let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
9109        let mut toCurrency = get_arg(optional_args, 1, Value::Null);
9110        if (conversion == Value::Null) {
9111            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9112        }
9113        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9114
9115    Value::Null
9116}
9117
9118    fn convert_expire_date(&self, mut date: Value) -> Value {
9119        if (date == Value::Null) {
9120            return Value::Null;
9121        }
9122        // parse YYMMDD to datetime string
9123        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);
9124        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);
9125        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);
9126        // the milliseconds are spelled out because every caller writes the result into
9127        // expiryDatetime, which types.ts documents in the ISO 8601 form with them
9128        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());
9129        return reconstructedDate;
9130
9131    Value::Null
9132}
9133
9134    fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9135        if (date == Value::Null) {
9136            return Value::Null;
9137        }
9138        // parse 240119 to 19JAN24
9139        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);
9140        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);
9141        let mut month: Value = Value::Null;
9142        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);
9143        if (monthRaw.as_str() == Some("01")) {
9144            month = Value::Str("JAN".into());
9145        }  else if (monthRaw.as_str() == Some("02")) {
9146            month = Value::Str("FEB".into());
9147        }  else if (monthRaw.as_str() == Some("03")) {
9148            month = Value::Str("MAR".into());
9149        }  else if (monthRaw.as_str() == Some("04")) {
9150            month = Value::Str("APR".into());
9151        }  else if (monthRaw.as_str() == Some("05")) {
9152            month = Value::Str("MAY".into());
9153        }  else if (monthRaw.as_str() == Some("06")) {
9154            month = Value::Str("JUN".into());
9155        }  else if (monthRaw.as_str() == Some("07")) {
9156            month = Value::Str("JUL".into());
9157        }  else if (monthRaw.as_str() == Some("08")) {
9158            month = Value::Str("AUG".into());
9159        }  else if (monthRaw.as_str() == Some("09")) {
9160            month = Value::Str("SEP".into());
9161        }  else if (monthRaw.as_str() == Some("10")) {
9162            month = Value::Str("OCT".into());
9163        }  else if (monthRaw.as_str() == Some("11")) {
9164            month = Value::Str("NOV".into());
9165        }  else if (monthRaw.as_str() == Some("12")) {
9166            month = Value::Str("DEC".into());
9167        }
9168        if (month == Value::Null) {
9169            panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9170        }
9171        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9172        return reconstructedDate;
9173
9174    Value::Null
9175}
9176
9177    fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9178        if (date == Value::Null) {
9179            return Value::Null;
9180        }
9181        // parse 03JAN24 to 240103.
9182        let mut monthMappping: Value = Value::Map({
9183            let mut m = indexmap::IndexMap::new();
9184                m.insert("JAN".to_string(), Value::Str("01".into()));
9185                m.insert("FEB".to_string(), Value::Str("02".into()));
9186                m.insert("MAR".to_string(), Value::Str("03".into()));
9187                m.insert("APR".to_string(), Value::Str("04".into()));
9188                m.insert("MAY".to_string(), Value::Str("05".into()));
9189                m.insert("JUN".to_string(), Value::Str("06".into()));
9190                m.insert("JUL".to_string(), Value::Str("07".into()));
9191                m.insert("AUG".to_string(), Value::Str("08".into()));
9192                m.insert("SEP".to_string(), Value::Str("09".into()));
9193                m.insert("OCT".to_string(), Value::Str("10".into()));
9194                m.insert("NOV".to_string(), Value::Str("11".into()));
9195                m.insert("DEC".to_string(), Value::Str("12".into()));
9196            m
9197        });
9198        // if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
9199        let mut datePadded: Value = date.clone();
9200        if (Value::Int(date.len() as i64).as_f64() == Some(6.0)) {
9201            datePadded = Value::Str(format!("{}{}", Value::Str("0".into()), date).into());
9202        }
9203        let mut year: Value = datePadded.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);
9204        let mut monthName: Value = datePadded.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);
9205        let mut month: Value = self.safe_string(monthMappping, monthName, &[]);
9206        let mut day: Value = datePadded.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);
9207        if (month == Value::Null) {
9208            panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9209        }
9210        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9211        return reconstructedDate;
9212
9213    Value::Null
9214}
9215
9216    fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9217        promise_all(&Value::from(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9218
9219    Value::Null
9220} }
9221
9222    fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9223        // virtual-dispatch (static: DerivedExchange::parse_margin_modification(self, ...))
9224        { 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; } }
9225
9226        let mut market = get_arg(optional_args, 0, Value::Null);
9227        if (data == Value::Null) {
9228            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9229        }
9230        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9231
9232    Value::Null
9233}
9234
9235    fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9236        let mut symbols = get_arg(optional_args, 0, Value::Null);
9237        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9238        let mut marketType = get_arg(optional_args, 2, Value::Null);
9239        let mut marginModifications: Value = Value::from(vec![]);
9240        if (response == Value::Null) {
9241            return marginModifications;
9242        }
9243        {
9244                        let mut i: Value = Value::Int(0);
9245            let mut __for_first_172: bool = true;
9246            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) < ((response.len() as i64) as f64) } {
9247            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);
9248            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9249            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
9250            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) {
9251                append_to_array(&mut marginModifications, <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info, &[market]));
9252            }
9253        }
9254        }
9255        return marginModifications;
9256
9257    Value::Null
9258}
9259
9260    fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9261        let mut code = get_arg(optional_args, 0, Value::Null);
9262        let mut params = get_arg(optional_args, 1, Value::Map({
9263    let mut m = indexmap::IndexMap::new();
9264    m
9265}));
9266        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfer () is not supported yet".into()))));
9267
9268    Value::Null
9269} }
9270
9271    fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9272        let mut code = get_arg(optional_args, 0, Value::Null);
9273        let mut since = get_arg(optional_args, 1, Value::Null);
9274        let mut limit = get_arg(optional_args, 2, Value::Null);
9275        let mut params = get_arg(optional_args, 3, Value::Map({
9276    let mut m = indexmap::IndexMap::new();
9277    m
9278}));
9279        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfers () is not supported yet".into()))));
9280
9281    Value::Null
9282} }
9283
9284    fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9285        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
9286        let mut params = get_arg(optional_args, 1, Value::Map({
9287    let mut m = indexmap::IndexMap::new();
9288    m
9289}));
9290        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCV () is not supported yet".into()))));
9291
9292    Value::Null
9293} }
9294
9295    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 {
9296        let mut params = get_arg(optional_args, 0, Value::Map({
9297    let mut m = indexmap::IndexMap::new();
9298    m
9299}));
9300        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdrawWs () is not supported yet".into()))));
9301
9302    Value::Null
9303} }
9304
9305    fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9306        let mut symbol = get_arg(optional_args, 0, Value::Null);
9307        let mut params = get_arg(optional_args, 1, Value::Map({
9308    let mut m = indexmap::IndexMap::new();
9309    m
9310}));
9311        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMyTrades () is not supported yet".into()))));
9312
9313    Value::Null
9314} }
9315
9316    fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9317        let mut symbol = get_arg(optional_args, 0, Value::Null);
9318        let mut since = get_arg(optional_args, 1, Value::Null);
9319        let mut limit = get_arg(optional_args, 2, Value::Null);
9320        let mut params = get_arg(optional_args, 3, Value::Map({
9321    let mut m = indexmap::IndexMap::new();
9322    m
9323}));
9324        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersByStatusWs () is not supported yet".into()))));
9325
9326    Value::Null
9327} }
9328
9329    fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9330        let mut symbols = get_arg(optional_args, 0, Value::Null);
9331        let mut params = get_arg(optional_args, 1, Value::Map({
9332    let mut m = indexmap::IndexMap::new();
9333    m
9334}));
9335        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchBidsAsks () is not supported yet".into()))));
9336
9337    Value::Null
9338} }
9339
9340    fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9341        let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9342        if (unsubHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &unsubHash)) {
9343            remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &unsubHash);
9344        }
9345        if !is_true(&subHashIsPrefix) {
9346            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &subHash)) {
9347                remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &subHash);
9348            }
9349            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("futures".into())), &subHash)) {
9350                let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), subHash));
9351                client.reject(&[Value::from(error.clone()), subHash.clone()]);
9352            }
9353        }  else {
9354            let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".into())));
9355            {
9356                                let mut i: Value = Value::Int(0);
9357                let mut __for_first_173: bool = true;
9358                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) < ((clientSubscriptions.len() as i64) as f64) } {
9359                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);
9360                if (sub != Value::Null) && (subHash != Value::Null) && (starts_with(&sub, &subHash)) {
9361                    remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &sub);
9362                }
9363            }
9364            }
9365            let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
9366            {
9367                                let mut i: Value = Value::Int(0);
9368                let mut __for_first_174: bool = true;
9369                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) < ((clientFutures.len() as i64) as f64) } {
9370                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);
9371                if (future != Value::Null) && (subHash != Value::Null) && (starts_with(&future, &subHash)) {
9372                    let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), future));
9373                    client.reject(&[Value::from(error), future.clone()]);
9374                }
9375            }
9376            }
9377        }
9378        client.resolve(&[Value::Bool(true), unsubHash]);
9379}
9380
9381    fn clean_cache(&mut self, mut subscription: Value) {
9382        let __subscription_empty = indexmap::IndexMap::new();
9383        let subscription = subscription.as_map().unwrap_or(&__subscription_empty);
9384        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);
9385        let mut symbols: Value = (match subscription.get("symbols") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9386        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
9387        if (topic.as_deref() == Some("ohlcv")) {
9388            let mut symbolsAndTimeframes: Value = (match subscription.get("symbolsAndTimeframes") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9389            {
9390                                let mut i: Value = Value::Int(0);
9391                let mut __for_first_175: bool = true;
9392                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) < ((symbolsAndTimeframes.len() as i64) as f64) } {
9393                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9394                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9395                let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9396                let mut timeframe: Value = self.safe_string(symbolAndTimeFrame, Value::Int(1), &[]);
9397                if (symbol == Value::Null) {
9398                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a symbol argument".into()))));
9399                }
9400                if (timeframe == Value::Null) {
9401                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a timeframe argument".into()))));
9402                }
9403                if (self.ohlcvs.clone() != Value::Null) && (in_op(&self.ohlcvs, &symbol)) {
9404                    if (in_op(&get_value(&self.ohlcvs, &symbol), &timeframe)) {
9405                        remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
9406                    }
9407                }
9408            }
9409            }
9410        }  else if symbolsLength > ((0i64) as f64) {
9411            {
9412                                let mut i: Value = Value::Int(0);
9413                let mut __for_first_176: bool = true;
9414                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) < ((symbols.len() as i64) as f64) } {
9415                let mut symbol: Value = get_value(&symbols, &i);
9416                let mut symbol: Value = get_value(&symbols, &i);
9417                if (topic.as_deref() == Some("trades")) {
9418                    if (in_op(&self.trades, &symbol)) {
9419                        remove(&mut self.trades.clone(), &symbol);
9420                    }
9421                }  else if (topic.as_deref() == Some("orderbook")) {
9422                    if (in_op(&self.orderbooks, &symbol)) {
9423                        remove(&mut self.orderbooks.clone(), &symbol);
9424                    }
9425                }  else if (topic.as_deref() == Some("ticker")) {
9426                    if (in_op(&self.tickers, &symbol)) {
9427                        remove(&mut self.tickers.clone(), &symbol);
9428                    }
9429                }  else if (topic.as_deref() == Some("bidsasks")) {
9430                    if (in_op(&self.bidsasks, &symbol)) {
9431                        remove(&mut self.bidsasks.clone(), &symbol);
9432                    }
9433                }
9434            }
9435            }
9436        }  else {
9437            if (topic.as_deref() == Some("myTrades")) && (self.myTrades.clone() != Value::Null) {
9438                self.myTrades = Value::Null;
9439            }  else if (topic.as_deref() == Some("orders")) && (self.orders.clone() != Value::Null) {
9440                self.orders = Value::Null;
9441            }  else if (topic.as_deref() == Some("positions")) && (self.positions.clone() != Value::Null) {
9442                self.positions = Value::Null;
9443                let mut clients: Value = object_values(&self.clients);
9444                {
9445                                        let mut i: Value = Value::Int(0);
9446                    let mut __for_first_177: bool = true;
9447                    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) < ((clients.len() as i64) as f64) } {
9448                    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);
9449                    let mut futures: Value = get_value(&client, &Value::Str("futures".into()));
9450                    if (futures != Value::Null) && (matches!(&futures, Value::Dict(__d) if __d.contains_key("fetchPositionsSnapshot"))) {
9451                        remove(&mut futures, &Value::Str("fetchPositionsSnapshot".into()));
9452                    }
9453                }
9454                }
9455            }  else if ((topic.as_deref() == Some("ticker")) || (topic.as_deref() == Some("markPrice"))) && (self.tickers.clone() != Value::Null) {
9456                let mut tickerSymbols: Value = object_keys(&self.tickers);
9457                {
9458                                        let mut i: Value = Value::Int(0);
9459                    let mut __for_first_178: bool = true;
9460                    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) < ((tickerSymbols.len() as i64) as f64) } {
9461                    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);
9462                    if (in_op(&self.tickers, &tickerSymbol)) {
9463                        remove(&mut self.tickers.clone(), &tickerSymbol);
9464                    }
9465                }
9466                }
9467            }  else if (topic.as_deref() == Some("bidsasks")) && (self.bidsasks.clone() != Value::Null) {
9468                let mut bidsaskSymbols: Value = object_keys(&self.bidsasks);
9469                {
9470                                        let mut i: Value = Value::Int(0);
9471                    let mut __for_first_179: bool = true;
9472                    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) < ((bidsaskSymbols.len() as i64) as f64) } {
9473                    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);
9474                    if (in_op(&self.bidsasks, &bidsaskSymbol)) {
9475                        remove(&mut self.bidsasks.clone(), &bidsaskSymbol);
9476                    }
9477                }
9478                }
9479            }
9480        }
9481}
9482
9483    fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9484        if ms.as_f64().unwrap_or(f64::NAN) <= ((0i64) as f64) {
9485            return Value::Str("".into());
9486        }
9487        let mut second: Value = Value::Int(1000);
9488        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 });
9489        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 });
9490        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 });
9491        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 });
9492        if (mod_val(&ms, &week).as_f64() == Some(0.0)) {
9493            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()));
9494        }
9495        if (mod_val(&ms, &day).as_f64() == Some(0.0)) {
9496            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()));
9497        }
9498        if (mod_val(&ms, &hour).as_f64() == Some(0.0)) {
9499            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()));
9500        }
9501        if (mod_val(&ms, &minute).as_f64() == Some(0.0)) {
9502            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()));
9503        }
9504        if (mod_val(&ms, &second).as_f64() == Some(0.0)) {
9505            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()));
9506        }
9507        return Value::Str("".into());
9508
9509    Value::Null
9510}
9511
9512    fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9513        let mut params = get_arg(optional_args, 0, Value::Map({
9514    let mut m = indexmap::IndexMap::new();
9515    m
9516}));
9517        return Value::Bool(false);
9518
9519    Value::Null
9520} }
9521    fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9522        let mut side = get_arg(optional_args, 0, Value::Null);
9523        let mut params = get_arg(optional_args, 1, Value::Map({
9524    let mut m = indexmap::IndexMap::new();
9525    m
9526}));
9527        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closePosition() is not supported yet".into()))));
9528
9529    Value::Null
9530} }
9531
9532    fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9533        let mut params = get_arg(optional_args, 0, Value::Map({
9534    let mut m = indexmap::IndexMap::new();
9535    m
9536}));
9537        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closeAllPositions() is not supported yet".into()))));
9538
9539    Value::Null
9540} }
9541
9542    fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9543        let mut params = get_arg(optional_args, 0, 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(" editOrders() is not supported yet".into()))));
9548
9549    Value::Null
9550} }
9551
9552    fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9553        let mut symbol = get_arg(optional_args, 0, Value::Null);
9554        let mut since = get_arg(optional_args, 1, Value::Null);
9555        let mut limit = get_arg(optional_args, 2, Value::Null);
9556        let mut params = get_arg(optional_args, 3, Value::Map({
9557    let mut m = indexmap::IndexMap::new();
9558    m
9559}));
9560        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".into()))));
9561
9562    Value::Null
9563} }
9564
9565    fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9566        // async-virtual: try the derived exchange first
9567        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 {
9568            if !matches!(__v, crate::Value::Null) { return __v; }
9569        }
9570
9571        let mut since = get_arg(optional_args, 0, Value::Null);
9572        let mut limit = get_arg(optional_args, 1, Value::Null);
9573        let mut params = get_arg(optional_args, 2, Value::Map({
9574    let mut m = indexmap::IndexMap::new();
9575    m
9576}));
9577        /*
9578         * @method
9579         * @name exchange#fetchPositionHistory
9580         * @description fetches the history of margin added or reduced from contract isolated positions
9581         * @param {string} [symbol] unified market symbol
9582         * @param {int} [since] timestamp in ms of the position
9583         * @param {int} [limit] the maximum amount of candles to fetch, default=1000
9584         * @param {object} params extra parameters specific to the exchange api endpoint
9585         * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
9586         */
9587        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)) {
9588            let mut positions: Value = self.fetch_positions_history(&[Value::from(vec![symbol]), since, limit, params]).await;
9589            return positions;
9590        }  else {
9591            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionHistory () is not supported yet".into()))));
9592        }
9593} }
9594
9595    fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9596        // async-virtual: try the derived exchange first
9597        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 {
9598            if !matches!(__v, crate::Value::Null) { return __v; }
9599        }
9600
9601        let mut symbols = get_arg(optional_args, 0, Value::Null);
9602        let mut since = get_arg(optional_args, 1, Value::Null);
9603        let mut limit = get_arg(optional_args, 2, Value::Null);
9604        let mut params = get_arg(optional_args, 3, Value::Map({
9605    let mut m = indexmap::IndexMap::new();
9606    m
9607}));
9608        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsHistory () is not supported yet".into()))));
9609
9610    Value::Null
9611} }
9612
9613    fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9614        let mut symbols = get_arg(optional_args, 0, Value::Null);
9615        let mut params = get_arg(optional_args, 1, Value::Map({
9616    let mut m = indexmap::IndexMap::new();
9617    m
9618}));
9619        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsRisk() is not supported yet".into()))));
9620
9621    Value::Null
9622} }
9623
9624    fn fetch_positions_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9625        let mut params = get_arg(optional_args, 0, Value::Map({
9626    let mut m = indexmap::IndexMap::new();
9627    m
9628}));
9629        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9630
9631    Value::Null
9632} }
9633
9634    fn fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9635        let mut params = get_arg(optional_args, 0, Value::Map({
9636    let mut m = indexmap::IndexMap::new();
9637    m
9638}));
9639        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9640
9641    Value::Null
9642} }
9643
9644    fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9645        let mut symbol = get_arg(optional_args, 0, Value::Null);
9646        let mut params = get_arg(optional_args, 1, Value::Map({
9647    let mut m = indexmap::IndexMap::new();
9648    m
9649}));
9650        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPosition() is not supported yet".into()))));
9651
9652    Value::Null
9653} }
9654
9655    fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9656        let mut since = get_arg(optional_args, 0, Value::Null);
9657        let mut limit = get_arg(optional_args, 1, Value::Null);
9658        let mut params = get_arg(optional_args, 2, Value::Map({
9659    let mut m = indexmap::IndexMap::new();
9660    m
9661}));
9662        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTradesForSymbols() is not supported yet".into()))));
9663
9664    Value::Null
9665} }
9666
9667    fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9668        let mut since = get_arg(optional_args, 0, Value::Null);
9669        let mut limit = get_arg(optional_args, 1, Value::Null);
9670        let mut params = get_arg(optional_args, 2, Value::Map({
9671    let mut m = indexmap::IndexMap::new();
9672    m
9673}));
9674        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTradesForSymbols() is not supported yet".into()))));
9675
9676    Value::Null
9677} }
9678
9679    fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9680        let mut symbols = get_arg(optional_args, 0, Value::Null);
9681        let mut params = get_arg(optional_args, 1, Value::Map({
9682    let mut m = indexmap::IndexMap::new();
9683    m
9684}));
9685        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBidsAsks() is not supported yet".into()))));
9686
9687    Value::Null
9688} }
9689
9690    fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9691        let mut params = get_arg(optional_args, 0, Value::Map({
9692    let mut m = indexmap::IndexMap::new();
9693    m
9694}));
9695        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)) {
9696            self.load_markets(&[]).await;
9697            let mut market: Value = self.market(symbol);
9698            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
9699            let mut tickers: Value = self.fetch_mark_prices(&[Value::from(vec![symbolResolved.clone()]), params]).await;
9700            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
9701            if (ticker == Value::Null) {
9702                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() could not find a ticker for ".into())).into()), symbolResolved)));
9703            }  else {
9704                return ticker;
9705            }
9706        }  else {
9707            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9708        }
9709
9710    Value::Null
9711} }
9712
9713    fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9714        let mut symbols = get_arg(optional_args, 0, Value::Null);
9715        let mut params = get_arg(optional_args, 1, Value::Map({
9716    let mut m = indexmap::IndexMap::new();
9717    m
9718}));
9719        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9720
9721    Value::Null
9722} }
9723
9724    fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9725        let mut symbols = get_arg(optional_args, 0, Value::Null);
9726        let mut params = get_arg(optional_args, 1, Value::Map({
9727    let mut m = indexmap::IndexMap::new();
9728    m
9729}));
9730        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBidsAsks() is not supported yet".into()))));
9731
9732    Value::Null
9733} }
9734
9735    fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9736        let mut params = get_arg(optional_args, 0, Value::Map({
9737    let mut m = indexmap::IndexMap::new();
9738    m
9739}));
9740        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrice () is not supported yet".into()))));
9741
9742    Value::Null
9743} }
9744
9745    fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9746        let mut symbols = get_arg(optional_args, 0, Value::Null);
9747        let mut params = get_arg(optional_args, 1, Value::Map({
9748    let mut m = indexmap::IndexMap::new();
9749    m
9750}));
9751        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrices () is not supported yet".into()))));
9752
9753    Value::Null
9754} }
9755
9756    fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9757        let mut limit = get_arg(optional_args, 0, Value::Null);
9758        let mut params = get_arg(optional_args, 1, Value::Map({
9759    let mut m = indexmap::IndexMap::new();
9760    m
9761}));
9762        panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchL3OrderBook() is not supported yet".into()))));
9763
9764    Value::Null
9765} }
9766
9767    fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9768        let mut limit = get_arg(optional_args, 0, Value::Null);
9769        let mut params = get_arg(optional_args, 1, Value::Map({
9770    let mut m = indexmap::IndexMap::new();
9771    m
9772}));
9773        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBookForSymbols() is not supported yet".into()))));
9774
9775    Value::Null
9776} }
9777
9778    fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9779        let mut since = get_arg(optional_args, 0, Value::Null);
9780        let mut limit = get_arg(optional_args, 1, Value::Null);
9781        let mut params = get_arg(optional_args, 2, Value::Map({
9782    let mut m = indexmap::IndexMap::new();
9783    m
9784}));
9785        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrdersForSymbols() is not supported yet".into()))));
9786
9787    Value::Null
9788} }
9789
9790    fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9791        let mut symbol = get_arg(optional_args, 0, Value::Null);
9792        let mut params = get_arg(optional_args, 1, Value::Map({
9793    let mut m = indexmap::IndexMap::new();
9794    m
9795}));
9796        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersWs() is not supported yet".into()))));
9797
9798    Value::Null
9799} }
9800
9801    fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9802        let mut symbol = get_arg(optional_args, 0, Value::Null);
9803        let mut params = get_arg(optional_args, 1, Value::Map({
9804    let mut m = indexmap::IndexMap::new();
9805    m
9806}));
9807        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrderWs() is not supported yet".into()))));
9808
9809    Value::Null
9810} }
9811
9812    fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9813        let mut symbol = get_arg(optional_args, 0, Value::Null);
9814        let mut params = get_arg(optional_args, 1, Value::Map({
9815    let mut m = indexmap::IndexMap::new();
9816    m
9817}));
9818        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersWs() is not supported yet".into()))));
9819
9820    Value::Null
9821} }
9822
9823    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 {
9824        let mut params = get_arg(optional_args, 0, Value::Map({
9825    let mut m = indexmap::IndexMap::new();
9826    m
9827}));
9828        return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
9829
9830    Value::Null
9831} }
9832
9833    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 {
9834        let mut params = get_arg(optional_args, 0, Value::Map({
9835    let mut m = indexmap::IndexMap::new();
9836    m
9837}));
9838        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
9839
9840    Value::Null
9841} }
9842
9843    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 {
9844        let mut params = get_arg(optional_args, 0, Value::Map({
9845    let mut m = indexmap::IndexMap::new();
9846    m
9847}));
9848        return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
9849
9850    Value::Null
9851} }
9852
9853    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 {
9854        let mut params = get_arg(optional_args, 0, Value::Map({
9855    let mut m = indexmap::IndexMap::new();
9856    m
9857}));
9858        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
9859
9860    Value::Null
9861} }
9862
9863    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 {
9864        let mut params = get_arg(optional_args, 0, Value::Map({
9865    let mut m = indexmap::IndexMap::new();
9866    m
9867}));
9868        /*
9869         * @method
9870         * @name createMarketOrderWithCostWs
9871         * @description create a market order by providing the symbol, side and cost
9872         * @param {string} symbol unified symbol of the market to create an order in
9873         * @param {string} side 'buy' or 'sell'
9874         * @param {float} cost how much you want to trade in units of the quote currency
9875         * @param {object} [params] extra parameters specific to the exchange API endpoint
9876         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
9877         */
9878        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)))) {
9879            return self.create_order_ws(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
9880        }
9881        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCostWs() is not supported yet".into()))));
9882
9883    Value::Null
9884} }
9885
9886    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 {
9887        let mut price = get_arg(optional_args, 0, Value::Null);
9888        let mut params = get_arg(optional_args, 1, Value::Map({
9889    let mut m = indexmap::IndexMap::new();
9890    m
9891}));
9892        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
9893
9894    Value::Null
9895} }
9896
9897    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 {
9898        let mut params = get_arg(optional_args, 0, Value::Map({
9899    let mut m = indexmap::IndexMap::new();
9900    m
9901}));
9902        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
9903
9904    Value::Null
9905} }
9906
9907    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 {
9908        let mut price = get_arg(optional_args, 0, Value::Null);
9909        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
9910        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
9911        let mut params = get_arg(optional_args, 3, Value::Map({
9912    let mut m = indexmap::IndexMap::new();
9913    m
9914}));
9915        /*
9916         * @method
9917         * @name createOrderWithTakeProfitAndStopLossWs
9918         * @description create an order with a stop loss or take profit attached (type 3)
9919         * @param {string} symbol unified symbol of the market to create an order in
9920         * @param {string} type 'market' or 'limit'
9921         * @param {string} side 'buy' or 'sell'
9922         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
9923         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
9924         * @param {float} [takeProfit] the take profit price, in units of the quote currency
9925         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
9926         * @param {object} [params] extra parameters specific to the exchange API endpoint
9927         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
9928         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
9929         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
9930         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
9931         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
9932         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
9933         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
9934         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
9935         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
9936         */
9937        let mut paramsValue: Value = 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()]);
9938        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)) {
9939            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsValue]).await;
9940        }
9941        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".into()))));
9942
9943    Value::Null
9944} }
9945
9946    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 {
9947        let mut price = get_arg(optional_args, 0, Value::Null);
9948        let mut params = get_arg(optional_args, 1, Value::Map({
9949    let mut m = indexmap::IndexMap::new();
9950    m
9951}));
9952        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWs() is not supported yet".into()))));
9953
9954    Value::Null
9955} }
9956
9957    fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9958        let mut params = get_arg(optional_args, 0, Value::Map({
9959    let mut m = indexmap::IndexMap::new();
9960    m
9961}));
9962        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrdersWs () is not supported yet".into()))));
9963
9964    Value::Null
9965} }
9966
9967    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 {
9968        let mut price = get_arg(optional_args, 0, Value::Null);
9969        let mut params = get_arg(optional_args, 1, Value::Map({
9970    let mut m = indexmap::IndexMap::new();
9971    m
9972}));
9973        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)) {
9974            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrderWs() is not supported yet".into()))));
9975        }
9976        let mut query: Value = self.extend(params, &[Value::Map({
9977            let mut m = indexmap::IndexMap::new();
9978                m.insert("postOnly".to_string(), Value::Bool(true));
9979            m
9980        })]);
9981        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
9982
9983    Value::Null
9984} }
9985
9986    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 {
9987        let mut price = get_arg(optional_args, 0, Value::Null);
9988        let mut params = get_arg(optional_args, 1, Value::Map({
9989    let mut m = indexmap::IndexMap::new();
9990    m
9991}));
9992        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)) {
9993            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrderWs() is not supported yet".into()))));
9994        }
9995        let mut query: Value = self.extend(params, &[Value::Map({
9996            let mut m = indexmap::IndexMap::new();
9997                m.insert("reduceOnly".to_string(), Value::Bool(true));
9998            m
9999        })]);
10000        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10001
10002    Value::Null
10003} }
10004
10005    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 {
10006        let mut params = get_arg(optional_args, 0, Value::Map({
10007    let mut m = indexmap::IndexMap::new();
10008    m
10009}));
10010        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)) {
10011            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrderWs() is not supported yet".into()))));
10012        }
10013        let mut query: Value = self.extend(params, &[Value::Map({
10014            let mut m = indexmap::IndexMap::new();
10015                m.insert("stopPrice".to_string(), triggerPrice);
10016            m
10017        })]);
10018        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
10019
10020    Value::Null
10021} }
10022
10023    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 {
10024        let mut price = get_arg(optional_args, 0, Value::Null);
10025        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10026        let mut params = get_arg(optional_args, 2, Value::Map({
10027    let mut m = indexmap::IndexMap::new();
10028    m
10029}));
10030        /*
10031         * @method
10032         * @name createStopLossOrderWs
10033         * @description create a trigger stop loss order (type 2)
10034         * @param {string} symbol unified symbol of the market to create an order in
10035         * @param {string} type 'market' or 'limit'
10036         * @param {string} side 'buy' or 'sell'
10037         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10038         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10039         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
10040         * @param {object} [params] extra parameters specific to the exchange API endpoint
10041         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10042         */
10043        if (stopLossPrice == Value::Null) {
10044            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".into()))));
10045        }
10046        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10047            let mut m = indexmap::IndexMap::new();
10048                m.insert("stopLossPrice".to_string(), stopLossPrice);
10049            m
10050        })]);
10051        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)) {
10052            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10053        }
10054        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() is not supported yet".into()))));
10055
10056    Value::Null
10057} }
10058
10059    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 {
10060        let mut params = get_arg(optional_args, 0, Value::Map({
10061    let mut m = indexmap::IndexMap::new();
10062    m
10063}));
10064        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)) {
10065            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrderWs() is not supported yet".into()))));
10066        }
10067        let mut query: Value = self.extend(params, &[Value::Map({
10068            let mut m = indexmap::IndexMap::new();
10069                m.insert("stopPrice".to_string(), triggerPrice);
10070            m
10071        })]);
10072        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
10073
10074    Value::Null
10075} }
10076
10077    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 {
10078        let mut price = get_arg(optional_args, 0, Value::Null);
10079        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10080        let mut params = get_arg(optional_args, 2, Value::Map({
10081    let mut m = indexmap::IndexMap::new();
10082    m
10083}));
10084        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)) {
10085            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() is not supported yet".into()))));
10086        }
10087        if (triggerPrice == Value::Null) {
10088            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() requires a stopPrice argument".into()))));
10089        }
10090        let mut query: Value = self.extend(params, &[Value::Map({
10091            let mut m = indexmap::IndexMap::new();
10092                m.insert("stopPrice".to_string(), triggerPrice);
10093            m
10094        })]);
10095        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10096
10097    Value::Null
10098} }
10099
10100    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 {
10101        let mut price = get_arg(optional_args, 0, Value::Null);
10102        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10103        let mut params = get_arg(optional_args, 2, Value::Map({
10104    let mut m = indexmap::IndexMap::new();
10105    m
10106}));
10107        /*
10108         * @method
10109         * @name createTakeProfitOrderWs
10110         * @description create a trigger take profit order (type 2)
10111         * @param {string} symbol unified symbol of the market to create an order in
10112         * @param {string} type 'market' or 'limit'
10113         * @param {string} side 'buy' or 'sell'
10114         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10115         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10116         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
10117         * @param {object} [params] extra parameters specific to the exchange API endpoint
10118         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10119         */
10120        if (takeProfitPrice == Value::Null) {
10121            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".into()))));
10122        }
10123        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10124            let mut m = indexmap::IndexMap::new();
10125                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
10126            m
10127        })]);
10128        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)) {
10129            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10130        }
10131        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() is not supported yet".into()))));
10132
10133    Value::Null
10134} }
10135
10136    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 {
10137        let mut price = get_arg(optional_args, 0, Value::Null);
10138        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10139        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10140        let mut params = get_arg(optional_args, 3, Value::Map({
10141    let mut m = indexmap::IndexMap::new();
10142    m
10143}));
10144        /*
10145         * @method
10146         * @name createTrailingAmountOrderWs
10147         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
10148         * @param {string} symbol unified symbol of the market to create an order in
10149         * @param {string} type 'market' or 'limit'
10150         * @param {string} side 'buy' or 'sell'
10151         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10152         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10153         * @param {float} trailingAmount the quote amount to trail away from the current market price
10154         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10155         * @param {object} [params] extra parameters specific to the exchange API endpoint
10156         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10157         */
10158        if (trailingAmount == Value::Null) {
10159            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".into()))));
10160        }
10161        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10162        if (trailingTriggerPrice != Value::Null) {
10163            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10164        }
10165        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)) {
10166            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10167        }
10168        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() is not supported yet".into()))));
10169
10170    Value::Null
10171} }
10172
10173    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 {
10174        let mut price = get_arg(optional_args, 0, Value::Null);
10175        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10176        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10177        let mut params = get_arg(optional_args, 3, Value::Map({
10178    let mut m = indexmap::IndexMap::new();
10179    m
10180}));
10181        /*
10182         * @method
10183         * @name createTrailingPercentOrderWs
10184         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
10185         * @param {string} symbol unified symbol of the market to create an order in
10186         * @param {string} type 'market' or 'limit'
10187         * @param {string} side 'buy' or 'sell'
10188         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10189         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10190         * @param {float} trailingPercent the percent to trail away from the current market price
10191         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10192         * @param {object} [params] extra parameters specific to the exchange API endpoint
10193         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10194         */
10195        if (trailingPercent == Value::Null) {
10196            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".into()))));
10197        }
10198        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10199        if (trailingTriggerPrice != Value::Null) {
10200            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10201        }
10202        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)) {
10203            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10204        }
10205        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() is not supported yet".into()))));
10206
10207    Value::Null
10208} }
10209
10210    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 {
10211        let mut price = get_arg(optional_args, 0, Value::Null);
10212        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10213        let mut params = get_arg(optional_args, 2, Value::Map({
10214    let mut m = indexmap::IndexMap::new();
10215    m
10216}));
10217        /*
10218         * @method
10219         * @name createTriggerOrderWs
10220         * @description create a trigger stop order (type 1)
10221         * @param {string} symbol unified symbol of the market to create an order in
10222         * @param {string} type 'market' or 'limit'
10223         * @param {string} side 'buy' or 'sell'
10224         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10225         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10226         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10227         * @param {object} [params] extra parameters specific to the exchange API endpoint
10228         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10229         */
10230        if (triggerPrice == Value::Null) {
10231            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".into()))));
10232        }
10233        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10234            let mut m = indexmap::IndexMap::new();
10235                m.insert("triggerPrice".to_string(), triggerPrice);
10236            m
10237        })]);
10238        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)) {
10239            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10240        }
10241        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() is not supported yet".into()))));
10242
10243    Value::Null
10244} }
10245
10246    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 {
10247        let mut amount = get_arg(optional_args, 0, Value::Null);
10248        let mut price = get_arg(optional_args, 1, Value::Null);
10249        let mut params = get_arg(optional_args, 2, Value::Map({
10250    let mut m = indexmap::IndexMap::new();
10251    m
10252}));
10253        self.cancel_order_ws(id, &[symbol.clone()]).await;
10254        return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10255
10256    Value::Null
10257} }
10258
10259    fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10260        let mut symbol = get_arg(optional_args, 0, Value::Null);
10261        let mut since = get_arg(optional_args, 1, Value::Null);
10262        let mut limit = get_arg(optional_args, 2, Value::Null);
10263        let mut params = get_arg(optional_args, 3, Value::Map({
10264    let mut m = indexmap::IndexMap::new();
10265    m
10266}));
10267        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)) {
10268            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10269            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
10270        }
10271        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrdersWs() is not supported yet".into()))));
10272
10273    Value::Null
10274} }
10275
10276    fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10277        let mut symbol = get_arg(optional_args, 0, Value::Null);
10278        let mut since = get_arg(optional_args, 1, Value::Null);
10279        let mut limit = get_arg(optional_args, 2, Value::Null);
10280        let mut params = get_arg(optional_args, 3, Value::Map({
10281    let mut m = indexmap::IndexMap::new();
10282    m
10283}));
10284        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTradesWs() is not supported yet".into()))));
10285
10286    Value::Null
10287} }
10288
10289    fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10290        let mut symbol = get_arg(optional_args, 0, Value::Null);
10291        let mut since = get_arg(optional_args, 1, Value::Null);
10292        let mut limit = get_arg(optional_args, 2, Value::Null);
10293        let mut params = get_arg(optional_args, 3, Value::Map({
10294    let mut m = indexmap::IndexMap::new();
10295    m
10296}));
10297        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)) {
10298            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10299            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
10300        }
10301        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrdersWs() is not supported yet".into()))));
10302
10303    Value::Null
10304} }
10305
10306    fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10307        let mut limit = get_arg(optional_args, 0, Value::Null);
10308        let mut params = get_arg(optional_args, 1, Value::Map({
10309    let mut m = indexmap::IndexMap::new();
10310    m
10311}));
10312        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBookWs() is not supported yet".into()))));
10313
10314    Value::Null
10315} }
10316
10317    fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10318        let mut symbol = get_arg(optional_args, 0, Value::Null);
10319        let mut params = get_arg(optional_args, 1, Value::Map({
10320    let mut m = indexmap::IndexMap::new();
10321    m
10322}));
10323        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderWs() is not supported yet".into()))));
10324
10325    Value::Null
10326} }
10327
10328    fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10329        let mut symbol = get_arg(optional_args, 0, Value::Null);
10330        let mut since = get_arg(optional_args, 1, Value::Null);
10331        let mut limit = get_arg(optional_args, 2, Value::Null);
10332        let mut params = get_arg(optional_args, 3, Value::Map({
10333    let mut m = indexmap::IndexMap::new();
10334    m
10335}));
10336        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersWs() is not supported yet".into()))));
10337
10338    Value::Null
10339} }
10340
10341    fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10342        let mut params = get_arg(optional_args, 0, Value::Map({
10343    let mut m = indexmap::IndexMap::new();
10344    m
10345}));
10346        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionWs() is not supported yet".into()))));
10347
10348    Value::Null
10349} }
10350
10351    fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10352        let mut symbols = get_arg(optional_args, 0, Value::Null);
10353        let mut params = get_arg(optional_args, 1, Value::Map({
10354    let mut m = indexmap::IndexMap::new();
10355    m
10356}));
10357        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10358
10359    Value::Null
10360} }
10361
10362    fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10363        let mut params = get_arg(optional_args, 0, Value::Map({
10364    let mut m = indexmap::IndexMap::new();
10365    m
10366}));
10367        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)) {
10368            self.load_markets(&[]).await;
10369            let mut market: Value = self.market(symbol);
10370            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10371            let mut tickers: Value = self.fetch_tickers_ws(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10372            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10373            if (ticker == Value::Null) {
10374                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() could not find a ticker for ".into())).into()), symbolResolved)));
10375            }  else {
10376                return ticker;
10377            }
10378        }  else {
10379            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() is not supported yet".into()))));
10380        }
10381
10382    Value::Null
10383} }
10384
10385    fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10386        let mut symbols = 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        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickersWs() is not supported yet".into()))));
10392
10393    Value::Null
10394} }
10395
10396    fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10397        let mut since = get_arg(optional_args, 0, Value::Null);
10398        let mut limit = get_arg(optional_args, 1, Value::Null);
10399        let mut params = get_arg(optional_args, 2, Value::Map({
10400    let mut m = indexmap::IndexMap::new();
10401    m
10402}));
10403        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradesWs() is not supported yet".into()))));
10404
10405    Value::Null
10406} }
10407
10408
10409    fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10410        // async-virtual: try the derived exchange first
10411        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 {
10412            if !matches!(__v, crate::Value::Null) { return __v; }
10413        }
10414
10415        let mut since = get_arg(optional_args, 0, Value::Null);
10416        let mut limit = get_arg(optional_args, 1, Value::Null);
10417        let mut params = get_arg(optional_args, 2, Value::Map({
10418    let mut m = indexmap::IndexMap::new();
10419    m
10420}));
10421        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() is not supported yet".into()))));
10422
10423    Value::Null
10424} }
10425
10426    fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10427        let mut since = get_arg(optional_args, 0, Value::Null);
10428        let mut limit = get_arg(optional_args, 1, Value::Null);
10429        let mut params = get_arg(optional_args, 2, Value::Map({
10430    let mut m = indexmap::IndexMap::new();
10431    m
10432}));
10433        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTrades() is not supported yet".into()))));
10434
10435    Value::Null
10436} }
10437
10438    fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10439        // async-virtual: try the derived exchange first
10440        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 {
10441            if !matches!(__v, crate::Value::Null) { return __v; }
10442        }
10443
10444        let mut limit = get_arg(optional_args, 0, Value::Null);
10445        let mut params = get_arg(optional_args, 1, Value::Map({
10446    let mut m = indexmap::IndexMap::new();
10447    m
10448}));
10449        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() is not supported yet".into()))));
10450
10451    Value::Null
10452} }
10453
10454    fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10455        let mut limit = get_arg(optional_args, 0, Value::Null);
10456        let mut params = get_arg(optional_args, 1, Value::Map({
10457    let mut m = indexmap::IndexMap::new();
10458    m
10459}));
10460        let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".into()), Value::Str("maxRetries".into()), &[Value::Int(3)]);
10461        {
10462                        let mut i: Value = Value::Int(0);
10463            let mut __for_first_180: bool = true;
10464            while { if !__for_first_180 { 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_180 = false; i.as_f64().unwrap_or(f64::NAN) < fetchSnapshotMaxRetries.as_f64().unwrap_or(f64::NAN) } {
10465            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10466                let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10467                return orderBook;
10468             #[allow(unreachable_code)] { Value::Null }})).await;
10469match _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); 
10470                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) {
10471                    panic!("{}", e);
10472                }
10473             } }
10474        }
10475        }
10476        return Value::Null;
10477
10478    Value::Null
10479} }
10480
10481    fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10482        let mut limit = get_arg(optional_args, 0, Value::Null);
10483        let mut params = get_arg(optional_args, 1, Value::Map({
10484    let mut m = indexmap::IndexMap::new();
10485    m
10486}));
10487        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBook() is not supported yet".into()))));
10488
10489    Value::Null
10490} }
10491
10492    fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10493        // async-virtual: try the derived exchange first
10494        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 {
10495            if !matches!(__v, crate::Value::Null) { return __v; }
10496        }
10497
10498        let mut params = get_arg(optional_args, 0, Value::Map({
10499    let mut m = indexmap::IndexMap::new();
10500    m
10501}));
10502        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)) {
10503            let mut openInterests: Value = self.fetch_open_interests(&[Value::from(vec![symbol.clone()]), params]).await;
10504            let mut openInterest: Value = self.safe_dict(openInterests, symbol, &[]);
10505            return openInterest;
10506        }  else {
10507            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterest() is not supported yet".into()))));
10508        }
10509
10510    Value::Null
10511} }
10512
10513    fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10514        let mut limit = get_arg(optional_args, 0, Value::Null);
10515        let mut params = get_arg(optional_args, 1, Value::Map({
10516    let mut m = indexmap::IndexMap::new();
10517    m
10518}));
10519        let mut orderbook: Value = self.fetch_order_book(symbol, &[limit, params]).await;
10520        return self.extend(orderbook.clone(), &[Value::Map({
10521    let mut m = indexmap::IndexMap::new();
10522        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), &[]));
10523        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)]));
10524    m
10525})]);
10526
10527    Value::Null
10528} }
10529
10530    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 {
10531        let mut price = get_arg(optional_args, 0, Value::Null);
10532        let mut params = get_arg(optional_args, 1, Value::Map({
10533    let mut m = indexmap::IndexMap::new();
10534    m
10535}));
10536        return self.edit_limit_order(id, symbol, Value::Str("buy".into()), amount, &[price, params]).await;
10537
10538    Value::Null
10539} }
10540
10541    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 {
10542        let mut price = get_arg(optional_args, 0, Value::Null);
10543        let mut params = get_arg(optional_args, 1, Value::Map({
10544    let mut m = indexmap::IndexMap::new();
10545    m
10546}));
10547        return self.edit_limit_order(id, symbol, Value::Str("sell".into()), amount, &[price, params]).await;
10548
10549    Value::Null
10550} }
10551
10552    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 {
10553        let mut price = get_arg(optional_args, 0, Value::Null);
10554        let mut params = get_arg(optional_args, 1, Value::Map({
10555    let mut m = indexmap::IndexMap::new();
10556    m
10557}));
10558        return self.edit_order(id, symbol, Value::Str("limit".into()), side, &[amount, price, params]).await;
10559
10560    Value::Null
10561} }
10562
10563    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 {
10564        // async-virtual: try the derived exchange first
10565        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 {
10566            if !matches!(__v, crate::Value::Null) { return __v; }
10567        }
10568
10569        let mut amount = get_arg(optional_args, 0, Value::Null);
10570        let mut price = get_arg(optional_args, 1, Value::Null);
10571        let mut params = get_arg(optional_args, 2, Value::Map({
10572    let mut m = indexmap::IndexMap::new();
10573    m
10574}));
10575        self.cancel_order(id, &[symbol.clone()]).await;
10576        return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10577
10578    Value::Null
10579} }
10580
10581    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 {
10582        let mut amount = get_arg(optional_args, 0, Value::Null);
10583        let mut price = get_arg(optional_args, 1, Value::Null);
10584        let mut params = get_arg(optional_args, 2, Value::Map({
10585    let mut m = indexmap::IndexMap::new();
10586    m
10587}));
10588        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10589            let mut m = indexmap::IndexMap::new();
10590                m.insert("clientOrderId".to_string(), clientOrderId);
10591            m
10592        })]);
10593        return self.edit_order(Value::Str("".into()), symbol, type_var, side, &[amount, price, extendedParams]).await;
10594
10595    Value::Null
10596} }
10597
10598    fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10599        // async-virtual: try the derived exchange first
10600        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 {
10601            if !matches!(__v, crate::Value::Null) { return __v; }
10602        }
10603
10604        let mut params = get_arg(optional_args, 0, Value::Map({
10605    let mut m = indexmap::IndexMap::new();
10606    m
10607}));
10608        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPosition() is not supported yet".into()))));
10609
10610    Value::Null
10611} }
10612
10613    fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10614        let mut symbols = get_arg(optional_args, 0, Value::Null);
10615        let mut since = get_arg(optional_args, 1, Value::Null);
10616        let mut limit = get_arg(optional_args, 2, Value::Null);
10617        let mut params = get_arg(optional_args, 3, Value::Map({
10618    let mut m = indexmap::IndexMap::new();
10619    m
10620}));
10621        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPositions() is not supported yet".into()))));
10622
10623    Value::Null
10624} }
10625
10626    fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10627        let mut symbols = get_arg(optional_args, 0, Value::Null);
10628        let mut since = get_arg(optional_args, 1, Value::Null);
10629        let mut limit = get_arg(optional_args, 2, Value::Null);
10630        let mut params = get_arg(optional_args, 3, Value::Map({
10631    let mut m = indexmap::IndexMap::new();
10632    m
10633}));
10634        return self.watch_positions(&[symbols, since, limit, params]).await;
10635
10636    Value::Null
10637} }
10638
10639    fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10640        // async-virtual: try the derived exchange first
10641        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 {
10642            if !matches!(__v, crate::Value::Null) { return __v; }
10643        }
10644
10645        let mut symbols = get_arg(optional_args, 0, Value::Null);
10646        let mut params = get_arg(optional_args, 1, Value::Map({
10647    let mut m = indexmap::IndexMap::new();
10648    m
10649}));
10650        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10651
10652    Value::Null
10653} }
10654
10655    fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10656        // async-virtual: try the derived exchange first
10657        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 {
10658            if !matches!(__v, crate::Value::Null) { return __v; }
10659        }
10660
10661        let mut params = get_arg(optional_args, 0, Value::Map({
10662    let mut m = indexmap::IndexMap::new();
10663    m
10664}));
10665        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)) {
10666            self.load_markets(&[]).await;
10667            let mut market: Value = self.market(symbol);
10668            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10669            let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10670            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10671            if (ticker == Value::Null) {
10672                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() could not find a ticker for ".into())).into()), symbolResolved)));
10673            }  else {
10674                return ticker;
10675            }
10676        }  else {
10677            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() is not supported yet".into()))));
10678        }
10679
10680    Value::Null
10681} }
10682
10683    fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10684        let mut params = get_arg(optional_args, 0, Value::Map({
10685    let mut m = indexmap::IndexMap::new();
10686    m
10687}));
10688        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTicker() is not supported yet".into()))));
10689
10690    Value::Null
10691} }
10692
10693    fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10694        // async-virtual: try the derived exchange first
10695        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 {
10696            if !matches!(__v, crate::Value::Null) { return __v; }
10697        }
10698
10699        let mut symbols = get_arg(optional_args, 0, Value::Null);
10700        let mut params = get_arg(optional_args, 1, Value::Map({
10701    let mut m = indexmap::IndexMap::new();
10702    m
10703}));
10704        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() is not supported yet".into()))));
10705
10706    Value::Null
10707} }
10708
10709    fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10710        let mut symbols = get_arg(optional_args, 0, Value::Null);
10711        let mut params = get_arg(optional_args, 1, Value::Map({
10712    let mut m = indexmap::IndexMap::new();
10713    m
10714}));
10715        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTickers() is not supported yet".into()))));
10716
10717    Value::Null
10718} }
10719
10720    fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10721        // async-virtual: try the derived exchange first
10722        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 {
10723            if !matches!(__v, crate::Value::Null) { return __v; }
10724        }
10725
10726        let mut symbol = get_arg(optional_args, 0, Value::Null);
10727        let mut params = get_arg(optional_args, 1, Value::Map({
10728    let mut m = indexmap::IndexMap::new();
10729    m
10730}));
10731        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() is not supported yet".into()))));
10732
10733    Value::Null
10734} }
10735
10736/*
10737 * @method
10738 * @name fetchOrderWithClientOrderId
10739 * @description create a market order by providing the symbol, side and cost
10740 * @param {string} clientOrderId client order Id
10741 * @param {string} symbol unified symbol of the market to create an order in
10742 * @param {object} [params] extra parameters specific to the exchange API endpoint
10743 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10744 */
10745    fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10746        let mut symbol = get_arg(optional_args, 0, Value::Null);
10747        let mut params = get_arg(optional_args, 1, Value::Map({
10748    let mut m = indexmap::IndexMap::new();
10749    m
10750}));
10751        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10752            let mut m = indexmap::IndexMap::new();
10753                m.insert("clientOrderId".to_string(), clientOrderId);
10754            m
10755        })]);
10756        return self.fetch_order(Value::Str("".into()), &[symbol, extendedParams]).await;
10757
10758    Value::Null
10759} }
10760
10761    fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10762        let mut symbol = get_arg(optional_args, 0, Value::Null);
10763        let mut params = get_arg(optional_args, 1, Value::Map({
10764    let mut m = indexmap::IndexMap::new();
10765    m
10766}));
10767        // TODO: TypeScript: change method signature by replacing
10768        // Promise<string> with Promise<Order['status']>.
10769        let mut order: Value = self.fetch_order(id, &[symbol, params]).await;
10770        return order.as_map().and_then(|__m| __m.get("status")).cloned().unwrap_or(Value::Null);
10771
10772    Value::Null
10773} }
10774
10775    fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10776        let mut params = get_arg(optional_args, 0, Value::Map({
10777    let mut m = indexmap::IndexMap::new();
10778    m
10779}));
10780        return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
10781
10782    Value::Null
10783} }
10784
10785    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 {
10786        // async-virtual: try the derived exchange first
10787        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 {
10788            if !matches!(__v, crate::Value::Null) { return __v; }
10789        }
10790
10791        let mut price = get_arg(optional_args, 0, Value::Null);
10792        let mut params = get_arg(optional_args, 1, Value::Map({
10793    let mut m = indexmap::IndexMap::new();
10794    m
10795}));
10796        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() is not supported yet".into()))));
10797
10798    Value::Null
10799} }
10800
10801    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 {
10802        let mut price = get_arg(optional_args, 0, Value::Null);
10803        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10804        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10805        let mut params = get_arg(optional_args, 3, Value::Map({
10806    let mut m = indexmap::IndexMap::new();
10807    m
10808}));
10809        /*
10810         * @method
10811         * @name createTrailingAmountOrder
10812         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
10813         * @param {string} symbol unified symbol of the market to create an order in
10814         * @param {string} type 'market' or 'limit'
10815         * @param {string} side 'buy' or 'sell'
10816         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10817         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10818         * @param {float} trailingAmount the quote amount to trail away from the current market price
10819         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10820         * @param {object} [params] extra parameters specific to the exchange API endpoint
10821         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10822         */
10823        if (trailingAmount == Value::Null) {
10824            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".into()))));
10825        }
10826        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10827        if (trailingTriggerPrice != Value::Null) {
10828            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10829        }
10830        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)) {
10831            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10832        }
10833        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() is not supported yet".into()))));
10834
10835    Value::Null
10836} }
10837
10838    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 {
10839        let mut price = get_arg(optional_args, 0, Value::Null);
10840        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10841        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10842        let mut params = get_arg(optional_args, 3, Value::Map({
10843    let mut m = indexmap::IndexMap::new();
10844    m
10845}));
10846        /*
10847         * @method
10848         * @name createTrailingPercentOrder
10849         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
10850         * @param {string} symbol unified symbol of the market to create an order in
10851         * @param {string} type 'market' or 'limit'
10852         * @param {string} side 'buy' or 'sell'
10853         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10854         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10855         * @param {float} trailingPercent the percent to trail away from the current market price
10856         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10857         * @param {object} [params] extra parameters specific to the exchange API endpoint
10858         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10859         */
10860        if (trailingPercent == Value::Null) {
10861            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".into()))));
10862        }
10863        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10864        if (trailingTriggerPrice != Value::Null) {
10865            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10866        }
10867        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)) {
10868            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10869        }
10870        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() is not supported yet".into()))));
10871
10872    Value::Null
10873} }
10874
10875    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 {
10876        let mut params = get_arg(optional_args, 0, Value::Map({
10877    let mut m = indexmap::IndexMap::new();
10878    m
10879}));
10880        /*
10881         * @method
10882         * @name createMarketOrderWithCost
10883         * @description create a market order by providing the symbol, side and cost
10884         * @param {string} symbol unified symbol of the market to create an order in
10885         * @param {string} side 'buy' or 'sell'
10886         * @param {float} cost how much you want to trade in units of the quote currency
10887         * @param {object} [params] extra parameters specific to the exchange API endpoint
10888         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10889         */
10890        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)))) {
10891            return self.create_order(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
10892        }
10893        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCost() is not supported yet".into()))));
10894
10895    Value::Null
10896} }
10897
10898    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 {
10899        let mut params = get_arg(optional_args, 0, Value::Map({
10900    let mut m = indexmap::IndexMap::new();
10901    m
10902}));
10903        /*
10904         * @method
10905         * @name createMarketBuyOrderWithCost
10906         * @description create a market buy order by providing the symbol and cost
10907         * @param {string} symbol unified symbol of the market to create an order in
10908         * @param {float} cost how much you want to trade in units of the quote currency
10909         * @param {object} [params] extra parameters specific to the exchange API endpoint
10910         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10911         */
10912        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))) {
10913            return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Int(1), params]).await;
10914        }
10915        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() is not supported yet".into()))));
10916
10917    Value::Null
10918} }
10919
10920    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 {
10921        let mut params = get_arg(optional_args, 0, Value::Map({
10922    let mut m = indexmap::IndexMap::new();
10923    m
10924}));
10925        /*
10926         * @method
10927         * @name createMarketSellOrderWithCost
10928         * @description create a market sell order by providing the symbol and cost
10929         * @param {string} symbol unified symbol of the market to create an order in
10930         * @param {float} cost how much you want to trade in units of the quote currency
10931         * @param {object} [params] extra parameters specific to the exchange API endpoint
10932         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10933         */
10934        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))) {
10935            return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), cost, &[Value::Int(1), params]).await;
10936        }
10937        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketSellOrderWithCost() is not supported yet".into()))));
10938
10939    Value::Null
10940} }
10941
10942    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 {
10943        let mut price = get_arg(optional_args, 0, Value::Null);
10944        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10945        let mut params = get_arg(optional_args, 2, Value::Map({
10946    let mut m = indexmap::IndexMap::new();
10947    m
10948}));
10949        /*
10950         * @method
10951         * @name createTriggerOrder
10952         * @description create a trigger stop order (type 1)
10953         * @param {string} symbol unified symbol of the market to create an order in
10954         * @param {string} type 'market' or 'limit'
10955         * @param {string} side 'buy' or 'sell'
10956         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10957         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10958         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10959         * @param {object} [params] extra parameters specific to the exchange API endpoint
10960         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10961         */
10962        if (triggerPrice == Value::Null) {
10963            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() requires a triggerPrice argument".into()))));
10964        }
10965        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10966            let mut m = indexmap::IndexMap::new();
10967                m.insert("triggerPrice".to_string(), triggerPrice);
10968            m
10969        })]);
10970        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)) {
10971            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10972        }
10973        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() is not supported yet".into()))));
10974
10975    Value::Null
10976} }
10977
10978    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 {
10979        let mut price = get_arg(optional_args, 0, Value::Null);
10980        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10981        let mut params = get_arg(optional_args, 2, Value::Map({
10982    let mut m = indexmap::IndexMap::new();
10983    m
10984}));
10985        /*
10986         * @method
10987         * @name createStopLossOrder
10988         * @description create a trigger stop loss order (type 2)
10989         * @param {string} symbol unified symbol of the market to create an order in
10990         * @param {string} type 'market' or 'limit'
10991         * @param {string} side 'buy' or 'sell'
10992         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10993         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10994         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
10995         * @param {object} [params] extra parameters specific to the exchange API endpoint
10996         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10997         */
10998        if (stopLossPrice == Value::Null) {
10999            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() requires a stopLossPrice argument".into()))));
11000        }
11001        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11002            let mut m = indexmap::IndexMap::new();
11003                m.insert("stopLossPrice".to_string(), stopLossPrice);
11004            m
11005        })]);
11006        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)) {
11007            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11008        }
11009        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() is not supported yet".into()))));
11010
11011    Value::Null
11012} }
11013
11014    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 {
11015        let mut price = get_arg(optional_args, 0, Value::Null);
11016        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
11017        let mut params = get_arg(optional_args, 2, Value::Map({
11018    let mut m = indexmap::IndexMap::new();
11019    m
11020}));
11021        /*
11022         * @method
11023         * @name createTakeProfitOrder
11024         * @description create a trigger take profit order (type 2)
11025         * @param {string} symbol unified symbol of the market to create an order in
11026         * @param {string} type 'market' or 'limit'
11027         * @param {string} side 'buy' or 'sell'
11028         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11029         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11030         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
11031         * @param {object} [params] extra parameters specific to the exchange API endpoint
11032         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11033         */
11034        if (takeProfitPrice == Value::Null) {
11035            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".into()))));
11036        }
11037        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11038            let mut m = indexmap::IndexMap::new();
11039                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
11040            m
11041        })]);
11042        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)) {
11043            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11044        }
11045        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() is not supported yet".into()))));
11046
11047    Value::Null
11048} }
11049
11050    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 {
11051        let mut price = get_arg(optional_args, 0, Value::Null);
11052        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
11053        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
11054        let mut params = get_arg(optional_args, 3, Value::Map({
11055    let mut m = indexmap::IndexMap::new();
11056    m
11057}));
11058        /*
11059         * @method
11060         * @name createOrderWithTakeProfitAndStopLoss
11061         * @description create an order with a stop loss or take profit attached (type 3)
11062         * @param {string} symbol unified symbol of the market to create an order in
11063         * @param {string} type 'market' or 'limit'
11064         * @param {string} side 'buy' or 'sell'
11065         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11066         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11067         * @param {float} [takeProfit] the take profit price, in units of the quote currency
11068         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
11069         * @param {object} [params] extra parameters specific to the exchange API endpoint
11070         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
11071         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
11072         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
11073         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
11074         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
11075         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
11076         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
11077         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
11078         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11079         */
11080        let mut paramsValue: Value = 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()]);
11081        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)) {
11082            return self.create_order(symbol, type_var, side, amount, &[price, paramsValue]).await;
11083        }
11084        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".into()))));
11085
11086    Value::Null
11087} }
11088
11089    fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11090        // async-virtual: try the derived exchange first
11091        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 {
11092            if !matches!(__v, crate::Value::Null) { return __v; }
11093        }
11094
11095        let mut params = get_arg(optional_args, 0, Value::Map({
11096    let mut m = indexmap::IndexMap::new();
11097    m
11098}));
11099        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrders() is not supported yet".into()))));
11100
11101    Value::Null
11102} }
11103
11104    fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11105        // async-virtual: try the derived exchange first
11106        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 {
11107            if !matches!(__v, crate::Value::Null) { return __v; }
11108        }
11109
11110        let mut symbol = get_arg(optional_args, 0, Value::Null);
11111        let mut params = get_arg(optional_args, 1, Value::Map({
11112    let mut m = indexmap::IndexMap::new();
11113    m
11114}));
11115        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() is not supported yet".into()))));
11116
11117    Value::Null
11118} }
11119
11120/*
11121 * @method
11122 * @name cancelOrderWithClientOrderId
11123 * @description create a market order by providing the symbol, side and cost
11124 * @param {string} clientOrderId client order Id
11125 * @param {string} symbol unified symbol of the market to create an order in
11126 * @param {object} [params] extra parameters specific to the exchange API endpoint
11127 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11128 */
11129    fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11130        let mut symbol = get_arg(optional_args, 0, Value::Null);
11131        let mut params = get_arg(optional_args, 1, Value::Map({
11132    let mut m = indexmap::IndexMap::new();
11133    m
11134}));
11135        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11136            let mut m = indexmap::IndexMap::new();
11137                m.insert("clientOrderId".to_string(), clientOrderId);
11138            m
11139        })]);
11140        return self.cancel_order(Value::Str("".into()), &[symbol, extendedParams]).await;
11141
11142    Value::Null
11143} }
11144
11145    fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11146        // async-virtual: try the derived exchange first
11147        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 {
11148            if !matches!(__v, crate::Value::Null) { return __v; }
11149        }
11150
11151        let mut symbol = get_arg(optional_args, 0, Value::Null);
11152        let mut params = get_arg(optional_args, 1, Value::Map({
11153    let mut m = indexmap::IndexMap::new();
11154    m
11155}));
11156        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() is not supported yet".into()))));
11157
11158    Value::Null
11159} }
11160
11161/*
11162 * @method
11163 * @name cancelOrdersWithClientOrderIds
11164 * @description create a market order by providing the symbol, side and cost
11165 * @param {string[]} clientOrderIds client order Ids
11166 * @param {string} symbol unified symbol of the market to create an order in
11167 * @param {object} [params] extra parameters specific to the exchange API endpoint
11168 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11169 */
11170    fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11171        let mut symbol = get_arg(optional_args, 0, Value::Null);
11172        let mut params = get_arg(optional_args, 1, Value::Map({
11173    let mut m = indexmap::IndexMap::new();
11174    m
11175}));
11176        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11177            let mut m = indexmap::IndexMap::new();
11178                m.insert("clientOrderIds".to_string(), clientOrderIds);
11179            m
11180        })]);
11181        return self.cancel_orders(Value::from(vec![]), &[symbol, extendedParams]).await;
11182
11183    Value::Null
11184} }
11185
11186    fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11187        // async-virtual: try the derived exchange first
11188        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 {
11189            if !matches!(__v, crate::Value::Null) { return __v; }
11190        }
11191
11192        let mut symbol = get_arg(optional_args, 0, Value::Null);
11193        let mut params = get_arg(optional_args, 1, Value::Map({
11194    let mut m = indexmap::IndexMap::new();
11195    m
11196}));
11197        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() is not supported yet".into()))));
11198
11199    Value::Null
11200} }
11201
11202    fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11203        let mut params = get_arg(optional_args, 0, Value::Map({
11204    let mut m = indexmap::IndexMap::new();
11205    m
11206}));
11207        return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11208
11209    Value::Null
11210} }
11211
11212    fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11213        // async-virtual: try the derived exchange first
11214        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 {
11215            if !matches!(__v, crate::Value::Null) { return __v; }
11216        }
11217
11218        let mut symbol = get_arg(optional_args, 0, Value::Null);
11219        let mut since = get_arg(optional_args, 1, Value::Null);
11220        let mut limit = get_arg(optional_args, 2, Value::Null);
11221        let mut params = get_arg(optional_args, 3, Value::Map({
11222    let mut m = indexmap::IndexMap::new();
11223    m
11224}));
11225        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))) {
11226            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".into()))));
11227        }
11228        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet".into()))));
11229
11230    Value::Null
11231} }
11232
11233    fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11234        let mut symbol = get_arg(optional_args, 0, Value::Null);
11235        let mut since = get_arg(optional_args, 1, Value::Null);
11236        let mut limit = get_arg(optional_args, 2, Value::Null);
11237        let mut params = get_arg(optional_args, 3, Value::Map({
11238    let mut m = indexmap::IndexMap::new();
11239    m
11240}));
11241        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderTrades() is not supported yet".into()))));
11242
11243    Value::Null
11244} }
11245
11246    fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11247        let mut symbol = get_arg(optional_args, 0, Value::Null);
11248        let mut since = get_arg(optional_args, 1, Value::Null);
11249        let mut limit = get_arg(optional_args, 2, Value::Null);
11250        let mut params = get_arg(optional_args, 3, Value::Map({
11251    let mut m = indexmap::IndexMap::new();
11252    m
11253}));
11254        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrders() is not supported yet".into()))));
11255
11256    Value::Null
11257} }
11258
11259    fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11260        // async-virtual: try the derived exchange first
11261        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 {
11262            if !matches!(__v, crate::Value::Null) { return __v; }
11263        }
11264
11265        let mut symbol = get_arg(optional_args, 0, Value::Null);
11266        let mut since = get_arg(optional_args, 1, Value::Null);
11267        let mut limit = get_arg(optional_args, 2, Value::Null);
11268        let mut params = get_arg(optional_args, 3, Value::Map({
11269    let mut m = indexmap::IndexMap::new();
11270    m
11271}));
11272        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)) {
11273            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11274            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
11275        }
11276        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() is not supported yet".into()))));
11277
11278    Value::Null
11279} }
11280
11281    fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11282        // async-virtual: try the derived exchange first
11283        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 {
11284            if !matches!(__v, crate::Value::Null) { return __v; }
11285        }
11286
11287        let mut symbol = get_arg(optional_args, 0, Value::Null);
11288        let mut since = get_arg(optional_args, 1, Value::Null);
11289        let mut limit = get_arg(optional_args, 2, Value::Null);
11290        let mut params = get_arg(optional_args, 3, Value::Map({
11291    let mut m = indexmap::IndexMap::new();
11292    m
11293}));
11294        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)) {
11295            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11296            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
11297        }
11298        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrders() is not supported yet".into()))));
11299
11300    Value::Null
11301} }
11302
11303    fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11304        let mut symbol = get_arg(optional_args, 0, Value::Null);
11305        let mut since = get_arg(optional_args, 1, Value::Null);
11306        let mut limit = get_arg(optional_args, 2, Value::Null);
11307        let mut params = get_arg(optional_args, 3, Value::Map({
11308    let mut m = indexmap::IndexMap::new();
11309    m
11310}));
11311        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledOrders() is not supported yet".into()))));
11312
11313    Value::Null
11314} }
11315
11316    fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11317        // async-virtual: try the derived exchange first
11318        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 {
11319            if !matches!(__v, crate::Value::Null) { return __v; }
11320        }
11321
11322        let mut symbol = get_arg(optional_args, 0, Value::Null);
11323        let mut since = get_arg(optional_args, 1, Value::Null);
11324        let mut limit = get_arg(optional_args, 2, Value::Null);
11325        let mut params = get_arg(optional_args, 3, Value::Map({
11326    let mut m = indexmap::IndexMap::new();
11327    m
11328}));
11329        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() is not supported yet".into()))));
11330
11331    Value::Null
11332} }
11333
11334    fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11335        let mut symbol = get_arg(optional_args, 0, Value::Null);
11336        let mut since = get_arg(optional_args, 1, Value::Null);
11337        let mut limit = get_arg(optional_args, 2, Value::Null);
11338        let mut params = get_arg(optional_args, 3, Value::Map({
11339    let mut m = indexmap::IndexMap::new();
11340    m
11341}));
11342        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTrades() is not supported yet".into()))));
11343
11344    Value::Null
11345} }
11346
11347    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 {
11348        let mut params = get_arg(optional_args, 0, Value::Map({
11349    let mut m = indexmap::IndexMap::new();
11350    m
11351}));
11352        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
11353
11354    Value::Null
11355} }
11356
11357    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 {
11358        let mut price = get_arg(optional_args, 0, Value::Null);
11359        let mut params = get_arg(optional_args, 1, Value::Map({
11360    let mut m = indexmap::IndexMap::new();
11361    m
11362}));
11363        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
11364
11365    Value::Null
11366} }
11367
11368    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 {
11369        let mut params = get_arg(optional_args, 0, Value::Map({
11370    let mut m = indexmap::IndexMap::new();
11371    m
11372}));
11373        return self.create_order(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
11374
11375    Value::Null
11376} }
11377
11378    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 {
11379        let mut params = get_arg(optional_args, 0, Value::Map({
11380    let mut m = indexmap::IndexMap::new();
11381    m
11382}));
11383        return self.create_order(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
11384
11385    Value::Null
11386} }
11387
11388    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 {
11389        let mut params = get_arg(optional_args, 0, Value::Map({
11390    let mut m = indexmap::IndexMap::new();
11391    m
11392}));
11393        return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
11394
11395    Value::Null
11396} }
11397
11398    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 {
11399        let mut params = get_arg(optional_args, 0, Value::Map({
11400    let mut m = indexmap::IndexMap::new();
11401    m
11402}));
11403        return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
11404
11405    Value::Null
11406} }
11407
11408    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 {
11409        let mut price = get_arg(optional_args, 0, Value::Null);
11410        let mut params = get_arg(optional_args, 1, Value::Map({
11411    let mut m = indexmap::IndexMap::new();
11412    m
11413}));
11414        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)) {
11415            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrder() is not supported yet".into()))));
11416        }
11417        let mut query: Value = self.extend(params, &[Value::Map({
11418            let mut m = indexmap::IndexMap::new();
11419                m.insert("postOnly".to_string(), Value::Bool(true));
11420            m
11421        })]);
11422        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11423
11424    Value::Null
11425} }
11426
11427    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 {
11428        let mut price = get_arg(optional_args, 0, Value::Null);
11429        let mut params = get_arg(optional_args, 1, Value::Map({
11430    let mut m = indexmap::IndexMap::new();
11431    m
11432}));
11433        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)) {
11434            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrder() is not supported yet".into()))));
11435        }
11436        let mut query: Value = self.extend(params, &[Value::Map({
11437            let mut m = indexmap::IndexMap::new();
11438                m.insert("reduceOnly".to_string(), Value::Bool(true));
11439            m
11440        })]);
11441        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11442
11443    Value::Null
11444} }
11445
11446    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 {
11447        let mut price = get_arg(optional_args, 0, Value::Null);
11448        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11449        let mut params = get_arg(optional_args, 2, Value::Map({
11450    let mut m = indexmap::IndexMap::new();
11451    m
11452}));
11453        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)) {
11454            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrder() is not supported yet".into()))));
11455        }
11456        if (triggerPrice == Value::Null) {
11457            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" create_stop_order() requires a stopPrice argument".into()))));
11458        }
11459        let mut query: Value = self.extend(params, &[Value::Map({
11460            let mut m = indexmap::IndexMap::new();
11461                m.insert("stopPrice".to_string(), triggerPrice);
11462            m
11463        })]);
11464        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11465
11466    Value::Null
11467} }
11468
11469    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 {
11470        let mut params = get_arg(optional_args, 0, Value::Map({
11471    let mut m = indexmap::IndexMap::new();
11472    m
11473}));
11474        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)) {
11475            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrder() is not supported yet".into()))));
11476        }
11477        let mut query: Value = self.extend(params, &[Value::Map({
11478            let mut m = indexmap::IndexMap::new();
11479                m.insert("stopPrice".to_string(), triggerPrice);
11480            m
11481        })]);
11482        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
11483
11484    Value::Null
11485} }
11486
11487    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 {
11488        let mut params = get_arg(optional_args, 0, Value::Map({
11489    let mut m = indexmap::IndexMap::new();
11490    m
11491}));
11492        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)) {
11493            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrder() is not supported yet".into()))));
11494        }
11495        let mut query: Value = self.extend(params, &[Value::Map({
11496            let mut m = indexmap::IndexMap::new();
11497                m.insert("stopPrice".to_string(), triggerPrice);
11498            m
11499        })]);
11500        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
11501
11502    Value::Null
11503} }
11504
11505    fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11506        // async-virtual: try the derived exchange first
11507        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 {
11508            if !matches!(__v, crate::Value::Null) { return __v; }
11509        }
11510
11511        let mut params = get_arg(optional_args, 0, Value::Map({
11512    let mut m = indexmap::IndexMap::new();
11513    m
11514}));
11515        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)) {
11516            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFee() is not supported yet".into()))));
11517        }
11518        let mut fees: Value = self.fetch_trading_fees(&[params]).await;
11519        let mut fee: Value = self.safe_dict(fees, symbol, &[]);
11520        return fee;
11521
11522    Value::Null
11523} }
11524    /// Base-method fall-through for a core's `call_dynamic`.
11525    fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11526        -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11527    {
11528        Box::pin(async move {
11529            match method {
11530            "account" => self.account(),
11531            "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)),
11532            "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,
11533            "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)),
11534            "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11535            "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())..]),
11536            "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,
11537            "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,
11538            "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,
11539            "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11540            "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())..]),
11541            "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())..]),
11542            "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())..]),
11543            "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11544            "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args[..]).await,
11545            "cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
11546            "cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11547            "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args[..]).await,
11548            "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args[..]).await,
11549            "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11550            "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11551            "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,
11552            "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11553            "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11554            "cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11555            "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,
11556            "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11557            "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11558            "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11559            "check_address" => self.check_address(&args[..]),
11560            "check_proxy_settings" => self.check_proxy_settings(&args[..]),
11561            "check_proxy_url_settings" => self.check_proxy_url_settings(&args[..]),
11562            "check_required_credentials" => self.check_required_credentials(&args[..]),
11563            "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11564            "close_all_positions" => self.close_all_positions(&args[..]).await,
11565            "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11566            "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11567            "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11568            "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11569            "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11570            "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())..]),
11571            "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())..]),
11572            "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11573            "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)),
11574            "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args[..]),
11575            "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11576            "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,
11577            "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11578            "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11579            "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,
11580            "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,
11581            "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,
11582            "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,
11583            "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,
11584            "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,
11585            "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,
11586            "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,
11587            "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,
11588            "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,
11589            "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,
11590            "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,
11591            "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,
11592            "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,
11593            "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,
11594            "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,
11595            "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)),
11596            "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,
11597            "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,
11598            "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,
11599            "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,
11600            "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11601            "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11602            "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,
11603            "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,
11604            "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,
11605            "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,
11606            "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11607            "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,
11608            "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,
11609            "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,
11610            "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,
11611            "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,
11612            "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,
11613            "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,
11614            "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,
11615            "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11616            "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,
11617            "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,
11618            "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,
11619            "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,
11620            "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,
11621            "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,
11622            "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,
11623            "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,
11624            "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,
11625            "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11626            "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11627            "currency_ids" => self.currency_ids(&args[..]),
11628            "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())..]),
11629            "default_network_code" => self.default_network_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11630            "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11631            "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,
11632            "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,
11633            "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,
11634            "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,
11635            "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,
11636            "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,
11637            "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11638            "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11639            "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())..]),
11640            "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())..]),
11641            "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)),
11642            "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11643            "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11644            "fetch_accounts" => self.fetch_accounts(&args[..]).await,
11645            "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11646            "fetch_all_greeks" => self.fetch_all_greeks(&args[..]).await,
11647            "fetch_balance" => self.fetch_balance(&args[..]).await,
11648            "fetch_balance_ws" => self.fetch_balance_ws(&args[..]).await,
11649            "fetch_bids_asks" => self.fetch_bids_asks(&args[..]).await,
11650            "fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
11651            "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,
11652            "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
11653            "fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
11654            "fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
11655            "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args[..]).await,
11656            "fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11657            "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11658            "fetch_contract_tickers" => self.fetch_contract_tickers(&args[..]).await,
11659            "fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
11660            "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,
11661            "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11662            "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
11663            "fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11664            "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args[..]).await,
11665            "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11666            "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args[..]).await,
11667            "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,
11668            "fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11669            "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
11670            "fetch_deposits" => self.fetch_deposits(&args[..]).await,
11671            "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
11672            "fetch_deposits_ws" => self.fetch_deposits_ws(&args[..]).await,
11673            "fetch_free_balance" => self.fetch_free_balance(&args[..]).await,
11674            "fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
11675            "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11676            "fetch_funding_intervals" => self.fetch_funding_intervals(&args[..]).await,
11677            "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11678            "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
11679            "fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
11680            "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11681            "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11682            "fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11683            "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args[..]).await,
11684            "fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11685            "fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11686            "fetch_last_prices" => self.fetch_last_prices(&args[..]).await,
11687            "fetch_ledger" => self.fetch_ledger(&args[..]).await,
11688            "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11689            "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11690            "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args[..]).await,
11691            "fetch_leverages" => self.fetch_leverages(&args[..]).await,
11692            "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11693            "fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11694            "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args[..]).await,
11695            "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args[..]).await,
11696            "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11697            "fetch_margin_modes" => self.fetch_margin_modes(&args[..]).await,
11698            "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11699            "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11700            "fetch_mark_prices" => self.fetch_mark_prices(&args[..]).await,
11701            "fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11702            "fetch_my_liquidations" => self.fetch_my_liquidations(&args[..]).await,
11703            "fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
11704            "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args[..]).await,
11705            "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11706            "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11707            "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11708            "fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11709            "fetch_open_interests" => self.fetch_open_interests(&args[..]).await,
11710            "fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
11711            "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args[..]).await,
11712            "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11713            "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11714            "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11715            "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11716            "fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11717            "fetch_order_books" => self.fetch_order_books(&args[..]).await,
11718            "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11719            "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11720            "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,
11721            "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11722            "fetch_orders" => self.fetch_orders(&args[..]).await,
11723            "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,
11724            "fetch_orders_ws" => self.fetch_orders_ws(&args[..]).await,
11725            "fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11726            "fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11727            "fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11728            "fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11729            "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11730            "fetch_payment_methods" => self.fetch_payment_methods(&args[..]).await,
11731            "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11732            "fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11733            "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11734            "fetch_position_mode" => self.fetch_position_mode(&args[..]).await,
11735            "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11736            "fetch_positions" => self.fetch_positions(&args[..]).await,
11737            "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args[..]).await,
11738            "fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11739            "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,
11740            "fetch_positions_history" => self.fetch_positions_history(&args[..]).await,
11741            "fetch_positions_risk" => self.fetch_positions_risk(&args[..]).await,
11742            "fetch_positions_ws" => self.fetch_positions_ws(&args[..]).await,
11743            "fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11744            "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,
11745            "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11746            "fetch_spot_tickers" => self.fetch_spot_tickers(&args[..]).await,
11747            "fetch_status" => self.fetch_status(&args[..]).await,
11748            "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11749            "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11750            "fetch_tickers" => self.fetch_tickers(&args[..]).await,
11751            "fetch_tickers_ws" => self.fetch_tickers_ws(&args[..]).await,
11752            "fetch_time" => self.fetch_time(&args[..]).await,
11753            "fetch_total_balance" => self.fetch_total_balance(&args[..]).await,
11754            "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11755            "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11756            "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11757            "fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
11758            "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args[..]).await,
11759            "fetch_trading_limits" => self.fetch_trading_limits(&args[..]).await,
11760            "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11761            "fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
11762            "fetch_transactions" => self.fetch_transactions(&args[..]).await,
11763            "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11764            "fetch_transfers" => self.fetch_transfers(&args[..]).await,
11765            "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11766            "fetch_used_balance" => self.fetch_used_balance(&args[..]).await,
11767            "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,
11768            "fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
11769            "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args[..]).await,
11770            "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())..]),
11771            "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())..]),
11772            "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())..]),
11773            "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())..]),
11774            "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())..]),
11775            "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())..]),
11776            "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11777            "filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11778            "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11779            "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())..]),
11780            "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())..]),
11781            "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())..]),
11782            "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())..]),
11783            "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)),
11784            "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)),
11785            "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)),
11786            "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11787            "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11788            "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)),
11789            "get_default_options" => self.get_default_options(),
11790            "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)),
11791            "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)),
11792            "get_market_from_symbols" => self.get_market_from_symbols(&args[..]),
11793            "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11794            "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args[..]),
11795            "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)),
11796            "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())..]),
11797            "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())..]),
11798            "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())..]),
11799            "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11800            "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())..]),
11801            "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())..]),
11802            "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())..]),
11803            "handle_option_bool_and_params" => self.handle_option_bool_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())..]),
11804            "handle_option_bool_and_params2" => self.handle_option_bool_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())..]),
11805            "handle_option_integer_and_params" => self.handle_option_integer_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())..]),
11806            "handle_option_integer_and_params2" => self.handle_option_integer_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())..]),
11807            "handle_option_string_and_params" => self.handle_option_string_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())..]),
11808            "handle_option_string_and_params2" => self.handle_option_string_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())..]),
11809            "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())..]),
11810            "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())..]),
11811            "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())..]),
11812            "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())..]),
11813            "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())..]),
11814            "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())..]),
11815            "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())..]),
11816            "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())..]),
11817            "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())..]),
11818            "handle_time_in_force" => self.handle_time_in_force(&args[..]),
11819            "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11820            "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())..]),
11821            "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())..]),
11822            "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())..]),
11823            "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11824            "incrementing_nonce" => self.incrementing_nonce(),
11825            "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11826            "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11827            "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11828            "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11829            "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())..]),
11830            "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11831            "is_significant_precision" => self.is_significant_precision(),
11832            "is_tick_precision" => self.is_tick_precision(),
11833            "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11834            "is_uta_enabled" => self.is_uta_enabled(&args[..]).await,
11835            "load_accounts" => self.load_accounts(&args[..]).await,
11836            "load_markets" => self.load_markets(&args[..]).await,
11837            "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
11838            "load_time_difference" => self.load_time_difference(&args[..]).await,
11839            "load_trading_limits" => self.load_trading_limits(&args[..]).await,
11840            "market" => self.market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11841            "market_codes" => self.market_codes(&args[..]),
11842            "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11843            "market_ids" => self.market_ids(&args[..]),
11844            "market_or_null" => self.market_or_null(&args[..]),
11845            "market_symbols" => self.market_symbols(&args[..]),
11846            "markets_for_symbols" => self.markets_for_symbols(&args[..]),
11847            "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)),
11848            "network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11849            "network_id_to_code" => self.network_id_to_code(&args[..]),
11850            "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
11851            "oath" => self.oath(),
11852            "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11853            "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11854            "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11855            "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())..]),
11856            "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11857            "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11858            "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11859            "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())..]),
11860            "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11861            "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())..]),
11862            "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)),
11863            "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())..]),
11864            "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11865            "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11866            "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11867            "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())..]),
11868            "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11869            "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())..]),
11870            "parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11871            "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11872            "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())..]),
11873            "parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11874            "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())..]),
11875            "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11876            "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())..]),
11877            "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())..]),
11878            "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11879            "parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11880            "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11881            "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())..]),
11882            "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11883            "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11884            "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())..]),
11885            "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())..]),
11886            "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11887            "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11888            "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())..]),
11889            "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11890            "parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11891            "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())..]),
11892            "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())..]),
11893            "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11894            "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())..]),
11895            "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11896            "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11897            "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())..]),
11898            "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11899            "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11900            "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())..]),
11901            "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())..]),
11902            "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11903            "parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11904            "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11905            "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11906            "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())..]),
11907            "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())..]),
11908            "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())..]),
11909            "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())..]),
11910            "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11911            "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())..]),
11912            "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11913            "parse_precision" => self.parse_precision(&args[..]),
11914            "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())..]),
11915            "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11916            "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11917            "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11918            "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())..]),
11919            "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11920            "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())..]),
11921            "parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11922            "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())..]),
11923            "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11924            "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())..]),
11925            "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11926            "parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11927            "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11928            "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11929            "parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11930            "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11931            "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11932            "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11933            "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)),
11934            "prioritized_network_aliases" => self.prioritized_network_aliases(&args[..]),
11935            "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11936            "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,
11937            "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)),
11938            "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())..]),
11939            "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11940            "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,
11941            "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,
11942            "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,
11943            "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11944            "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11945            "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11946            "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11947            "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())..]),
11948            "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())..]),
11949            "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())..]),
11950            "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11951            "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11952            "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11953            "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11954            "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())..]),
11955            "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())..]),
11956            "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())..]),
11957            "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())..]),
11958            "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11959            "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11960            "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())..]),
11961            "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())..]),
11962            "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())..]),
11963            "safe_market" => self.safe_market(&args[..]),
11964            "safe_market_structure" => self.safe_market_structure(&args[..]),
11965            "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11966            "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())..]),
11967            "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())..]),
11968            "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())..]),
11969            "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())..]),
11970            "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11971            "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11972            "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11973            "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11974            "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11975            "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11976            "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)),
11977            "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)),
11978            "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())..]),
11979            "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11980            "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11981            "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,
11982            "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11983            "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11984            "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11985            "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11986            "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())..]),
11987            "sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11988            "sign_in" => self.sign_in(&args[..]).await,
11989            "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11990            "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11991            "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11992            "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11993            "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,
11994            "un_watch_bids_asks" => self.un_watch_bids_asks(&args[..]).await,
11995            "un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11996            "un_watch_funding_rates" => self.un_watch_funding_rates(&args[..]).await,
11997            "un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11998            "un_watch_mark_prices" => self.un_watch_mark_prices(&args[..]).await,
11999            "un_watch_my_trades" => self.un_watch_my_trades(&args[..]).await,
12000            "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12001            "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,
12002            "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12003            "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,
12004            "un_watch_orders" => self.un_watch_orders(&args[..]).await,
12005            "un_watch_positions" => self.un_watch_positions(&args[..]).await,
12006            "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12007            "un_watch_tickers" => self.un_watch_tickers(&args[..]).await,
12008            "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12009            "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,
12010            "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12011            "watch_balance" => self.watch_balance(&args[..]).await,
12012            "watch_bids_asks" => self.watch_bids_asks(&args[..]).await,
12013            "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12014            "watch_funding_rates" => self.watch_funding_rates(&args[..]).await,
12015            "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,
12016            "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12017            "watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12018            "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12019            "watch_mark_prices" => self.watch_mark_prices(&args[..]).await,
12020            "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12021            "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,
12022            "watch_my_trades" => self.watch_my_trades(&args[..]).await,
12023            "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,
12024            "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12025            "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12026            "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12027            "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,
12028            "watch_orders" => self.watch_orders(&args[..]).await,
12029            "watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12030            "watch_position" => self.watch_position(&args[..]).await,
12031            "watch_position_for_symbols" => self.watch_position_for_symbols(&args[..]).await,
12032            "watch_positions" => self.watch_positions(&args[..]).await,
12033            "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12034            "watch_tickers" => self.watch_tickers(&args[..]).await,
12035            "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12036            "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12037            "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,
12038            "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,
12039                // Implicit-API endpoints (`publicGetX`) exist only as inherent
12040                // methods on the venue's `<id>_api.rs`, which no name-based
12041                // dispatch arm covers — a static-request test named after one
12042                // (bingx's accountV1PrivateGetAccountApiRestrictions) otherwise
12043                // computes a null url. Route them the way those wrappers do.
12044                // Guarded on the api block so a genuinely unknown name still
12045                // returns Null rather than panicking inside call_method.
12046                //
12047                // Returning Null keeps an optional probe cheap, but a dynamic
12048                // re-entry (`fetchPaginatedCall*` / `fetchWebEndpoint`, which
12049                // reach here via `method_name_to_snake_case`) must not silently
12050                // see an empty page — so record the miss for
12051                // `crate::exchange::call_dynamic_required` to raise on.
12052                _ => {
12053                    if self.internals.implicit_api.is_empty() {
12054                        self.build_implicit_api();
12055                    }
12056                    if self.internals.implicit_api.contains_key(method) {
12057                        self.call_method(crate::Value::Str(method.to_string().into()), &args[..]).await
12058                    } else {
12059                        self.internals.dynamic_dispatch_miss = Some(method.to_string());
12060                        crate::Value::Null
12061                    }
12062                }
12063            }
12064        })
12065    }
12066}