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, optional_args: &[Value]) {
2072        let mut userConfig = get_arg(optional_args, 0, Value::Map({
2073    let mut m = indexmap::IndexMap::new();
2074    m
2075}));
2076        let __userConfig_empty = indexmap::IndexMap::new();
2077        let userConfig = userConfig.as_map().unwrap_or(&__userConfig_empty);
2078        // networks
2079        self.create_networks_by_id_object();
2080        self.features_generator();
2081        // init predefined markets if any
2082        if (self.markets.clone() != Value::Null) {
2083            self.set_markets(self.markets.clone(), &[]);
2084        }
2085        // init the request rate limiter
2086        self.init_rest_rate_limiter();
2087        // sanbox mode
2088        let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".into()), Value::Str("testnet".into()), &[Value::Bool(false)]);
2089        if (isSandbox.as_bool() == Some(true)) {
2090            self.set_sandbox_mode(isSandbox);
2091        }
2092        // compatibility for sandbox/testnet options in userConfig
2093        if matches!(((match userConfig.get("sandbox") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) })), Value::Bool(true)) || matches!(((match userConfig.get("testnet") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) })), Value::Bool(true)) {
2094            self.set_sandbox_mode(Value::Bool(true));
2095        }
2096}
2097
2098    fn init_rest_rate_limiter(&mut self) {
2099        if (self.rateLimit.clone() == Value::Null) || ((self.id.clone() != Value::Null) && (self.rateLimit.as_f64() == Value::Int(-1).as_f64())) {
2100            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(".rateLimit property is not configured".into()))));
2101        }
2102        let mut refillRate: Value = self.MAX_VALUE.clone();
2103        if self.rateLimit.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2104            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 });
2105        }
2106        let mut useLeaky: bool = (self.rollingWindowSize.as_f64() == Some(0.0)) || (self.rateLimiterAlgorithm.as_str() == Some("leakyBucket"));
2107        let mut algorithm: Value = (if useLeaky { Value::Str("leakyBucket".into()) } else { Value::Str("rollingWindow".into()) });
2108        let mut defaultBucket: Value = Value::Map({
2109            let mut m = indexmap::IndexMap::new();
2110                m.insert("delay".to_string(), Value::Float(0.001));
2111                m.insert("capacity".to_string(), Value::Int(1));
2112                m.insert("cost".to_string(), Value::Int(1));
2113                m.insert("refillRate".to_string(), refillRate);
2114                m.insert("algorithm".to_string(), algorithm);
2115                m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2116                m.insert("rateLimit".to_string(), self.rateLimit.clone());
2117            m
2118        });
2119        let mut existingBucket: Value = (if (self.tokenBucket.clone() == Value::Null) { Value::Map({
2120    let mut m = indexmap::IndexMap::new();
2121    m
2122}) } else { self.tokenBucket.clone() });
2123        { let __t = self.extend(defaultBucket, &[existingBucket]); self.tokenBucket = __t; }
2124        self.init_throttler();
2125}
2126
2127    fn features_generator(&mut self) {
2128        //
2129        // in the exchange-specific features can be something like this, where we support 'string' aliases too:
2130        //
2131        //     {
2132        //         'my' : {
2133        //             'createOrder' : {...},
2134        //         },
2135        //         'swap': {
2136        //             'linear': {
2137        //                 'extends': my',
2138        //             },
2139        //         },
2140        //     }
2141        //
2142        if (self.features.clone() == Value::Null) {
2143            return;
2144        }
2145        // reconstruct
2146        let mut initialFeatures: Value = self.features.clone();
2147        self.features = Value::Map({
2148            let mut m = indexmap::IndexMap::new();
2149            m
2150        });
2151        let mut unifiedMarketTypes: Value = Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into()), Value::Str("future".into()), Value::Str("option".into())]);
2152        let mut subTypes: Value = Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into())]);
2153        {
2154                        let mut i: Value = Value::Int(0);
2155            let mut __for_first_82: bool = true;
2156            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) } {
2157            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);
2158            // if marketType is not filled for this exchange, don't add that in `features`
2159            if !(in_op(&initialFeatures, &marketType)) {
2160                if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Null); }
2161            }  else {
2162                if (marketType.as_str() == Some("spot")) {
2163                    { 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); } }
2164                }  else {
2165                    if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Map({
2166    let mut m = indexmap::IndexMap::new();
2167    m
2168})); }
2169                    {
2170                                                let mut j: Value = Value::Int(0);
2171                        let mut __for_first_81: bool = true;
2172                        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) } {
2173                        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);
2174                        { 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); };
2175                    }
2176                    }
2177                }
2178            }
2179        }
2180        }
2181}
2182
2183    fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2184        let mut subType = get_arg(optional_args, 0, Value::Null);
2185        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) });
2186        // if exchange does not have that market-type (eg. future>inverse)
2187        if (featuresObj == Value::Null) {
2188            return Value::Null;
2189        }
2190        let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
2191        if (extendsStr != Value::Null) {
2192            featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".into()), &[]);
2193            let mut extendObj: Value = self.features_mapper(initialFeatures, extendsStr, &[]);
2194            featuresObj = self.deep_extend(extendObj, &[featuresObj.clone()]);
2195        }
2196        //
2197        // ### corrections ###
2198        //
2199        // createOrder
2200        if (in_op(&featuresObj, &Value::Str("createOrder".into()))) {
2201            let mut value: Value = self.safe_dict_k(crate::value::get_value_k(&featuresObj, "createOrder"), "attachedStopLossTakeProfit", &[]);
2202            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("stopLoss".into()), value.clone());
2203            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("takeProfit".into()), value.clone());
2204            if (marketType.as_str() == Some("spot")) {
2205                // default 'hedged': false
2206                add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("hedged".into()), Value::Bool(false));
2207                // default 'leverage': false
2208                if !(in_op(&crate::value::get_value_k(&featuresObj, "createOrder"), &Value::Str("leverage".into()))) {
2209                    add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("leverage".into()), Value::Bool(false));
2210                }
2211            }
2212            // default 'GTC' to true
2213            if (self.safe_bool(crate::value::get_value_k(&crate::value::get_value_k(&featuresObj, "createOrder"), "timeInForce"), Value::Str("GTC".into()), &[]) == Value::Null) {
2214                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));
2215            }
2216        }
2217        // other methods
2218        let mut keys: Value = object_keys(&featuresObj);
2219        {
2220                        let mut i: Value = Value::Int(0);
2221            let mut __for_first_83: bool = true;
2222            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) } {
2223            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);
2224            let mut featureBlock: Value = get_value(&featuresObj, &key);
2225            let mut featureBlock: Value = get_value(&featuresObj, &key);
2226            if !(self.in_array(key.clone(), Value::from(vec![Value::Str("sandbox".into())])).as_bool() == Some(true)) && (featureBlock != Value::Null) {
2227                // default "symbolRequired" to false to all methods (except `createOrder`)
2228                if !(in_op(&featureBlock, &Value::Str("symbolRequired".into()))) {
2229                    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())])));
2230                }
2231            }
2232        }
2233        }
2234        return featuresObj;
2235
2236    Value::Null
2237}
2238
2239    fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
2240        let mut methodName = get_arg(optional_args, 0, Value::Null);
2241        let mut paramName = get_arg(optional_args, 1, Value::Null);
2242        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2243        /*
2244         * @method
2245         * @name exchange#featureValue
2246         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2247         * @param {string} [symbol] unified symbol
2248         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2249         * @param {string} [paramName] unified param value, like: `triggerPrice`, `stopLoss.triggerPrice` (check docs for supported param names)
2250         * @param {object} [defaultValue] return default value if no result found
2251         * @returns {object} returns feature value
2252         */
2253        let mut market: Value = self.market(symbol.clone());
2254        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]);
2255
2256    Value::Null
2257}
2258
2259    fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2260        let mut methodName = get_arg(optional_args, 0, Value::Null);
2261        let mut paramName = get_arg(optional_args, 1, Value::Null);
2262        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2263        /*
2264         * @method
2265         * @name exchange#featureValueByType
2266         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2267         * @param {string} [marketType] supported only: "spot", "swap", "future"
2268         * @param {string} [subType] supported only: "linear", "inverse"
2269         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2270         * @param {string} [paramName] unified param value (check docs for supported param names)
2271         * @param {object} [defaultValue] return default value if no result found
2272         * @returns {object} returns feature value
2273         */
2274        // if exchange does not yet have features manually implemented
2275        if (self.features.clone() == Value::Null) {
2276            return defaultValue;
2277        }
2278        if (marketType == Value::Null) {
2279            return defaultValue;
2280        }
2281        // if marketType (e.g. 'option') does not exist in features
2282        if !(in_op(&self.features, &marketType)) {
2283            return defaultValue;
2284        }
2285        // if marketType dict undefined
2286        if (get_value(&self.features, &marketType) == Value::Null) {
2287            return defaultValue;
2288        }
2289        let mut methodsContainer: Value = get_value(&self.features, &marketType);
2290        if (subType == Value::Null) {
2291            if (marketType.as_str() != Some("spot")) {
2292                return defaultValue;
2293            }
2294        }  else {
2295            if !(in_op(&get_value(&self.features, &marketType), &subType)) {
2296                return defaultValue;
2297            }
2298            // if subType dict undefined
2299            if (get_value(&get_value(&self.features, &marketType), &subType) == Value::Null) {
2300                return defaultValue;
2301            }
2302            methodsContainer = get_value(&get_value(&self.features, &marketType), &subType);
2303        }
2304        // if user wanted only marketType and didn't provide methodName, eg: featureIsSupported('spot')
2305        if (methodName == Value::Null) {
2306            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodsContainer.clone() });
2307        }
2308        if !(in_op(&methodsContainer, &methodName)) {
2309            return defaultValue;
2310        }
2311        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2312        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2313        if (methodDict == Value::Null) {
2314            return defaultValue;
2315        }
2316        // if user wanted only method and didn't provide `paramName`, eg: featureIsSupported('swap', 'linear', 'createOrder')
2317        if (paramName == Value::Null) {
2318            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodDict.clone() });
2319        }
2320        let mut splited: Value = split(&paramName, &Value::Str(".".into())); // can be only parent key (`stopLoss`) or with child (`stopLoss.triggerPrice`)
2321        let mut parentKey: Value = splited.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
2322        let mut subKey: Value = self.safe_string(splited, Value::Int(1), &[]);
2323        if !(in_op(&methodDict, &parentKey)) {
2324            return defaultValue;
2325        }
2326        let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2327        if (dictionary == Value::Null) {
2328            return get_value(&methodDict, &parentKey);
2329        }  else {
2330            // return as is, when calling without subKey eg: featureValueByType('spot', undefined, 'createOrder', 'stopLoss')
2331            if (subKey == Value::Null) {
2332                return get_value(&methodDict, &parentKey);
2333            }
2334            // throw an exception for unsupported subKey
2335            if !(in_op(&get_value(&methodDict, &parentKey), &subKey)) {
2336                return defaultValue;
2337            }
2338            return get_value(&get_value(&methodDict, &parentKey), &subKey);
2339        }
2340
2341    Value::Null
2342}
2343
2344    fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2345        if (symbol == Value::Null) {
2346            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" orderbookChecksumMessage() requires a symbol argument".into()))));
2347        }
2348        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());
2349
2350    Value::Null
2351}
2352
2353    fn create_networks_by_id_object(&mut self) {
2354        // automatically generate network-id-to-code mappings
2355        let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2356            let mut m = indexmap::IndexMap::new();
2357            m
2358        })])); // invert defined networks dictionary
2359        { let __be_tmp = self.extend(networkIdsToCodesGenerated, &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2360    let mut m = indexmap::IndexMap::new();
2361    m
2362})])]); 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
2363}
2364
2365    fn get_default_options(&self) -> Value {
2366        return Value::Map({
2367    let mut m = indexmap::IndexMap::new();
2368        m.insert("defaultNetworkCodeReplacements".to_string(), Value::Map({
2369    let mut m = indexmap::IndexMap::new();
2370        m.insert("ETH".to_string(), Value::Map({
2371    let mut m = indexmap::IndexMap::new();
2372        m.insert("primary".to_string(), Value::Str("ETH".into()));
2373        m.insert("secondary".to_string(), Value::Str("ERC20".into()));
2374        m.insert("default".to_string(), Value::Str("secondary".into()));
2375    m
2376}));
2377        m.insert("CRO".to_string(), Value::Map({
2378    let mut m = indexmap::IndexMap::new();
2379        m.insert("primary".to_string(), Value::Str("CRONOS".into()));
2380        m.insert("secondary".to_string(), Value::Str("CRC20".into()));
2381        m.insert("default".to_string(), Value::Str("secondary".into()));
2382    m
2383}));
2384        m.insert("TRX".to_string(), Value::Map({
2385    let mut m = indexmap::IndexMap::new();
2386        m.insert("primary".to_string(), Value::Str("TRX".into()));
2387        m.insert("secondary".to_string(), Value::Str("TRC20".into()));
2388        m.insert("default".to_string(), Value::Str("secondary".into()));
2389    m
2390}));
2391        m.insert("BTC".to_string(), Value::Map({
2392    let mut m = indexmap::IndexMap::new();
2393        m.insert("primary".to_string(), Value::Str("BTC".into()));
2394        m.insert("secondary".to_string(), Value::Str("BRC20".into()));
2395        m.insert("default".to_string(), Value::Str("primary".into()));
2396    m
2397}));
2398    m
2399}));
2400        m.insert("backwardSupportedNetworkCodes".to_string(), Value::Map({
2401    let mut m = indexmap::IndexMap::new();
2402        m.insert("ARB".to_string(), Value::Str("ARBITRUM".into()));
2403        m.insert("ARBONE".to_string(), Value::Str("ARBITRUM".into()));
2404        m.insert("ARBNOVA".to_string(), Value::Str("ARBITRUM_NOVA".into()));
2405    m
2406}));
2407        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())]));
2408    m
2409});
2410
2411    Value::Null
2412}
2413
2414    fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2415        let mut currency = get_arg(optional_args, 0, Value::Null);
2416        let mut currencyResolved: Value = self.safe_currency(Value::Null, &[currency]);
2417        let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2418        let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2419        let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2420        let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
2421        if (amount != Value::Null) {
2422            if (before == Value::Null) && (after != Value::Null) {
2423                before = crate::precise::Precise::stringSub(&after, &amount);
2424            }  else if (before != Value::Null) && (after == Value::Null) {
2425                after = crate::precise::Precise::stringAdd(&before, &amount);
2426            }
2427        }
2428        if (before != Value::Null) && (after != Value::Null) {
2429            if (direction == Value::Null) {
2430                if is_true(&crate::precise::Precise::stringGt(&before, &after)) {
2431                    direction = Value::Str("out".into());
2432                }
2433                if is_true(&crate::precise::Precise::stringGt(&after, &before)) {
2434                    direction = Value::Str("in".into());
2435                }
2436            }
2437        }
2438        let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2439        if (fee != Value::Null) {
2440            { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); };
2441        }
2442        let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
2443        let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2444    let mut m = indexmap::IndexMap::new();
2445    m
2446})]);
2447        return Value::Map({
2448    let mut m = indexmap::IndexMap::new();
2449        m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2450        m.insert("timestamp".to_string(), timestamp.clone());
2451        m.insert("datetime".to_string(), self.iso8601(timestamp));
2452        m.insert("direction".to_string(), direction);
2453        m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2454        m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2455        m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2456        m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2457        m.insert("currency".to_string(), currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null));
2458        m.insert("amount".to_string(), self.parse_number(amount, &[]));
2459        m.insert("before".to_string(), self.parse_number(before, &[]));
2460        m.insert("after".to_string(), self.parse_number(after, &[]));
2461        m.insert("status".to_string(), self.safe_string_k(entry, "status", &[]));
2462        m.insert("fee".to_string(), fee);
2463        m.insert("info".to_string(), info);
2464    m
2465});
2466
2467    Value::Null
2468}
2469
2470    fn safe_currency_structure(&self, mut currency: Value) -> Value {
2471        // derive data from networks: deposit, withdraw, active, fee, limits, precision
2472        let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2473    let mut m = indexmap::IndexMap::new();
2474    m
2475})]);
2476        let mut keys: Value = object_keys(&networks);
2477        let mut length: f64 = ((keys.len() as i64) as f64);
2478        if (length != 0.0) {
2479            {
2480                                let mut i: Value = Value::Int(0);
2481                let mut __for_first_84: bool = true;
2482                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 } {
2483                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);
2484                let mut network: Value = networks.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2485                let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
2486                let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
2487                if (currencyDeposit == Value::Null) || (deposit.as_bool() == Some(true)) {
2488                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("deposit".into(), deposit); }
2489                }
2490                let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
2491                let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
2492                if (currencyWithdraw == Value::Null) || (withdraw.as_bool() == Some(true)) {
2493                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("withdraw".into(), withdraw); }
2494                }
2495                // find lowest fee (which is more desired)
2496                let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
2497                let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
2498                if (feeMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&fee, &feeMain)) {
2499                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("fee".into(), self.parse_number(fee.clone(), &[])); }
2500                }
2501                // find lowest precision (which is more desired)
2502                let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
2503                let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
2504                if (precisionMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&precision, &precisionMain)) {
2505                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("precision".into(), self.parse_number(precision.clone(), &[])); }
2506                }
2507                // limits
2508                let mut limits: Value = self.safe_dict_k(network, "limits", &[]);
2509                let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
2510                if (limitsMain == Value::Null) {
2511                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("limits".into(), Value::Map({
2512    let mut m = indexmap::IndexMap::new();
2513    m
2514})); }
2515                }
2516                // deposits
2517                let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2518                let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
2519                if (limitsDepositMain == Value::Null) {
2520                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into()), Value::Map({
2521    let mut m = indexmap::IndexMap::new();
2522    m
2523}));
2524                }
2525                let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
2526                let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit, "max", &[]);
2527                let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
2528                let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain, "max", &[]);
2529                // find min
2530                if (limitsDepositMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain)) {
2531                    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, &[]));
2532                }
2533                // find max
2534                if (limitsDepositMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain)) {
2535                    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, &[]));
2536                }
2537                // withdrawals
2538                let mut limitsWithdraw: Value = self.safe_dict_k(limits, "withdraw", &[]);
2539                let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain, "withdraw", &[]);
2540                if (limitsWithdrawMain == Value::Null) {
2541                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into()), Value::Map({
2542    let mut m = indexmap::IndexMap::new();
2543    m
2544}));
2545                }
2546                let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
2547                let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw, "max", &[]);
2548                let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
2549                let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain, "max", &[]);
2550                // find min
2551                if (limitsWithdrawMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain)) {
2552                    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, &[]));
2553                }
2554                // find max
2555                if (limitsWithdrawMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain)) {
2556                    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, &[]));
2557                }
2558            }
2559            }
2560        }
2561        return self.extend(Value::Map({
2562    let mut m = indexmap::IndexMap::new();
2563        m.insert("info".to_string(), Value::Null);
2564        m.insert("id".to_string(), Value::Null);
2565        m.insert("numericId".to_string(), Value::Null);
2566        m.insert("code".to_string(), Value::Null);
2567        m.insert("precision".to_string(), Value::Null);
2568        m.insert("type".to_string(), Value::Null);
2569        m.insert("name".to_string(), Value::Null);
2570        m.insert("active".to_string(), Value::Null);
2571        m.insert("deposit".to_string(), Value::Null);
2572        m.insert("withdraw".to_string(), Value::Null);
2573        m.insert("fee".to_string(), Value::Null);
2574        m.insert("fees".to_string(), Value::Map({
2575    let mut m = indexmap::IndexMap::new();
2576    m
2577}));
2578        m.insert("networks".to_string(), Value::Map({
2579    let mut m = indexmap::IndexMap::new();
2580    m
2581}));
2582        m.insert("limits".to_string(), Value::Map({
2583    let mut m = indexmap::IndexMap::new();
2584        m.insert("deposit".to_string(), Value::Map({
2585    let mut m = indexmap::IndexMap::new();
2586        m.insert("min".to_string(), Value::Null);
2587        m.insert("max".to_string(), Value::Null);
2588    m
2589}));
2590        m.insert("withdraw".to_string(), Value::Map({
2591    let mut m = indexmap::IndexMap::new();
2592        m.insert("min".to_string(), Value::Null);
2593        m.insert("max".to_string(), Value::Null);
2594    m
2595}));
2596    m
2597}));
2598    m
2599}), &[currency]);
2600
2601    Value::Null
2602}
2603
2604    fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2605        let mut market = get_arg(optional_args, 0, Value::Null);
2606        let mut cleanStructure: Value = Value::Map({
2607            let mut m = indexmap::IndexMap::new();
2608                m.insert("id".to_string(), Value::Null);
2609                m.insert("lowercaseId".to_string(), Value::Null);
2610                m.insert("symbol".to_string(), Value::Null);
2611                m.insert("base".to_string(), Value::Null);
2612                m.insert("quote".to_string(), Value::Null);
2613                m.insert("settle".to_string(), Value::Null);
2614                m.insert("baseId".to_string(), Value::Null);
2615                m.insert("quoteId".to_string(), Value::Null);
2616                m.insert("settleId".to_string(), Value::Null);
2617                m.insert("type".to_string(), Value::Null);
2618                m.insert("spot".to_string(), Value::Null);
2619                m.insert("margin".to_string(), Value::Null);
2620                m.insert("swap".to_string(), Value::Null);
2621                m.insert("future".to_string(), Value::Null);
2622                m.insert("option".to_string(), Value::Null);
2623                m.insert("index".to_string(), Value::Null);
2624                m.insert("active".to_string(), Value::Null);
2625                m.insert("contract".to_string(), Value::Null);
2626                m.insert("linear".to_string(), Value::Null);
2627                m.insert("inverse".to_string(), Value::Null);
2628                m.insert("subType".to_string(), Value::Null);
2629                m.insert("taker".to_string(), Value::Null);
2630                m.insert("maker".to_string(), Value::Null);
2631                m.insert("contractSize".to_string(), Value::Null);
2632                m.insert("expiry".to_string(), Value::Null);
2633                m.insert("expiryDatetime".to_string(), Value::Null);
2634                m.insert("strike".to_string(), Value::Null);
2635                m.insert("optionType".to_string(), Value::Null);
2636                m.insert("precision".to_string(), Value::Map({
2637    let mut m = indexmap::IndexMap::new();
2638        m.insert("amount".to_string(), Value::Null);
2639        m.insert("price".to_string(), Value::Null);
2640        m.insert("cost".to_string(), Value::Null);
2641        m.insert("base".to_string(), Value::Null);
2642        m.insert("quote".to_string(), Value::Null);
2643    m
2644}));
2645                m.insert("limits".to_string(), Value::Map({
2646    let mut m = indexmap::IndexMap::new();
2647        m.insert("leverage".to_string(), Value::Map({
2648    let mut m = indexmap::IndexMap::new();
2649        m.insert("min".to_string(), Value::Null);
2650        m.insert("max".to_string(), Value::Null);
2651    m
2652}));
2653        m.insert("amount".to_string(), Value::Map({
2654    let mut m = indexmap::IndexMap::new();
2655        m.insert("min".to_string(), Value::Null);
2656        m.insert("max".to_string(), Value::Null);
2657    m
2658}));
2659        m.insert("price".to_string(), Value::Map({
2660    let mut m = indexmap::IndexMap::new();
2661        m.insert("min".to_string(), Value::Null);
2662        m.insert("max".to_string(), Value::Null);
2663    m
2664}));
2665        m.insert("cost".to_string(), Value::Map({
2666    let mut m = indexmap::IndexMap::new();
2667        m.insert("min".to_string(), Value::Null);
2668        m.insert("max".to_string(), Value::Null);
2669    m
2670}));
2671    m
2672}));
2673                m.insert("marginModes".to_string(), Value::Map({
2674    let mut m = indexmap::IndexMap::new();
2675        m.insert("cross".to_string(), Value::Null);
2676        m.insert("isolated".to_string(), Value::Null);
2677    m
2678}));
2679                m.insert("created".to_string(), Value::Null);
2680                m.insert("info".to_string(), Value::Null);
2681            m
2682        });
2683        if (market != Value::Null) {
2684            let mut result: Value = self.extend(cleanStructure.clone(), &[market]);
2685            // set undefined swap/future/etc
2686            if is_equal(&result.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2687                if (result.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null) == Value::Null) {
2688                    add_element_to_object(&mut result, &Value::Str("contract".into()), Value::Bool(false));
2689                }
2690                if (result.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null) == Value::Null) {
2691                    add_element_to_object(&mut result, &Value::Str("swap".into()), Value::Bool(false));
2692                }
2693                if (result.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null) == Value::Null) {
2694                    add_element_to_object(&mut result, &Value::Str("future".into()), Value::Bool(false));
2695                }
2696                if (result.as_map().and_then(|__m| __m.get("option")).cloned().unwrap_or(Value::Null) == Value::Null) {
2697                    add_element_to_object(&mut result, &Value::Str("option".into()), Value::Bool(false));
2698                }
2699                if (result.as_map().and_then(|__m| __m.get("index")).cloned().unwrap_or(Value::Null) == Value::Null) {
2700                    add_element_to_object(&mut result, &Value::Str("index".into()), Value::Bool(false));
2701                }
2702            }
2703            return result;
2704        }
2705        return self.extend(cleanStructure, &[]);
2706
2707    Value::Null
2708}
2709
2710    fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2711        let mut currencies = get_arg(optional_args, 0, Value::Null);
2712        let mut values: Value = Value::from(vec![]);
2713        { let __t = self.create_safe_dictionary(&[]); self.markets_by_id = __t; }
2714        // handle marketId conflicts
2715        // we insert spot markets first
2716        let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".into()), &[Value::Bool(true), Value::Bool(true)]);
2717        {
2718                        let mut i: Value = Value::Int(0);
2719            let mut __for_first_86: bool = true;
2720            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) } {
2721            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);
2722            if (in_op(&self.markets_by_id, &crate::value::get_value_k(&value, "id"))) {
2723                let mut marketsByIdArray: Value = get_value(&self.markets_by_id, &crate::value::get_value_k(&value, "id"));
2724                append_to_array(&mut marketsByIdArray, value.clone());
2725                add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), marketsByIdArray);
2726            }  else {
2727                add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), Value::from(vec![value.clone()]));
2728            }
2729            // strip undefined-valued keys from the parsed market before deepExtend,
2730            // otherwise an explicit `taker: undefined` (from safeMarketStructure)
2731            // would clobber the fee defaults from this.fees['trading'] in the merge
2732            let mut valueDefined: Value = Value::Map({
2733                let mut m = indexmap::IndexMap::new();
2734                m
2735            });
2736            let mut valueKeys: Value = object_keys(&value);
2737            {
2738                                let mut j: Value = Value::Int(0);
2739                let mut __for_first_85: bool = true;
2740                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) } {
2741                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);
2742                if (get_value(&value, &valueKey) != Value::Null) {
2743                    if let Value::Dict(__d) = &mut valueDefined { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&valueKey), get_value(&value, &valueKey)); }
2744                }
2745            }
2746            }
2747            let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2748                let mut m = indexmap::IndexMap::new();
2749                    m.insert("precision".to_string(), self.precision.clone());
2750                    m.insert("limits".to_string(), self.limits.clone());
2751                m
2752            }), self.fees.as_map().and_then(|__m| __m.get("trading")).cloned().unwrap_or(Value::Null), valueDefined]);
2753            if is_equal(&market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2754                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("linear".into()));
2755            }  else if is_equal(&market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2756                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("inverse".into()));
2757            }  else {
2758                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Null);
2759            }
2760            append_to_array(&mut values, market.clone());
2761        }
2762        }
2763        { let __t = self.map_to_safe_map(self.index_by(values.clone(), Value::Str("symbol".into()))); self.markets = __t; }
2764        let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
2765        let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
2766        self.symbols = object_keys(&marketsSortedBySymbol);
2767        self.ids = object_keys(&marketsSortedById);
2768        let mut numCurrencies: Value = Value::Int(0);
2769        if (currencies != Value::Null) {
2770            let mut keys: Value = object_keys(&currencies);
2771            numCurrencies = Value::Int(keys.len() as i64);
2772        }
2773        if numCurrencies.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2774            // currencies is always undefined when called in constructor but not when called from loadMarkets
2775            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2776        }  else {
2777            let mut baseCurrencies: Value = Value::from(vec![]);
2778            let mut quoteCurrencies: Value = Value::from(vec![]);
2779            {
2780                                let mut i: Value = Value::Int(0);
2781                let mut __for_first_87: bool = true;
2782                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) } {
2783                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);
2784                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()), &[]) });
2785                let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2786    let mut m = indexmap::IndexMap::new();
2787    m
2788})]);
2789                if (matches!(&market, Value::Dict(__d) if __d.contains_key("base"))) {
2790                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2791                        let mut m = indexmap::IndexMap::new();
2792                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".into()), Value::Str("base".into()), &[]));
2793                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2794                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2795                            m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".into()), Value::Str("amount".into()), &[defaultCurrencyPrecision.clone()]));
2796                        m
2797                    }));
2798                    append_to_array(&mut baseCurrencies, currency.clone());
2799                }
2800                if (matches!(&market, Value::Dict(__d) if __d.contains_key("quote"))) {
2801                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2802                        let mut m = indexmap::IndexMap::new();
2803                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".into()), Value::Str("quote".into()), &[]));
2804                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2805                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2806                            m.insert("precision".to_string(), self.safe_value2(marketPrecision, Value::Str("quote".into()), Value::Str("price".into()), &[defaultCurrencyPrecision]));
2807                        m
2808                    }));
2809                    append_to_array(&mut quoteCurrencies, currency);
2810                }
2811            }
2812            }
2813            baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2814            quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2815            { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".into()))); self.baseCurrencies = __t; }
2816            { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".into()))); self.quoteCurrencies = __t; }
2817            let mut allCurrencies: Value = self.array_concat(baseCurrencies, quoteCurrencies);
2818            let mut groupedCurrencies: Value = self.group_by(allCurrencies, Value::Str("code".into()), &[]);
2819            let mut codes: Value = object_keys(&groupedCurrencies);
2820            let mut resultingCurrencies: Value = Value::from(vec![]);
2821            {
2822                                let mut i: Value = Value::Int(0);
2823                let mut __for_first_89: bool = true;
2824                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) } {
2825                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);
2826                let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code, &[Value::from(vec![])]);
2827                let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2828                {
2829                                        let mut j: Value = Value::Int(1);
2830                    let mut __for_first_88: bool = true;
2831                    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) } {
2832                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2833                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2834                    let mut currentPrecision: Value = self.safe_number_k(currentCurrency.clone(), "precision", &[]);
2835                    let mut highestPrecision: Value = self.safe_number_k(highestPrecisionCurrency.clone(), "precision", &[]);
2836                    if (currentPrecision == Value::Null) || (highestPrecision == Value::Null) {
2837                        continue;
2838                    }
2839                    if (self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64()) {
2840                        if currentPrecision.as_f64().unwrap_or(f64::NAN) < highestPrecision.as_f64().unwrap_or(f64::NAN) {
2841                            highestPrecisionCurrency = currentCurrency.clone();
2842                        }
2843                    }  else if currentPrecision.as_f64().unwrap_or(f64::NAN) > highestPrecision.as_f64().unwrap_or(f64::NAN) {
2844                        highestPrecisionCurrency = currentCurrency;
2845                    }
2846                }
2847                }
2848                append_to_array(&mut resultingCurrencies, highestPrecisionCurrency);
2849            }
2850            }
2851            let mut sortedCurrencies: Value = self.sort_by(resultingCurrencies, Value::Str("code".into()), &[]);
2852            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(sortedCurrencies, Value::Str("code".into()))])); self.currencies = __t; }
2853        }
2854        { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".into())); self.currencies_by_id = __t; }
2855        let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
2856        self.codes = object_keys(&currenciesSortedByCode);
2857        if (self.markets.clone() == Value::Null) {
2858            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" setMarkets() markets not set".into()))));
2859        }
2860        return self.markets.clone();
2861
2862    Value::Null
2863}
2864
2865    fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2866        // Validate that both exchanges are of the same type
2867        if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".into()))) {
2868            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()))));
2869        }
2870        // Validate that source exchange has loaded markets
2871        if (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) || (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) {
2872            panic!("{}", crate::exchange_errors::exchange_error("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function"));
2873        }
2874        // Set all market-related data
2875        self.markets = get_value(&sourceExchange, &Value::Str("markets".into()));
2876        self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".into()));
2877        self.symbols = get_value(&sourceExchange, &Value::Str("symbols".into()));
2878        self.ids = get_value(&sourceExchange, &Value::Str("ids".into()));
2879        self.currencies = get_value(&sourceExchange, &Value::Str("currencies".into()));
2880        self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".into()));
2881        self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".into()));
2882        self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".into()));
2883        self.codes = get_value(&sourceExchange, &Value::Str("codes".into()));
2884        // check marketHelperProps
2885        let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".into())), Value::Str("marketHelperProps".into()), &[Value::from(vec![])]);
2886        {
2887                        let mut i: Value = Value::Int(0);
2888            let mut __for_first_90: bool = true;
2889            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) } {
2890            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2891            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2892            if (get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper) != Value::Null) {
2893                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)); }
2894            }
2895        }
2896        }
2897        return Value::Null;
2898
2899    Value::Null
2900}
2901
2902    fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2903        let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2904        let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe, &[wsBaseDescribe]);
2905        return superWithRestDescribe;
2906
2907    Value::Null
2908}
2909
2910    fn safe_balance(&self, mut balance: Value) -> Value {
2911        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())]), &[]);
2912        let mut codes: Value = object_keys(&balances);
2913        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("free".into(), Value::Map({
2914    let mut m = indexmap::IndexMap::new();
2915    m
2916})); }
2917        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("used".into(), Value::Map({
2918    let mut m = indexmap::IndexMap::new();
2919    m
2920})); }
2921        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("total".into(), Value::Map({
2922    let mut m = indexmap::IndexMap::new();
2923    m
2924})); }
2925        let mut debtBalance: Value = Value::Map({
2926            let mut m = indexmap::IndexMap::new();
2927            m
2928        });
2929        {
2930                        let mut i: Value = Value::Int(0);
2931            let mut __for_first_91: bool = true;
2932            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) } {
2933            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);
2934            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()), &[]);
2935            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()), &[]);
2936            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()), &[]);
2937            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()), &[]);
2938            if (total == Value::Null) && (free != Value::Null) && (used != Value::Null) {
2939                total = crate::precise::Precise::stringAdd(&free, &used);
2940            }
2941            if (free == Value::Null) && (total != Value::Null) && (used != Value::Null) {
2942                free = crate::precise::Precise::stringSub(&total, &used);
2943            }
2944            if (used == Value::Null) && (total != Value::Null) && (free != Value::Null) {
2945                used = crate::precise::Precise::stringSub(&total, &free);
2946            }
2947            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".into()), self.parse_number(free, &[]));
2948            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".into()), self.parse_number(used, &[]));
2949            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".into()), self.parse_number(total, &[]));
2950            { 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); };
2951            { 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); };
2952            { 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); };
2953            if (debt != Value::Null) {
2954                add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".into()), self.parse_number(debt, &[]));
2955                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")); }
2956            }
2957        }
2958        }
2959        let mut debtBalanceArray: Value = object_keys(&debtBalance);
2960        let mut length: Value = Value::Int(debtBalanceArray.len() as i64);
2961        if (length != Value::Null) && (length.as_f64() != Some(0.0)) {
2962            if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("debt".into(), debtBalance); }
2963        }
2964        return balance;
2965
2966    Value::Null
2967}
2968
2969    fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2970        let mut market = get_arg(optional_args, 0, Value::Null);
2971        // parses numbers as strings
2972        // * it is important pass the trades as unparsed rawTrades
2973        let mut orderDict: Value = order.clone();
2974        if (order == Value::Null) {
2975            orderDict = Value::Map({
2976                let mut m = indexmap::IndexMap::new();
2977                m
2978            });
2979        }
2980        let mut amount: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "amount", &[]));
2981        let mut remaining: Value = self.safe_string_k(orderDict.clone(), "remaining", &[]);
2982        let mut filled: Value = self.safe_string_k(orderDict.clone(), "filled", &[]);
2983        let mut cost: Value = self.safe_string_k(orderDict.clone(), "cost", &[]);
2984        let mut average: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "average", &[]));
2985        let mut price: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "price", &[]));
2986        let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastTradeTimestamp", &[]);
2987        let mut symbol: Value = self.safe_string_k(orderDict.clone(), "symbol", &[]);
2988        let mut side: Value = self.safe_string_k(orderDict.clone(), "side", &[]);
2989        let mut status: Value = self.safe_string_k(orderDict.clone(), "status", &[]);
2990        let mut parseFilled: bool = filled == Value::Null;
2991        let mut parseCost: bool = cost == Value::Null;
2992        let mut parseLastTradeTimeTimestamp: bool = lastTradeTimeTimestamp == Value::Null;
2993        let mut fee: Value = self.safe_value_k(orderDict.clone(), "fee", &[]);
2994        let mut parseFee: bool = fee == Value::Null;
2995        let mut parseFees: bool = self.safe_value_k(orderDict.clone(), "fees", &[]) == Value::Null;
2996        let mut parseSymbol: bool = symbol == Value::Null;
2997        let mut parseSide: bool = side == Value::Null;
2998        let mut shouldParseFees: bool = parseFee || parseFees;
2999        let mut fees: Value = self.safe_list_k(orderDict.clone(), "fees", &[Value::from(vec![])]);
3000        let mut trades: Value = Value::from(vec![]);
3001        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);
3002        if parseFilled || parseCost || shouldParseFees {
3003            let mut rawTrades: Value = self.safe_value_k(orderDict.clone(), "trades", &[trades.clone()]);
3004            // const oldNumber = this.number;
3005            // we parse trades as strings here!
3006            // i don't think this is needed anymore
3007            // (this as any).number = String;
3008            let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
3009            // parse trades if they haven't already been parsed
3010            let mut tradesAreParsed: bool = (firstTrade != Value::Null) && (in_op(&firstTrade, &Value::Str("info".into()))) && (in_op(&firstTrade, &Value::Str("id".into())));
3011            if !tradesAreParsed {
3012                trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
3013            }  else {
3014                trades = rawTrades;
3015            }
3016            // this.number = oldNumber; why parse trades as strings if you read the value using `safeString` ?
3017            let mut tradesLength: Value = Value::Int(0);
3018            let mut isArray: bool = matches!(&trades, Value::Arr(_));
3019            if isArray {
3020                tradesLength = Value::Int(trades.len() as i64);
3021            }
3022            if isArray && (tradesLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) {
3023                // move properties that are defined in trades up into the order
3024                if (orderDict.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) == Value::Null) {
3025                    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"));
3026                }
3027                if (orderDict.as_map().and_then(|__m| __m.get("side")).cloned().unwrap_or(Value::Null) == Value::Null) {
3028                    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"));
3029                }
3030                if (orderDict.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null) == Value::Null) {
3031                    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"));
3032                }
3033                if (orderDict.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null) == Value::Null) {
3034                    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"));
3035                }
3036                if parseFilled {
3037                    filled = Value::Str("0".into());
3038                }
3039                if parseCost {
3040                    cost = Value::Str("0".into());
3041                }
3042                {
3043                                        let mut i: Value = Value::Int(0);
3044                    let mut __for_first_93: bool = true;
3045                    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) } {
3046                    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);
3047                    let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3048                    if parseFilled && (tradeAmount != Value::Null) {
3049                        filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
3050                    }
3051                    let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3052                    if parseCost && (tradeCost != Value::Null) {
3053                        cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
3054                    }
3055                    if parseSymbol {
3056                        symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
3057                    }
3058                    if parseSide {
3059                        side = self.safe_string_k(trade.clone(), "side", &[]);
3060                    }
3061                    let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
3062                    if parseLastTradeTimeTimestamp && (tradeTimestamp != Value::Null) {
3063                        if (lastTradeTimeTimestamp == Value::Null) {
3064                            lastTradeTimeTimestamp = tradeTimestamp.clone();
3065                        }  else {
3066                            lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
3067                        }
3068                    }
3069                    if shouldParseFees {
3070                        let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
3071                        if (tradeFees != Value::Null) {
3072                            {
3073                                                                let mut j: Value = Value::Int(0);
3074                                let mut __for_first_92: bool = true;
3075                                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) } {
3076                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3077                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3078                                append_to_array(&mut fees, self.extend(Value::Map({
3079                                    let mut m = indexmap::IndexMap::new();
3080                                    m
3081                                }), &[tradeFee.clone()]));
3082                            }
3083                            }
3084                        }  else {
3085                            let mut tradeFee: Value = self.safe_value_k(trade, "fee", &[]);
3086                            if (tradeFee != Value::Null) {
3087                                append_to_array(&mut fees, self.extend(Value::Map({
3088                                    let mut m = indexmap::IndexMap::new();
3089                                    m
3090                                }), &[tradeFee.clone()]));
3091                            }
3092                        }
3093                    }
3094                }
3095                }
3096            }
3097        }
3098        if shouldParseFees {
3099            let mut reducedFees: Value = fees.clone();
3100            if is_true(&self.reduceFees) {
3101                reducedFees = self.reduce_fees_by_currency(fees);
3102            }
3103            if (reducedFees == Value::Null) {
3104                reducedFees = Value::from(vec![]);
3105            }
3106            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3107            {
3108                                let mut i: Value = Value::Int(0);
3109                let mut __for_first_94: bool = true;
3110                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 } {
3111                { 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); };
3112                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()))) {
3113                    { 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); };
3114                }
3115            }
3116            }
3117            if !parseFee && (reducedLength == 0.0) {
3118                // copy fee to avoid modification by reference
3119                let mut feeCopy: Value = self.deep_extend(fee, &[]);
3120                { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".into()), __be_tmp); };
3121                if (in_op(&feeCopy, &Value::Str("rate".into()))) {
3122                    { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".into()), __be_tmp); };
3123                }
3124                append_to_array(&mut reducedFees, feeCopy);
3125            }
3126            add_element_to_object(&mut orderDict, &Value::Str("fees".into()), reducedFees.clone());
3127            if parseFee && (reducedLength == 1.0) {
3128                add_element_to_object(&mut orderDict, &Value::Str("fee".into()), reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
3129            }
3130        }
3131        if (amount == Value::Null) {
3132            // ensure amount = filled + remaining
3133            if (filled != Value::Null) && (remaining != Value::Null) {
3134                amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3135            }  else if (status.as_str() == Some("closed")) {
3136                amount = filled.clone();
3137            }
3138        }
3139        if (filled == Value::Null) {
3140            if (amount != Value::Null) && (remaining != Value::Null) {
3141                filled = crate::precise::Precise::stringSub(&amount, &remaining);
3142            }  else if (status.as_str() == Some("closed")) && (amount != Value::Null) {
3143                filled = amount.clone();
3144            }
3145        }
3146        if (remaining == Value::Null) {
3147            if (amount != Value::Null) && (filled != Value::Null) {
3148                remaining = crate::precise::Precise::stringSub(&amount, &filled);
3149            }  else if (status.as_str() == Some("closed")) {
3150                remaining = Value::Str("0".into());
3151            }
3152        }
3153        // ensure that the average field is calculated correctly
3154        let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3155        let mut contractSize: Value = self.number_to_string(self.safe_value_k(market, "contractSize", &[Value::Int(1)]));
3156        // inverse
3157        // price = filled * contract size / cost
3158        //
3159        // linear
3160        // price = cost / (filled * contract size)
3161        if (average == Value::Null) {
3162            if (filled != Value::Null) && (cost != Value::Null) && is_true(&crate::precise::Precise::stringGt(&filled, &Value::Str("0".into()))) {
3163                let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3164                if (inverse.as_bool() == Some(true)) {
3165                    average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3166                }  else {
3167                    average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3168                }
3169            }
3170        }
3171        // similarly
3172        // inverse
3173        // cost = filled * contract size / price
3174        //
3175        // linear
3176        // cost = filled * contract size * price
3177        let mut costPriceExists: bool = (average != Value::Null) || (price != Value::Null);
3178        if parseCost && (filled != Value::Null) && costPriceExists {
3179            let mut multiplyPrice: Value = Value::Null;
3180            if (average == Value::Null) {
3181                multiplyPrice = price.clone();
3182            }  else {
3183                multiplyPrice = average.clone();
3184            }
3185            // contract trading
3186            let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3187            if (inverse.as_bool() == Some(true)) {
3188                cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3189            }  else {
3190                cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3191            }
3192        }
3193        // support for market orders
3194        let mut orderType: Value = self.safe_value_k(orderDict.clone(), "type", &[]);
3195        let mut emptyPrice: bool = (price == Value::Null) || is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".into())));
3196        if emptyPrice && (orderType.as_str() == Some("market")) {
3197            price = average.clone();
3198        }
3199        {
3200                        let mut i: Value = Value::Int(0);
3201            let mut __for_first_96: bool = true;
3202            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) } {
3203            let mut entry: Value = get_value(&trades, &i);
3204            let mut entry: Value = get_value(&trades, &i);
3205            { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".into()), __be_tmp); };
3206            { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".into()), __be_tmp); };
3207            { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".into()), __be_tmp); };
3208            let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3209    let mut m = indexmap::IndexMap::new();
3210    m
3211})]);
3212            { 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); } }
3213            if (matches!(&tradeFee, Value::Dict(__d) if __d.contains_key("rate"))) {
3214                { 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); } }
3215            }
3216            let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::from(vec![])]);
3217            {
3218                                let mut j: Value = Value::Int(0);
3219                let mut __for_first_95: bool = true;
3220                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) } {
3221                { 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); };
3222            }
3223            }
3224            add_element_to_object(&mut entry, &Value::Str("fees".into()), entryFees);
3225            add_element_to_object(&mut entry, &Value::Str("fee".into()), tradeFee);
3226        }
3227        }
3228        let mut timeInForce: Value = self.safe_string_k(orderDict.clone(), "timeInForce", &[]);
3229        let mut postOnly: Value = self.safe_value_k(orderDict.clone(), "postOnly", &[]);
3230        // timeInForceHandling
3231        if (timeInForce == Value::Null) {
3232            if !isTriggerOrSLTpOrder && (self.safe_string_k(orderDict.clone(), "type", &[]).as_str() == Some("market")) {
3233                timeInForce = Value::Str("IOC".into());
3234            }
3235            // allow postOnly override
3236            if is_equal(&postOnly, &Value::Bool(true)) {
3237                timeInForce = Value::Str("PO".into());
3238            }
3239        }  else if (postOnly == Value::Null) {
3240            // timeInForce is not undefined here
3241            postOnly = Value::Bool(timeInForce.as_str() == Some("PO"));
3242        }
3243        let mut timestamp: Value = self.safe_integer_k(orderDict.clone(), "timestamp", &[]);
3244        let mut lastUpdateTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastUpdateTimestamp", &[]);
3245        let mut datetime: Value = self.safe_string_k(orderDict.clone(), "datetime", &[]);
3246        if (datetime == Value::Null) {
3247            datetime = self.iso8601(timestamp.clone());
3248        }
3249        let mut triggerPrice: Value = self.parse_number(self.safe_string2(orderDict.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]), &[]);
3250        let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "takeProfitPrice", &[]), &[]);
3251        let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "stopLossPrice", &[]), &[]);
3252        return self.extend(orderDict.clone(), &[Value::Map({
3253    let mut m = indexmap::IndexMap::new();
3254        m.insert("id".to_string(), self.safe_string_k(orderDict.clone(), "id", &[]));
3255        m.insert("clientOrderId".to_string(), self.safe_string_k(orderDict.clone(), "clientOrderId", &[]));
3256        m.insert("timestamp".to_string(), timestamp);
3257        m.insert("datetime".to_string(), datetime);
3258        m.insert("symbol".to_string(), symbol);
3259        m.insert("type".to_string(), self.safe_string_k(orderDict.clone(), "type", &[]));
3260        m.insert("side".to_string(), side);
3261        m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp);
3262        m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp);
3263        m.insert("price".to_string(), self.parse_number(price, &[]));
3264        m.insert("amount".to_string(), self.parse_number(amount, &[]));
3265        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3266        m.insert("average".to_string(), self.parse_number(average, &[]));
3267        m.insert("filled".to_string(), self.parse_number(filled, &[]));
3268        m.insert("remaining".to_string(), self.parse_number(remaining, &[]));
3269        m.insert("timeInForce".to_string(), timeInForce);
3270        m.insert("postOnly".to_string(), postOnly);
3271        m.insert("trades".to_string(), trades);
3272        m.insert("reduceOnly".to_string(), self.safe_value_k(orderDict.clone(), "reduceOnly", &[]));
3273        m.insert("stopPrice".to_string(), triggerPrice.clone());
3274        m.insert("triggerPrice".to_string(), triggerPrice);
3275        m.insert("takeProfitPrice".to_string(), takeProfitPrice);
3276        m.insert("stopLossPrice".to_string(), stopLossPrice);
3277        m.insert("status".to_string(), status);
3278        m.insert("fee".to_string(), self.safe_value_k(orderDict, "fee", &[]));
3279    m
3280})]);
3281
3282    Value::Null
3283}
3284
3285    fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3286        let mut market = get_arg(optional_args, 0, Value::Null);
3287        let mut since = get_arg(optional_args, 1, Value::Null);
3288        let mut limit = get_arg(optional_args, 2, Value::Null);
3289        let mut params = get_arg(optional_args, 3, Value::Map({
3290    let mut m = indexmap::IndexMap::new();
3291    m
3292}));
3293        //
3294        // the value of orders is either a dict or a list
3295        //
3296        // dict
3297        //
3298        //     {
3299        //         'id1': { ... },
3300        //         'id2': { ... },
3301        //         'id3': { ... },
3302        //         ...
3303        //     }
3304        //
3305        // list
3306        //
3307        //     [
3308        //         { 'id': 'id1', ... },
3309        //         { 'id': 'id2', ... },
3310        //         { 'id': 'id3', ... },
3311        //         ...
3312        //     ]
3313        //
3314        if (orders == Value::Null) {
3315            return Value::from(vec![]);
3316        }
3317        let mut results: Value = Value::from(vec![]);
3318        if (matches!(&orders, Value::Arr(_))) {
3319            {
3320                                let mut i: Value = Value::Int(0);
3321                let mut __for_first_97: bool = true;
3322                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) } {
3323                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, get_value(&orders, &i), &[market.clone()]); // don't inline this call
3324                let mut order: Value = self.extend(parsed, &[params.clone()]);
3325                append_to_array(&mut results, order.clone());
3326            }
3327            }
3328        }  else {
3329            let mut ids: Value = object_keys(&orders);
3330            {
3331                                let mut i: Value = Value::Int(0);
3332                let mut __for_first_98: bool = true;
3333                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) } {
3334                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);
3335                let mut idExtended: Value = self.extend(Value::Map({
3336                    let mut m = indexmap::IndexMap::new();
3337                        m.insert("id".to_string(), id.clone());
3338                    m
3339                }), &[get_value(&orders, &id)]);
3340                let mut parsedOrder: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, idExtended, &[market.clone()]); // don't  inline these calls
3341                let mut order: Value = self.extend(parsedOrder, &[params.clone()]);
3342                append_to_array(&mut results, order);
3343            }
3344            }
3345        }
3346        results = self.sort_by(results.clone(), Value::Str("timestamp".into()), &[]);
3347        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
3348        return self.filter_by_symbol_since_limit(results, &[symbol, since, limit]);
3349
3350    Value::Null
3351}
3352
3353    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 {
3354        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3355        let mut feeRate = get_arg(optional_args, 1, Value::Null);
3356        let mut params = get_arg(optional_args, 2, Value::Map({
3357    let mut m = indexmap::IndexMap::new();
3358    m
3359}));
3360        if (type_var.as_str() == Some("market")) && (takerOrMaker.as_str() == Some("maker")) {
3361            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()))));
3362        }
3363        let mut markets: Value = self.markets.clone();
3364        if (markets == Value::Null) {
3365            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
3366        }
3367        let mut market: Value = get_value(&markets, &symbol);
3368        let mut market: Value = get_value(&markets, &symbol);
3369        let mut feeSide: Option<String> = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".into())]).as_str().map(str::to_owned);
3370        let mut useQuote: Value = Value::Null;
3371        if (feeSide.as_deref() == Some("get")) {
3372            // the fee is always in the currency you get
3373            useQuote = Value::Bool(side.as_str() == Some("sell"));
3374        }  else if (feeSide.as_deref() == Some("give")) {
3375            // the fee is always in the currency you give
3376            useQuote = Value::Bool(side.as_str() == Some("buy"));
3377        }  else {
3378            // the fee is always in feeSide currency
3379            useQuote = Value::Bool(feeSide.as_deref() == Some("quote"));
3380        }
3381        let mut cost: Value = self.number_to_string(amount);
3382        let mut key: Value = Value::Null;
3383        if useQuote.as_bool() == Some(true) {
3384            let mut priceString: Value = self.number_to_string(price);
3385            cost = crate::precise::Precise::stringMul(&cost, &priceString);
3386            key = Value::Str("quote".into());
3387        }  else {
3388            key = Value::Str("base".into());
3389        }
3390        // for derivatives, the fee is in 'settle' currency
3391        if !is_equal(&crate::value::get_value_k(&market, "spot"), &Value::Bool(true)) {
3392            key = Value::Str("settle".into());
3393        }
3394        // even if `takerOrMaker` argument was set to 'maker', for 'market' orders we should forcefully override it to 'taker'
3395        let mut takerOrMakerResolved: Value = (if (type_var.as_str() == Some("market")) { Value::Str("taker".into()) } else { takerOrMaker });
3396        let mut rate: Value = (if (feeRate != Value::Null) { self.number_to_string(feeRate) } else { self.safe_string(market.clone(), takerOrMakerResolved.clone(), &[]) });
3397        cost = crate::precise::Precise::stringMul(&cost, &rate);
3398        return Value::Map({
3399    let mut m = indexmap::IndexMap::new();
3400        m.insert("type".to_string(), takerOrMakerResolved);
3401        m.insert("currency".to_string(), get_value(&market, &key));
3402        m.insert("rate".to_string(), self.parse_number(rate, &[]));
3403        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3404    m
3405});
3406
3407    Value::Null
3408}
3409
3410    fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3411        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3412        let mut params = get_arg(optional_args, 1, Value::Map({
3413    let mut m = indexmap::IndexMap::new();
3414    m
3415}));
3416        return self.calculate_fee_with_rate(symbol, type_var, side, amount, price, &[takerOrMaker, Value::Null, params]);
3417
3418    Value::Null
3419}
3420
3421    fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3422        let mut market = get_arg(optional_args, 0, Value::Null);
3423        let __market_empty = indexmap::IndexMap::new();
3424        let market = market.as_map().unwrap_or(&__market_empty);
3425        let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
3426        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 });
3427        let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
3428        let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3429        let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3430        if (baseValue == Value::Null) && (contracts != Value::Null) && (contractSize != Value::Null) && (price != Value::Null) {
3431            baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
3432        }
3433        if (quoteValue == Value::Null) && (baseValue != Value::Null) && (price != Value::Null) {
3434            quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
3435        }
3436        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(contracts, &[])); }
3437        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(contractSize, &[])); }
3438        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3439        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("baseValue".into(), self.parse_number(baseValue, &[])); }
3440        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("quoteValue".into(), self.parse_number(quoteValue, &[])); }
3441        return liquidation;
3442
3443    Value::Null
3444}
3445
3446    fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3447        let mut market = get_arg(optional_args, 0, Value::Null);
3448        let __market_empty = indexmap::IndexMap::new();
3449        let market = market.as_map().unwrap_or(&__market_empty);
3450        let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3451        let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
3452        let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3453        if (cost == Value::Null) {
3454            // contract trading
3455            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 });
3456            let mut multiplyPrice: Value = price.clone();
3457            if (contractSize != Value::Null) {
3458                let mut inverse: Value = (match market.get("inverse") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) });
3459                if (inverse.as_bool() == Some(true)) {
3460                    multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &price);
3461                }
3462                multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3463            }
3464            cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
3465        }
3466        let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
3467        let mut resultFee: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3468        let mut resultFees: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
3469        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fee".into(), resultFee); }
3470        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fees".into(), resultFees); }
3471        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("amount".into(), self.parse_number(amount, &[])); }
3472        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3473        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("cost".into(), self.parse_number(cost, &[])); }
3474        return trade;
3475
3476    Value::Null
3477}
3478
3479    fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3480        let mut timestamp = get_arg(optional_args, 0, Value::Null);
3481        let mut side = get_arg(optional_args, 1, Value::Null);
3482        let mut amount = get_arg(optional_args, 2, Value::Null);
3483        let mut price = get_arg(optional_args, 3, Value::Null);
3484        let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3485        // this approach is being used by multiple exchanges (mexc, woo, coinsbit, dydx, ...)
3486        let mut id: Value = Value::Null;
3487        if (timestamp != Value::Null) {
3488            id = self.number_to_string(timestamp);
3489            if (side != Value::Null) {
3490                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), side).into())).into());
3491            }
3492            if (amount != Value::Null) {
3493                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(amount)).into())).into());
3494            }
3495            if (price != Value::Null) {
3496                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(price)).into())).into());
3497            }
3498            if (takerOrMaker != Value::Null) {
3499                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), takerOrMaker).into())).into());
3500            }
3501        }
3502        return id;
3503
3504    Value::Null
3505}
3506
3507    fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3508        let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3509        let mut fees: Value = self.safe_list_k(container, "fees", &[]);
3510        let mut feeDefined: bool = fee != Value::Null;
3511        let mut feesDefined: bool = fees != Value::Null;
3512        // parsing only if at least one of them is defined
3513        let mut shouldParseFees: bool = feeDefined || feesDefined;
3514        if shouldParseFees {
3515            if feeDefined {
3516                fee = self.parse_fee_numeric(fee.clone());
3517            }
3518            if !feesDefined {
3519                // just set it directly, no further processing needed.
3520                fees = Value::from(vec![fee.clone()]);
3521            }
3522            // 'fees' were set, so reparse them
3523            let mut reducedFees: Value = fees.clone();
3524            if is_true(&self.reduceFees) {
3525                reducedFees = self.reduce_fees_by_currency(fees.clone());
3526            }
3527            if (reducedFees == Value::Null) {
3528                reducedFees = Value::from(vec![]);
3529            }
3530            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3531            {
3532                                let mut i: Value = Value::Int(0);
3533                let mut __for_first_99: bool = true;
3534                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 } {
3535                { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3536            }
3537            }
3538            fees = reducedFees.clone();
3539            if (reducedLength == 1.0) {
3540                fee = reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3541            }  else if (reducedLength == 0.0) {
3542                fee = Value::Null;
3543            }
3544        }
3545        // in case `fee & fees` are undefined, set `fees` as empty array
3546        if (fee == Value::Null) {
3547            fee = Value::Map({
3548                let mut m = indexmap::IndexMap::new();
3549                    m.insert("cost".to_string(), Value::Null);
3550                    m.insert("currency".to_string(), Value::Null);
3551                m
3552            });
3553        }
3554        if (fees == Value::Null) {
3555            fees = Value::from(vec![]);
3556        }
3557        return Value::from(vec![fee, fees]);
3558
3559    Value::Null
3560}
3561
3562    fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3563        { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); }; // ensure numeric
3564        if (in_op(&fee, &Value::Str("rate".into()))) {
3565            { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".into()), __be_tmp); };
3566        }
3567        return fee;
3568
3569    Value::Null
3570}
3571
3572    fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3573        //  i.e. findNearestCeiling ([ 10, 30, 50],  23) returns 30
3574        let mut length: Value = Value::Int(arr.len() as i64);
3575        {
3576                        let mut i: Value = Value::Int(0);
3577            let mut __for_first_100: bool = true;
3578            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) } {
3579            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);
3580            if providedValue.as_f64().unwrap_or(f64::NAN) <= current.as_f64().unwrap_or(f64::NAN) {
3581                return current;
3582            }
3583        }
3584        }
3585        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 }));
3586
3587    Value::Null
3588}
3589
3590    fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3591        let mut result: Value = Value::from(vec![]);
3592        let mut keys: Value = object_keys(&obj);
3593        {
3594                        let mut i: Value = Value::Int(0);
3595            let mut __for_first_101: bool = true;
3596            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) } {
3597            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);
3598            let mut item: Value = get_value(&obj, &key);
3599            let mut item: Value = get_value(&obj, &key);
3600            if (item == Value::Null) {
3601                continue;
3602            }
3603            let mut itemWithKey: Value = self.extend(Value::Map({
3604                let mut m = indexmap::IndexMap::new();
3605                m
3606            }), &[item]);
3607            add_element_to_object(&mut itemWithKey, &keyName, key);
3608            append_to_array(&mut result, itemWithKey);
3609        }
3610        }
3611        return result;
3612
3613    Value::Null
3614}
3615
3616    fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3617        let mut reversed: Value = Value::Map({
3618            let mut m = indexmap::IndexMap::new();
3619            m
3620        });
3621        let mut keys: Value = object_keys(&dict);
3622        {
3623                        let mut i: Value = Value::Int(0);
3624            let mut __for_first_102: bool = true;
3625            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) } {
3626            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);
3627            let mut value: Value = get_value(&dict, &key);
3628            let mut value: Value = get_value(&dict, &key);
3629            if matches!(&value, Value::Str(_)) {
3630                if let Value::Dict(__d) = &mut reversed { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&value), key); }
3631            }
3632        }
3633        }
3634        return reversed;
3635
3636    Value::Null
3637}
3638
3639    fn string_to_base16(&self, mut str_val: Value) -> Value {
3640        return Value::Str(format!("{}{}", Value::Str("0x".into()), self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val, &[]), &[]), &[])).into());
3641
3642    Value::Null
3643}
3644
3645    fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3646        //
3647        // this function takes a list of fee structures having the following format
3648        //
3649        //     string = true
3650        //
3651        //     [
3652        //         { 'currency': 'BTC', 'cost': '0.1' },
3653        //         { 'currency': 'BTC', 'cost': '0.2'  },
3654        //         { 'currency': 'BTC', 'cost': '0.2', 'rate': '0.00123' },
3655        //         { 'currency': 'BTC', 'cost': '0.4', 'rate': '0.00123' },
3656        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3657        //         { 'currency': 'USDT', 'cost': '12.3456' },
3658        //     ]
3659        //
3660        //     string = false
3661        //
3662        //     [
3663        //         { 'currency': 'BTC', 'cost': 0.1 },
3664        //         { 'currency': 'BTC', 'cost': 0.2 },
3665        //         { 'currency': 'BTC', 'cost': 0.2, 'rate': 0.00123 },
3666        //         { 'currency': 'BTC', 'cost': 0.4, 'rate': 0.00123 },
3667        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3668        //         { 'currency': 'USDT', 'cost': 12.3456 },
3669        //     ]
3670        //
3671        // and returns a reduced fee list, where fees are summed per currency and rate (if any)
3672        //
3673        //     string = true
3674        //
3675        //     [
3676        //         { 'currency': 'BTC', 'cost': '0.4'  },
3677        //         { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
3678        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3679        //         { 'currency': 'USDT', 'cost': '12.3456' },
3680        //     ]
3681        //
3682        //     string  = false
3683        //
3684        //     [
3685        //         { 'currency': 'BTC', 'cost': 0.3  },
3686        //         { 'currency': 'BTC', 'cost': 0.6, 'rate': 0.00123 },
3687        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3688        //         { 'currency': 'USDT', 'cost': 12.3456 },
3689        //     ]
3690        //
3691        let mut reduced: Value = Value::Map({
3692            let mut m = indexmap::IndexMap::new();
3693            m
3694        });
3695        {
3696                        let mut i: Value = Value::Int(0);
3697            let mut __for_first_103: bool = true;
3698            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) } {
3699            let mut fee: Value = get_value(&fees, &i);
3700            let mut fee: Value = get_value(&fees, &i);
3701            let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3702            let mut feeCurrencyCode: Value = (if (code != Value::Null) { code.clone() } else { to_string_val(&i) });
3703            if (feeCurrencyCode != Value::Null) {
3704                let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3705                let mut cost: Value = self.safe_string_k(fee, "cost", &[]);
3706                if (cost == Value::Null) {
3707                    continue;
3708                }
3709                if !(in_op(&reduced, &feeCurrencyCode)) {
3710                    if let Value::Dict(__d) = &mut reduced { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&feeCurrencyCode), Value::Map({
3711    let mut m = indexmap::IndexMap::new();
3712    m
3713})); }
3714                }
3715                let mut rateKey: Value = (if (rate == Value::Null) { Value::Str("".into()) } else { rate.clone() });
3716                if (in_op(&reduced.as_map().and_then(|__m| feeCurrencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &rateKey)) {
3717                    { 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); };
3718                }  else {
3719                    add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
3720    let mut m = indexmap::IndexMap::new();
3721        m.insert("currency".to_string(), code);
3722        m.insert("cost".to_string(), cost);
3723    m
3724}));
3725                    if (rate != Value::Null) {
3726                        add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".into()), rate);
3727                    }
3728                }
3729            }
3730        }
3731        }
3732        let mut result: Value = Value::from(vec![]);
3733        let mut feeValues: Value = object_values(&reduced);
3734        {
3735                        let mut i: Value = Value::Int(0);
3736            let mut __for_first_104: bool = true;
3737            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) } {
3738            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));
3739            result = self.array_concat(result.clone(), reducedFeeValues);
3740        }
3741        }
3742        return result;
3743
3744    Value::Null
3745}
3746
3747    fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3748        let mut market = get_arg(optional_args, 0, Value::Null);
3749        let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3750        let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".into()), Value::Str("last".into()), &[]));
3751        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
3752        let mut percentage: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "percentage", &[]));
3753        let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3754        let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3755        let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
3756        let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
3757        if (vwap == Value::Null) {
3758            vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
3759        }
3760        // calculate open
3761        if (change != Value::Null) {
3762            if (close == Value::Null) && (average != Value::Null) {
3763                close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".into())));
3764            }
3765            if (open == Value::Null) && (close != Value::Null) {
3766                open = crate::precise::Precise::stringSub(&close, &change);
3767            }
3768        }  else if (percentage != Value::Null) {
3769            if (close == Value::Null) && (average != Value::Null) {
3770                let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".into()));
3771                // openAddClose = open * (1 + (100 + percentage)/100)
3772                let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3773                let mut calcOpen: Value = (if (open != Value::Null) { open.clone() } else { crate::precise::Precise::stringDiv(&openAddClose, &denominator) });
3774                close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3775            }
3776            if (open == Value::Null) && (close != Value::Null) {
3777                open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3778            }
3779        }
3780        // change
3781        if (change == Value::Null) {
3782            if (close != Value::Null) && (open != Value::Null) {
3783                change = crate::precise::Precise::stringSub(&close, &open);
3784            }  else if (close != Value::Null) && (percentage != Value::Null) {
3785                change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".into())));
3786            }  else if (open != Value::Null) && (percentage != Value::Null) {
3787                change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3788            }
3789        }
3790        // calculate things according to "open" (similar can be done with "close")
3791        if (open != Value::Null) {
3792            // percentage (using change)
3793            if (percentage == Value::Null) && (change != Value::Null) {
3794                percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".into()));
3795            }
3796            // close (using change)
3797            if (close == Value::Null) && (change != Value::Null) {
3798                close = crate::precise::Precise::stringAdd(&open, &change);
3799            }
3800            // close (using average)
3801            if (close == Value::Null) && (average != Value::Null) {
3802                // average is the midpoint of open and close, so twice it is their sum
3803                close = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&average, &Value::Str("2".into())), &open);
3804            }
3805            // average
3806            if (average == Value::Null) && (close != Value::Null) {
3807                let mut precision: Value = Value::Int(18);
3808                if (market != Value::Null) && self.is_tick_precision().as_bool() == Some(true) {
3809                    let mut marketPrecision: Value = self.safe_dict_k(market, "precision", &[]);
3810                    let mut precisionPrice: Value = self.safe_string_k(marketPrecision, "price", &[]);
3811                    if (precisionPrice != Value::Null) {
3812                        precision = self.precision_from_string(precisionPrice);
3813                    }
3814                }
3815                average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".into()), &precision);
3816            }
3817        }
3818        // timestamp and symbol operations don't belong in safeTicker
3819        // they should be done in the derived classes
3820        let mut closeParsed: Value = self.parse_number(self.omit_zero(close), &[]);
3821        return self.extend(ticker.clone(), &[Value::Map({
3822    let mut m = indexmap::IndexMap::new();
3823        m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3824        m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3825        m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3826        m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3827        m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3828        m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3829        m.insert("open".to_string(), self.parse_number(self.omit_zero(open), &[]));
3830        m.insert("close".to_string(), closeParsed.clone());
3831        m.insert("last".to_string(), closeParsed);
3832        m.insert("change".to_string(), self.parse_number(change, &[]));
3833        m.insert("percentage".to_string(), self.parse_number(percentage, &[]));
3834        m.insert("average".to_string(), self.parse_number(average, &[]));
3835        m.insert("vwap".to_string(), self.parse_number(vwap, &[]));
3836        m.insert("baseVolume".to_string(), self.parse_number(baseVolume, &[]));
3837        m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume, &[]));
3838        m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3839        m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3840        m.insert("markPrice".to_string(), self.safe_number_k(ticker, "markPrice", &[]));
3841    m
3842})]);
3843
3844    Value::Null
3845}
3846
3847    fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3848        let mut params = get_arg(optional_args, 0, Value::Map({
3849    let mut m = indexmap::IndexMap::new();
3850    m
3851}));
3852        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".into()))));
3853
3854    Value::Null
3855} }
3856
3857    fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3858        // async-virtual: try the derived exchange first
3859        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 {
3860            if !matches!(__v, crate::Value::Null) { return __v; }
3861        }
3862
3863        let mut params = get_arg(optional_args, 0, Value::Map({
3864    let mut m = indexmap::IndexMap::new();
3865    m
3866}));
3867        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayCrossMargin is not support yet".into()))));
3868
3869    Value::Null
3870} }
3871
3872    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 {
3873        // async-virtual: try the derived exchange first
3874        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 {
3875            if !matches!(__v, crate::Value::Null) { return __v; }
3876        }
3877
3878        let mut params = get_arg(optional_args, 0, Value::Map({
3879    let mut m = indexmap::IndexMap::new();
3880    m
3881}));
3882        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayIsolatedMargin is not support yet".into()))));
3883
3884    Value::Null
3885} }
3886
3887    fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3888        // async-virtual: try the derived exchange first
3889        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 {
3890            if !matches!(__v, crate::Value::Null) { return __v; }
3891        }
3892
3893        let mut params = get_arg(optional_args, 0, Value::Map({
3894    let mut m = indexmap::IndexMap::new();
3895    m
3896}));
3897        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowCrossMargin is not support yet".into()))));
3898
3899    Value::Null
3900} }
3901
3902    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 {
3903        // async-virtual: try the derived exchange first
3904        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 {
3905            if !matches!(__v, crate::Value::Null) { return __v; }
3906        }
3907
3908        let mut params = get_arg(optional_args, 0, Value::Map({
3909    let mut m = indexmap::IndexMap::new();
3910    m
3911}));
3912        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowIsolatedMargin is not support yet".into()))));
3913
3914    Value::Null
3915} }
3916
3917    fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3918        let mut symbol = get_arg(optional_args, 0, Value::Null);
3919        let mut params = get_arg(optional_args, 1, Value::Map({
3920    let mut m = indexmap::IndexMap::new();
3921    m
3922}));
3923        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".into()))));
3924
3925    Value::Null
3926} }
3927
3928    fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3929        let mut symbol = get_arg(optional_args, 0, Value::Null);
3930        let mut params = get_arg(optional_args, 1, Value::Map({
3931    let mut m = indexmap::IndexMap::new();
3932    m
3933}));
3934        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".into()))));
3935
3936    Value::Null
3937} }
3938
3939    fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3940        // async-virtual: try the derived exchange first
3941        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 {
3942            if !matches!(__v, crate::Value::Null) { return __v; }
3943        }
3944
3945        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3946        let mut since = get_arg(optional_args, 1, Value::Null);
3947        let mut limit = get_arg(optional_args, 2, Value::Null);
3948        let mut params = get_arg(optional_args, 3, Value::Map({
3949    let mut m = indexmap::IndexMap::new();
3950    m
3951}));
3952        let mut message: Value = Value::Str("".into());
3953        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)) {
3954            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());
3955        }
3956        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() is not supported yet".into())).into()), message)));
3957
3958    Value::Null
3959} }
3960
3961    fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3962        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3963        let mut since = get_arg(optional_args, 1, Value::Null);
3964        let mut limit = get_arg(optional_args, 2, Value::Null);
3965        let mut params = get_arg(optional_args, 3, Value::Map({
3966    let mut m = indexmap::IndexMap::new();
3967    m
3968}));
3969        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotOHLCV() is not supported yet".into()))));
3970
3971    Value::Null
3972} }
3973
3974    fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3975        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3976        let mut since = get_arg(optional_args, 1, Value::Null);
3977        let mut limit = get_arg(optional_args, 2, Value::Null);
3978        let mut params = get_arg(optional_args, 3, Value::Map({
3979    let mut m = indexmap::IndexMap::new();
3980    m
3981}));
3982        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractOHLCV() is not supported yet".into()))));
3983
3984    Value::Null
3985} }
3986
3987    fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3988        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3989        let mut since = get_arg(optional_args, 1, Value::Null);
3990        let mut limit = get_arg(optional_args, 2, Value::Null);
3991        let mut params = get_arg(optional_args, 3, Value::Map({
3992    let mut m = indexmap::IndexMap::new();
3993    m
3994}));
3995        let mut message: Value = Value::Str("".into());
3996        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)) {
3997            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());
3998        }
3999        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)));
4000
4001    Value::Null
4002} }
4003
4004    fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4005        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
4006        let mut since = get_arg(optional_args, 1, Value::Null);
4007        let mut limit = get_arg(optional_args, 2, Value::Null);
4008        let mut params = get_arg(optional_args, 3, Value::Map({
4009    let mut m = indexmap::IndexMap::new();
4010    m
4011}));
4012        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCV() is not supported yet".into()))));
4013
4014    Value::Null
4015} }
4016
4017    fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4018        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4019        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4020        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4021        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4022        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4023        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4024        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4025        let mut result: Value = Value::from(vec![]);
4026        let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp, &[Value::from(vec![])]);
4027        let mut opens: Value = self.safe_list(ohlcvs.clone(), open, &[Value::from(vec![])]);
4028        let mut highs: Value = self.safe_list(ohlcvs.clone(), high, &[Value::from(vec![])]);
4029        let mut lows: Value = self.safe_list(ohlcvs.clone(), low, &[Value::from(vec![])]);
4030        let mut closes: Value = self.safe_list(ohlcvs.clone(), close, &[Value::from(vec![])]);
4031        let mut volumes: Value = self.safe_list(ohlcvs, volume, &[Value::from(vec![])]);
4032        {
4033                        let mut i: Value = Value::Int(0);
4034            let mut __for_first_105: bool = true;
4035            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) } {
4036            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(), &[])]));
4037        }
4038        }
4039        return result;
4040
4041    Value::Null
4042}
4043
4044    fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4045        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4046        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4047        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4048        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4049        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4050        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4051        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4052        let mut result: Value = Value::Map({
4053            let mut m = indexmap::IndexMap::new();
4054            m
4055        });
4056        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&timestamp), Value::from(vec![])); }
4057        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&open), Value::from(vec![])); }
4058        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&high), Value::from(vec![])); }
4059        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&low), Value::from(vec![])); }
4060        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&close), Value::from(vec![])); }
4061        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&volume), Value::from(vec![])); }
4062        {
4063                        let mut i: Value = Value::Int(0);
4064            let mut __for_first_106: bool = true;
4065            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) } {
4066            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 })) });
4067            let mut resultTimestamp: Value = get_value(&result, &timestamp);
4068            append_to_array(&mut resultTimestamp, ts);
4069            crate::set_value(&mut result, &timestamp, resultTimestamp);
4070            let mut resultOpen: Value = get_value(&result, &open);
4071            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));
4072            crate::set_value(&mut result, &open, resultOpen);
4073            let mut resultHigh: Value = get_value(&result, &high);
4074            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));
4075            crate::set_value(&mut result, &high, resultHigh);
4076            let mut resultLow: Value = get_value(&result, &low);
4077            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));
4078            crate::set_value(&mut result, &low, resultLow);
4079            let mut resultClose: Value = get_value(&result, &close);
4080            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));
4081            crate::set_value(&mut result, &close, resultClose);
4082            let mut resultVolume: Value = get_value(&result, &volume);
4083            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));
4084            crate::set_value(&mut result, &volume, resultVolume);
4085        }
4086        }
4087        return result;
4088
4089    Value::Null
4090}
4091
4092    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 {
4093        let mut startRegex = get_arg(optional_args, 0, Value::Null);
4094        let mut endRegex = get_arg(optional_args, 1, Value::Null);
4095        let mut errorMessage: Value = Value::Str("".into());
4096        let mut options: Value = self.safe_value(self.options.clone(), method, &[Value::Map({
4097            let mut m = indexmap::IndexMap::new();
4098            m
4099        })]);
4100        let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4101        {
4102            // if it was not explicitly disabled, then don't fetch
4103            if !matches!(self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)]), Value::Bool(true)) {
4104                return Value::Null;
4105            }
4106            let mut maxRetries: Value = self.safe_integer_k(options, "webApiRetries", &[Value::Int(10)]);
4107            let mut response: Value = Value::Null;
4108            let mut retry: f64 = ((0i64) as f64);
4109            let mut shouldBreak: bool = false;
4110            while retry < maxRetries.as_f64().unwrap_or(f64::NAN) {
4111                {
4112                    response = self.call_dynamic_checked(endpointMethod.clone(), vec![(Value::Map({
4113                        let mut m = indexmap::IndexMap::new();
4114                        m
4115                    })).clone()]).await;
4116                    shouldBreak = true;
4117                    break;
4118                }
4119                if shouldBreak {
4120                    break;
4121                }
4122            }
4123            let mut content: Value = response;
4124            if (content == Value::Null) {
4125                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4126            }
4127            if (startRegex != Value::Null) {
4128                let mut splitted_by_start: Value = split(&content, &startRegex);
4129                content = get_value(&splitted_by_start, &Value::Int(1)); // we need second part after start
4130            }
4131            if (content == Value::Null) {
4132                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4133            }
4134            if (endRegex != Value::Null) {
4135                let mut splitted_by_end: Value = split(&content, &endRegex);
4136                content = get_value(&splitted_by_end, &Value::Int(0)); // we need first part after start
4137            }
4138            if (is_equal(&returnAsJson, &Value::Bool(true))) && (matches!(&content, Value::Str(_))) {
4139                let mut jsoned: Value = self.parse_json_value(trim(&content)); // content should be trimmed before json parsing
4140                if (jsoned != Value::Null) && (jsoned != Value::Null) {
4141                    return jsoned;
4142                }  else {
4143                    panic!("{}", crate::exchange_errors::bad_response("could not parse the response into json"));
4144                }
4145            }  else {
4146                return content;
4147            }
4148        }
4149        if (muteOnFailure.as_bool() == Some(true)) {
4150            return Value::Null;
4151        }  else {
4152            panic!("{}", crate::exchange_errors::bad_response(errorMessage));
4153        }
4154} }
4155
4156    fn market_ids(&self, optional_args: &[Value]) -> Value {
4157        let mut symbols = get_arg(optional_args, 0, Value::Null);
4158        /*
4159         * @param {string[]|undefined} symbols list of unified symbols
4160         * @returns {string[]|undefined} list of exchange-specific market ids
4161         * Overloads: non-null `string[]` input yields `string[]`; optional input yields `Strings`.
4162         */
4163        if (symbols == Value::Null) {
4164            return symbols;
4165        }
4166        let mut result: Value = Value::from(vec![]);
4167        {
4168                        let mut i: Value = Value::Int(0);
4169            let mut __for_first_107: bool = true;
4170            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) } {
4171            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));
4172            if (id != Value::Null) {
4173                append_to_array(&mut result, id);
4174            }
4175        }
4176        }
4177        return result;
4178
4179    Value::Null
4180}
4181
4182    fn currency_ids(&self, optional_args: &[Value]) -> Value {
4183        let mut codes = get_arg(optional_args, 0, Value::Null);
4184        if (codes == Value::Null) {
4185            return codes;
4186        }
4187        let mut result: Value = Value::from(vec![]);
4188        {
4189                        let mut i: Value = Value::Int(0);
4190            let mut __for_first_108: bool = true;
4191            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) } {
4192            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));
4193            if (id != Value::Null) {
4194                append_to_array(&mut result, id);
4195            }
4196        }
4197        }
4198        return result;
4199
4200    Value::Null
4201}
4202
4203    fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4204        let mut symbols = get_arg(optional_args, 0, Value::Null);
4205        if (symbols == Value::Null) {
4206            return Value::Null;
4207        }
4208        let mut result: Value = Value::from(vec![]);
4209        {
4210                        let mut i: Value = Value::Int(0);
4211            let mut __for_first_109: bool = true;
4212            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) } {
4213            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)));
4214        }
4215        }
4216        return result;
4217
4218    Value::Null
4219}
4220
4221// allowEmpty: false always returns string[] (throws on empty/undefined at runtime)
4222    fn market_symbols(&self, optional_args: &[Value]) -> Value {
4223        let mut symbols = get_arg(optional_args, 0, Value::Null);
4224        let mut type_var = get_arg(optional_args, 1, Value::Null);
4225        let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4226        let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4227        let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4228        /*
4229         * @param {string[]|undefined} symbols list of unified symbols
4230         * @param {string|undefined} type filter by market type
4231         * @param {boolean} allowEmpty whether empty/undefined symbols is allowed
4232         * @param {boolean} sameTypeOnly require all markets to share type
4233         * @param {boolean} sameSubTypeOnly require all markets to share linear/inverse subType
4234         * @returns {string[]|undefined} validated unified symbols
4235         * Overloads: `allowEmpty: false` or non-null `string[]` input yields `string[]`; permissive form yields `Strings`.
4236         */
4237        if (symbols == Value::Null) {
4238            if !is_true(&allowEmpty) {
4239                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4240            }
4241            return symbols;
4242        }
4243        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
4244        if (symbolsLength == 0.0) {
4245            if !is_true(&allowEmpty) {
4246                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4247            }
4248            return symbols;
4249        }
4250        let mut result: Value = Value::from(vec![]);
4251        let mut marketType: Value = Value::Null;
4252        let mut isLinearSubType: Value = Value::Null;
4253        {
4254                        let mut i: Value = Value::Int(0);
4255            let mut __for_first_110: bool = true;
4256            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) } {
4257            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));
4258            if is_true(&sameTypeOnly) && (marketType != Value::Null) {
4259                if (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != marketType.as_str()) {
4260                    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()))));
4261                }
4262            }
4263            if is_true(&sameSubTypeOnly) && (isLinearSubType != Value::Null) {
4264                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() != isLinearSubType.as_bool()) {
4265                    panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same subType, either linear or inverse.".into()))));
4266                }
4267            }
4268            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()) {
4269                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()))));
4270            }
4271            marketType = self.safe_string_k(market.clone(), "type", &[]);
4272            if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
4273                isLinearSubType = self.safe_bool_k(market.clone(), "linear", &[]);
4274            }
4275            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)]);
4276            append_to_array(&mut result, symbol);
4277        }
4278        }
4279        return result;
4280
4281    Value::Null
4282}
4283
4284    fn market_codes(&self, optional_args: &[Value]) -> Value {
4285        let mut codes = get_arg(optional_args, 0, Value::Null);
4286        if (codes == Value::Null) {
4287            return codes;
4288        }
4289        let mut result: Value = Value::from(vec![]);
4290        {
4291                        let mut i: Value = Value::Int(0);
4292            let mut __for_first_111: bool = true;
4293            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) } {
4294            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)));
4295        }
4296        }
4297        return result;
4298
4299    Value::Null
4300}
4301
4302    fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4303        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4304        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4305        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4306        let mut bidasksValue: Value = self.to_array(bidasks);
4307        let mut result: Value = Value::from(vec![]);
4308        {
4309                        let mut i: Value = Value::Int(0);
4310            let mut __for_first_112: bool = true;
4311            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) } {
4312            append_to_array(&mut result, self.parse_order_book_bid_ask(get_value(&bidasksValue, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4313        }
4314        }
4315        return result;
4316
4317    Value::Null
4318}
4319
4320    fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4321        let mut value = get_arg(optional_args, 0, Value::Null);
4322        if (value == Value::Null) {
4323            return objects;
4324        }
4325        let mut result: Value = Value::from(vec![]);
4326        {
4327                        let mut i: Value = Value::Int(0);
4328            let mut __for_first_113: bool = true;
4329            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) } {
4330            let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
4331            if (objectValue.as_str() == value.as_str()) {
4332                append_to_array(&mut result, get_value(&objects, &i));
4333            }
4334        }
4335        }
4336        return result;
4337
4338    Value::Null
4339}
4340
4341    fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4342        let mut symbol = get_arg(optional_args, 0, Value::Null);
4343        return self.filter_by_key(objects, Value::Str("symbol".into()), &[symbol]);
4344
4345    Value::Null
4346}
4347
4348    fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4349        // virtual-dispatch (static: DerivedExchange::parse_ohlcv(self, ...))
4350        { 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; } }
4351
4352        let mut market = get_arg(optional_args, 0, Value::Null);
4353        if (matches!(&ohlcv, Value::Arr(_))) {
4354            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), &[])]);
4355        }
4356        return ohlcv;
4357
4358    Value::Null
4359}
4360
4361    fn safe_network(&self, mut network: Value) -> Value {
4362        let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
4363        let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
4364        let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
4365        let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4366        let mut deposit: Value = self.safe_dict_k(limits, "deposit", &[]);
4367        let mut isEnabled: Value = withdrawEnabled.clone();
4368        if (withdrawEnabled.as_bool() == Some(true)) {
4369            isEnabled = depositEnabled.clone();
4370        }
4371        return Value::Map({
4372    let mut m = indexmap::IndexMap::new();
4373        m.insert("info".to_string(), crate::value::get_value_k(&network, "info"));
4374        m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
4375        m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
4376        m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
4377        m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled]));
4378        m.insert("deposit".to_string(), depositEnabled);
4379        m.insert("withdraw".to_string(), withdrawEnabled);
4380        m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
4381        m.insert("precision".to_string(), self.safe_number_k(network, "precision", &[]));
4382        m.insert("limits".to_string(), Value::Map({
4383    let mut m = indexmap::IndexMap::new();
4384        m.insert("withdraw".to_string(), Value::Map({
4385    let mut m = indexmap::IndexMap::new();
4386        m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4387        m.insert("max".to_string(), self.safe_number_k(withdraw, "max", &[]));
4388    m
4389}));
4390        m.insert("deposit".to_string(), Value::Map({
4391    let mut m = indexmap::IndexMap::new();
4392        m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4393        m.insert("max".to_string(), self.safe_number_k(deposit, "max", &[]));
4394    m
4395}));
4396    m
4397}));
4398    m
4399});
4400
4401    Value::Null
4402}
4403
4404    fn prioritized_network_aliases(&self, optional_args: &[Value]) -> Value {
4405        let mut networkCode = get_arg(optional_args, 0, Value::Null);
4406        let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4407        let mut allowDefault = get_arg(optional_args, 2, Value::Bool(false));
4408        /*
4409         * @method
4410         * @name Exchange#prioritizedNetworkAliases
4411         * @description returns the chain pair [preferred, alternative] for the given networkCode & currency, e.g:
4412         *   ---------------------------------
4413         *   | input          | output       |
4414         *   --------------------------------|
4415         *   | ETH & USDC     | ERC20, ETH   |
4416         *   | ERC20 & USDC   | ERC20, ETH   |
4417         *   | ETH & ETH      | ETH, ERC20   |
4418         *   | ERC20 & ETH    | ETH, ERC20   |
4419         *   | ERC20          | ERC20, ETH   |
4420         *   | ETH            | ERC20, ETH   |
4421         *   ---------------------------------
4422         * @param {string} networkCode unified network-code
4423         * @param {string} currencyCode unified currency-code
4424         * @param {boolean} allowDefault when currencyCode is undefined, order by replacement's "default" instead of by user input
4425         * @returns {string[]} [preferredChain, alternativeChain]
4426         */
4427        if (networkCode == Value::Null) {
4428            return Value::Null;
4429        }
4430        let mut replacements: Value = self.safe_dict_k(self.options.clone(), "defaultNetworkCodeReplacements", &[Value::Map({
4431    let mut m = indexmap::IndexMap::new();
4432    m
4433})]);
4434        let mut keys: Value = object_keys(&replacements);
4435        {
4436                        let mut i: Value = Value::Int(0);
4437            let mut __for_first_114: bool = true;
4438            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) } {
4439            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);
4440            let mut entry: Value = replacements.as_map().and_then(|__m| baseCoin.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4441            let mut primary: Value = crate::value::get_value_k(&entry, "primary");
4442            let mut secondary: Value = crate::value::get_value_k(&entry, "secondary");
4443            if !is_equal(&networkCode, &primary) && !is_equal(&networkCode, &secondary) {
4444                continue;
4445            }
4446            // pick which form goes first in the returned pair
4447            let mut preferPrimary: bool = false;
4448            if (currencyCode.as_str() == baseCoin.as_str()) {
4449                preferPrimary = true; // mainnet currency uses primary chain
4450            }  else if (currencyCode != Value::Null) {
4451                preferPrimary = false; // any other (token) currency uses secondary chain
4452            }  else if is_true(&allowDefault) {
4453                preferPrimary = crate::value::get_value_k(&entry, "default").as_str() == Some("primary");
4454            }  else {
4455                preferPrimary = is_equal(&networkCode, &primary); // keep user input first
4456            }
4457            return (if (preferPrimary) { Value::from(vec![primary.clone(), secondary.clone()]) } else { Value::from(vec![secondary, primary]) });
4458        }
4459        }
4460        return Value::from(vec![networkCode.clone(), networkCode.clone()]);
4461
4462    Value::Null
4463}
4464
4465    fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4466        let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4467        /*
4468         * @ignore
4469         * @method
4470         * @name exchange#networkCodeToId
4471         * @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.
4472         * @param {string} networkCode unified network code
4473         * @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
4474         * @returns {string|undefined} exchange-specific network id
4475         */
4476        if (networkCode == Value::Null) {
4477            return Value::Null;
4478        }
4479        let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4480    let mut m = indexmap::IndexMap::new();
4481    m
4482})]);
4483        // try the preferred form first, fall back to its alternative (e.g. when only 'ETH' or only 'ERC20' is defined)
4484        let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(false)]);
4485        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) });
4486        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) });
4487        let mut networkId: Value = self.safe_string2(networkIdsByCodes, preferredChain, alternativeChain, &[]);
4488        if (networkId != Value::Null) {
4489            return networkId;
4490        }
4491        // fall back to scanning loaded currencies
4492        let mut currenciesToCheck: Value = Value::from(vec![]);
4493        if (currencyCode == Value::Null) {
4494            currenciesToCheck = object_keys(&self.currencies);
4495        }  else {
4496            currenciesToCheck = Value::from(vec![self.safe_dict(self.currencies.clone(), currencyCode.clone(), &[])]);
4497        }
4498        {
4499                        let mut i: Value = Value::Int(0);
4500            let mut __for_first_115: bool = true;
4501            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) } {
4502            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({
4503    let mut m = indexmap::IndexMap::new();
4504    m
4505})]);
4506            if (in_op(&networks, &networkCode)) {
4507                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()), &[]);
4508            }
4509        }
4510        }
4511        // before returning the original input, try to match if it's backward-maintained networkCode
4512        let mut oldCodes: Value = self.safe_dict_k(self.options.clone(), "backwardSupportedNetworkCodes", &[Value::Map({
4513    let mut m = indexmap::IndexMap::new();
4514    m
4515})]);
4516        if (in_op(&oldCodes, &networkCode)) {
4517            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]);
4518        }
4519        return networkCode;
4520
4521    Value::Null
4522}
4523
4524    fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4525        let mut networkId = get_arg(optional_args, 0, Value::Null);
4526        let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4527        /*
4528         * @ignore
4529         * @method
4530         * @name exchange#networkIdToCode
4531         * @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.
4532         * @param {string} networkId exchange specific network id/title, like: TRON, Trc-20, usdt-erc20, etc
4533         * @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
4534         * @returns {string|undefined} unified network code
4535         */
4536        if (networkId == Value::Null) {
4537            return Value::Null;
4538        }
4539        let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4540    let mut m = indexmap::IndexMap::new();
4541    m
4542})]);
4543        let mut networkCode: Value = self.safe_string(networkCodesByIds, networkId.clone(), &[networkId.clone()]);
4544        let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(true)]);
4545        if (chainPair == Value::Null) {
4546            return networkCode;
4547        }
4548        let mut preferredChain: Value = chainPair.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
4549        let mut alternativeChain: Value = chainPair.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
4550        // when the exchange explicitly defines both forms in options.networks (e.g. BTC + BRC20),
4551        // it disambiguates them — trust the direct id→code inversion instead of guessing
4552        if (currencyCode == Value::Null) {
4553            let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4554    let mut m = indexmap::IndexMap::new();
4555    m
4556})]);
4557            if (in_op(&networkIdsByCodes, &preferredChain)) && (in_op(&networkIdsByCodes, &alternativeChain)) {
4558                return networkCode;
4559            }
4560        }
4561        return preferredChain;
4562
4563    Value::Null
4564}
4565
4566    fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4567        let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".into()), Value::Str("network".into()), &[]);
4568        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 });
4569        return Value::from(vec![networkCodeInParams, paramsOmitted]);
4570
4571    Value::Null
4572}
4573
4574    fn default_network_code(&self, mut currencyCode: Value) -> Value {
4575        let mut defaultNetworkCode: Value = Value::Null;
4576        let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4577    let mut m = indexmap::IndexMap::new();
4578    m
4579})]);
4580        if (in_op(&defaultNetworks, &currencyCode)) {
4581            // if currency had set its network in "defaultNetworks", use it
4582            defaultNetworkCode = defaultNetworks.as_map().and_then(|__m| currencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4583        }  else {
4584            // 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)
4585            let mut defaultNetwork: Value = self.safe_string_k(self.options.clone(), "defaultNetwork", &[]);
4586            if (defaultNetwork != Value::Null) {
4587                defaultNetworkCode = defaultNetwork;
4588            }
4589        }
4590        return defaultNetworkCode;
4591
4592    Value::Null
4593}
4594
4595    fn select_network_code_from_unified_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4596        return self.select_network_key_from_networks(currencyCode, networkCode, indexedNetworkEntries, &[Value::Bool(true)]);
4597
4598    Value::Null
4599}
4600
4601    fn select_network_id_from_raw_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4602        return self.select_network_key_from_networks(currencyCode, networkCode, indexedNetworkEntries, &[Value::Bool(false)]);
4603
4604    Value::Null
4605}
4606
4607    fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4608        let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4609        // this method is used against raw & unparse network entries, which are just indexed by network id
4610        let mut chosenNetworkId: Value = Value::Null;
4611        let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4612        let mut responseNetworksLength: f64 = ((availableNetworkIds.len() as i64) as f64);
4613        if (networkCode != Value::Null) {
4614            if (responseNetworksLength == 0.0) {
4615                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)));
4616            }  else {
4617                // if networkCode was provided by user, we should check it after response, as the referenced exchange doesn't support network-code during request
4618                let mut networkIdOrCode: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { networkCode.clone() } else { self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]) });
4619                if (networkIdOrCode == Value::Null) {
4620                    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)));
4621                }
4622                if (in_op(&indexedNetworkEntries, &networkIdOrCode)) {
4623                    chosenNetworkId = networkIdOrCode.clone();
4624                }  else {
4625                    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())))));
4626                }
4627            }
4628        }  else {
4629            if (responseNetworksLength == 0.0) {
4630                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - no networks were returned for ".into())).into()), currencyCode)));
4631            }  else {
4632                // 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
4633                let mut defaultNetworkCode: Value = self.default_network_code(currencyCode.clone());
4634                let mut defaultNetworkId: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { defaultNetworkCode.clone() } else { self.network_code_to_id(defaultNetworkCode, &[currencyCode]) });
4635                if (defaultNetworkId == Value::Null) {
4636                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".into()))));
4637                }
4638                if (in_op(&indexedNetworkEntries, &defaultNetworkId)) {
4639                    return defaultNetworkId;
4640                }
4641                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())))));
4642            }
4643        }
4644        return chosenNetworkId;
4645
4646    Value::Null
4647}
4648
4649    fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4650        let mut d = get_arg(optional_args, 0, Value::Null);
4651        let mut value: Value = self.safe_string2(dictionary, key1, key2, &[]);
4652        return self.parse_number(value, &[d]);
4653
4654    Value::Null
4655}
4656
4657    fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4658        // virtual-dispatch (static: DerivedExchange::parse_order_book(self, ...))
4659        { 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; } }
4660
4661        let mut timestamp = get_arg(optional_args, 0, Value::Null);
4662        let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4663        let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4664        let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4665        let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4666        let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4667        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()]);
4668        let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4669        return Value::Map({
4670    let mut m = indexmap::IndexMap::new();
4671        m.insert("symbol".to_string(), symbol);
4672        m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4673        m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4674        m.insert("timestamp".to_string(), timestamp.clone());
4675        m.insert("datetime".to_string(), self.iso8601(timestamp));
4676        m.insert("nonce".to_string(), Value::Null);
4677    m
4678});
4679
4680    Value::Null
4681}
4682
4683    fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4684        let mut market = get_arg(optional_args, 0, Value::Null);
4685        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
4686        let mut since = get_arg(optional_args, 2, Value::Null);
4687        let mut limit = get_arg(optional_args, 3, Value::Null);
4688        let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4689        if (ohlcvs == Value::Null) {
4690            return Value::from(vec![]);
4691        }
4692        let mut results: Value = Value::from(vec![]);
4693        {
4694                        let mut i: Value = Value::Int(0);
4695            let mut __for_first_116: bool = true;
4696            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) } {
4697            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()]));
4698        }
4699        }
4700        let mut sorted: Value = self.sort_by(results, Value::Int(0), &[]);
4701        return self.filter_by_since_limit(sorted, &[since, limit, Value::Int(0), tail]);
4702
4703    Value::Null
4704}
4705
4706    fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4707        let mut symbols = get_arg(optional_args, 0, Value::Null);
4708        let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4709        // marketIdKey should only be undefined when response is a dictionary.
4710        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4711        let mut tiers: Value = Value::Map({
4712            let mut m = indexmap::IndexMap::new();
4713            m
4714        });
4715        let mut symbolsLength: Value = Value::Int(0);
4716        if (symbolsNormalized != Value::Null) {
4717            symbolsLength = Value::Int(symbolsNormalized.len() as i64);
4718        }
4719        let mut noSymbols: bool = (symbolsNormalized == Value::Null) || (symbolsLength.as_f64() == Some(0.0));
4720        if (matches!(&response, Value::Arr(_))) {
4721            {
4722                                let mut i: Value = Value::Int(0);
4723                let mut __for_first_117: bool = true;
4724                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) } {
4725                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);
4726                let mut id: Value = (if (marketIdKey == Value::Null) { Value::Null } else { self.safe_string(item.clone(), marketIdKey.clone(), &[]) });
4727                let mut market: Value = self.safe_market(&[id, Value::Null, Value::Null, Value::Str("swap".into())]);
4728                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4729                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4730                if (contract.as_bool() == Some(true)) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4731                    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()])); }
4732                }
4733            }
4734            }
4735        }  else {
4736            let mut keys: Value = object_keys(&response);
4737            {
4738                                let mut i: Value = Value::Int(0);
4739                let mut __for_first_118: bool = true;
4740                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) } {
4741                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);
4742                let mut item: Value = get_value(&response, &marketId);
4743                let mut item: Value = get_value(&response, &marketId);
4744                let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("swap".into())]);
4745                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4746                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4747                if (contract.as_bool() == Some(true)) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4748                    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])); }
4749                }
4750            }
4751            }
4752        }
4753        return tiers;
4754
4755    Value::Null
4756}
4757
4758    fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4759        let mut symbols = get_arg(optional_args, 0, Value::Null);
4760        let mut reload = get_arg(optional_args, 1, Value::Bool(false));
4761        let mut params = get_arg(optional_args, 2, Value::Map({
4762    let mut m = indexmap::IndexMap::new();
4763    m
4764}));
4765        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)) {
4766            if is_true(&reload) || !(matches!(&self.options, Value::Dict(__d) if __d.contains_key("limitsLoaded"))) {
4767                let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4768                let mut symbolsArray: Value = self.require_value(symbols, &[Value::Str("loadTradingLimits() requires a symbols argument".into())]);
4769                let mut markets: Value = self.markets.clone();
4770                if (markets == Value::Null) {
4771                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
4772                }
4773                {
4774                                        let mut i: Value = Value::Int(0);
4775                    let mut __for_first_119: bool = true;
4776                    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) } {
4777                    let mut symbol: Value = get_value(&symbolsArray, &i);
4778                    let mut symbol: Value = get_value(&symbolsArray, &i);
4779                    { let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
4780                }
4781                }
4782                { let __be_tmp = self.milliseconds(); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("limitsLoaded".into(), __be_tmp); } }
4783            }
4784        }
4785        return self.markets.clone();
4786
4787    Value::Null
4788} }
4789
4790    fn safe_position(&self, mut position: Value) -> Value {
4791        // simplified version of: /pull/12765/
4792        let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
4793        let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
4794        //
4795        // PERCENTAGE
4796        //
4797        let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
4798        if (percentage == Value::Null) && (unrealizedPnlString != Value::Null) && (initialMarginString != Value::Null) {
4799            // as it was done in all implementations ( aax, btcex, bybit, deribit, gate, kucoinfutures, phemex )
4800            let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".into()));
4801            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("percentage".into(), self.parse_number(percentageString, &[])); }
4802        }
4803        // if contractSize is undefined get from market
4804        let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
4805        let mut symbol: Value = self.safe_string_k(position.clone(), "symbol", &[]);
4806        let mut market: Value = Value::Null;
4807        if (symbol != Value::Null) {
4808            market = self.safe_value(self.markets.clone(), symbol, &[]);
4809        }
4810        if (contractSize == Value::Null) && (market != Value::Null) {
4811            contractSize = self.safe_number_k(market, "contractSize", &[]);
4812            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), contractSize); }
4813        }
4814        return position;
4815
4816    Value::Null
4817}
4818
4819    fn parse_positions(&self, mut positions: Value, optional_args: &[Value]) -> Value {
4820        let mut symbols = get_arg(optional_args, 0, Value::Null);
4821        let mut params = get_arg(optional_args, 1, Value::Map({
4822    let mut m = indexmap::IndexMap::new();
4823    m
4824}));
4825        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4826        let mut positionsArray: Value = self.to_array(positions);
4827        let mut result: Value = Value::from(vec![]);
4828        {
4829                        let mut i: Value = Value::Int(0);
4830            let mut __for_first_120: bool = true;
4831            while { if !__for_first_120 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_120 = false; i.as_f64().unwrap_or(f64::NAN) < ((positionsArray.len() as i64) as f64) } {
4832            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()]);
4833            append_to_array(&mut result, position);
4834        }
4835        }
4836        return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbolsNormalized]);
4837
4838    Value::Null
4839}
4840
4841    fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
4842        // virtual-dispatch (static: DerivedExchange::parse_adl_rank(self, ...))
4843        { 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; } }
4844
4845        let mut market = get_arg(optional_args, 0, Value::Null);
4846        if (info == Value::Null) {
4847            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
4848        }
4849        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
4850
4851    Value::Null
4852}
4853
4854    fn parse_adl_ranks(&self, mut ranks: Value, optional_args: &[Value]) -> Value {
4855        let mut symbols = get_arg(optional_args, 0, Value::Null);
4856        let mut params = get_arg(optional_args, 1, Value::Map({
4857    let mut m = indexmap::IndexMap::new();
4858    m
4859}));
4860        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4861        let mut ranksArray: Value = self.to_array(ranks);
4862        let mut result: Value = Value::from(vec![]);
4863        {
4864                        let mut i: Value = Value::Int(0);
4865            let mut __for_first_121: bool = true;
4866            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) } {
4867            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()]);
4868            append_to_array(&mut result, rank);
4869        }
4870        }
4871        return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbolsNormalized]);
4872
4873    Value::Null
4874}
4875
4876    fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
4877        let mut params = get_arg(optional_args, 0, Value::Map({
4878    let mut m = indexmap::IndexMap::new();
4879    m
4880}));
4881        let mut accountsArray: Value = self.to_array(accounts);
4882        let mut result: Value = Value::from(vec![]);
4883        {
4884                        let mut i: Value = Value::Int(0);
4885            let mut __for_first_122: bool = true;
4886            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) } {
4887            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()]);
4888            append_to_array(&mut result, account);
4889        }
4890        }
4891        return result;
4892
4893    Value::Null
4894}
4895
4896    fn parse_trades_helper(&self, mut isWs: Value, mut trades: Value, optional_args: &[Value]) -> Value {
4897        let mut market = get_arg(optional_args, 0, Value::Null);
4898        let mut since = get_arg(optional_args, 1, Value::Null);
4899        let mut limit = get_arg(optional_args, 2, Value::Null);
4900        let mut params = get_arg(optional_args, 3, Value::Map({
4901    let mut m = indexmap::IndexMap::new();
4902    m
4903}));
4904        let mut tradesArray: Value = self.to_array(trades);
4905        let mut result: Value = Value::from(vec![]);
4906        {
4907                        let mut i: Value = Value::Int(0);
4908            let mut __for_first_123: bool = true;
4909            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) } {
4910            let mut parsed: Value = Value::Null;
4911            if is_true(&isWs) {
4912                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()]);
4913            }  else {
4914                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()]);
4915            }
4916            let mut trade: Value = self.extend(parsed, &[params.clone()]);
4917            append_to_array(&mut result, trade);
4918        }
4919        }
4920        result = self.sort_by2(result.clone(), Value::Str("timestamp".into()), Value::Str("id".into()), &[]);
4921        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
4922        return self.filter_by_symbol_since_limit(result, &[symbol, since, limit]);
4923
4924    Value::Null
4925}
4926
4927    fn parse_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4928        let mut market = get_arg(optional_args, 0, Value::Null);
4929        let mut since = get_arg(optional_args, 1, Value::Null);
4930        let mut limit = get_arg(optional_args, 2, Value::Null);
4931        let mut params = get_arg(optional_args, 3, Value::Map({
4932    let mut m = indexmap::IndexMap::new();
4933    m
4934}));
4935        return self.parse_trades_helper(Value::Bool(false), trades, &[market, since, limit, params]);
4936
4937    Value::Null
4938}
4939
4940    fn parse_ws_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4941        let mut market = get_arg(optional_args, 0, Value::Null);
4942        let mut since = get_arg(optional_args, 1, Value::Null);
4943        let mut limit = get_arg(optional_args, 2, Value::Null);
4944        let mut params = get_arg(optional_args, 3, Value::Map({
4945    let mut m = indexmap::IndexMap::new();
4946    m
4947}));
4948        return self.parse_trades_helper(Value::Bool(true), trades, &[market, since, limit, params]);
4949
4950    Value::Null
4951}
4952
4953    fn parse_transactions(&self, mut transactions: Value, optional_args: &[Value]) -> Value {
4954        let mut currency = get_arg(optional_args, 0, Value::Null);
4955        let mut since = get_arg(optional_args, 1, Value::Null);
4956        let mut limit = get_arg(optional_args, 2, Value::Null);
4957        let mut params = get_arg(optional_args, 3, Value::Map({
4958    let mut m = indexmap::IndexMap::new();
4959    m
4960}));
4961        let mut transactionsArray: Value = self.to_array(transactions);
4962        let mut result: Value = Value::from(vec![]);
4963        {
4964                        let mut i: Value = Value::Int(0);
4965            let mut __for_first_124: bool = true;
4966            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) } {
4967            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()]);
4968            append_to_array(&mut result, transaction);
4969        }
4970        }
4971        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
4972        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 });
4973        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
4974
4975    Value::Null
4976}
4977
4978    fn parse_transfers(&self, mut transfers: Value, optional_args: &[Value]) -> Value {
4979        let mut currency = get_arg(optional_args, 0, Value::Null);
4980        let mut since = get_arg(optional_args, 1, Value::Null);
4981        let mut limit = get_arg(optional_args, 2, Value::Null);
4982        let mut params = get_arg(optional_args, 3, Value::Map({
4983    let mut m = indexmap::IndexMap::new();
4984    m
4985}));
4986        let mut transfersArray: Value = self.to_array(transfers);
4987        let mut result: Value = Value::from(vec![]);
4988        {
4989                        let mut i: Value = Value::Int(0);
4990            let mut __for_first_125: bool = true;
4991            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) } {
4992            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()]);
4993            append_to_array(&mut result, transfer);
4994        }
4995        }
4996        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
4997        let mut code: Value = (if (currency != Value::Null) { currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null) } else { Value::Null });
4998        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
4999
5000    Value::Null
5001}
5002
5003    fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
5004        let mut currency = get_arg(optional_args, 0, Value::Null);
5005        let mut since = get_arg(optional_args, 1, Value::Null);
5006        let mut limit = get_arg(optional_args, 2, Value::Null);
5007        let mut params = get_arg(optional_args, 3, Value::Map({
5008    let mut m = indexmap::IndexMap::new();
5009    m
5010}));
5011        let mut result: Value = Value::from(vec![]);
5012        let mut arrayData: Value = self.to_array(data);
5013        {
5014                        let mut i: Value = Value::Int(0);
5015            let mut __for_first_127: bool = true;
5016            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) } {
5017            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()]);
5018            if (matches!(&itemOrItems, Value::Arr(_))) {
5019                {
5020                                        let mut j: Value = Value::Int(0);
5021                    let mut __for_first_126: bool = true;
5022                    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) } {
5023                    append_to_array(&mut result, self.extend(get_value(&itemOrItems, &j), &[params.clone()]));
5024                }
5025                }
5026            }  else {
5027                append_to_array(&mut result, self.extend(itemOrItems, &[params.clone()]));
5028            }
5029        }
5030        }
5031        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5032        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 });
5033        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5034
5035    Value::Null
5036}
5037
5038    fn nonce(&self) -> Value {
5039        // virtual-dispatch (static: DerivedExchange::nonce(self, ...))
5040        { let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
5041
5042        return self.seconds();
5043
5044    Value::Null
5045}
5046
5047/*
5048 * @method
5049 * @ignore
5050 * @name Exchange#incrementingNonce
5051 * @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.
5052 * @returns {int} a strictly-increasing nonce in the unit returned by nonce ()
5053 */
5054    fn incrementing_nonce(&mut self) -> Value {
5055        let mut currentNonce: Value = <Self as crate::exchange_generated::ExchangeBase>::nonce(self, );
5056        self.lock_last_nonce(&[]);
5057        let mut lastNonce: Value = self.safe_integer_k(self.options.clone(), "lastNonce", &[Value::Int(0)]);
5058        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 }) });
5059        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("lastNonce".into(), result.clone()); }
5060        self.unlock_last_nonce(&[]);
5061        return result;
5062
5063    Value::Null
5064}
5065
5066    fn set_headers(&self, mut headers: Value) -> Value {
5067        return headers;
5068
5069    Value::Null
5070}
5071
5072    fn currency_id(&self, mut code: Value) -> Value {
5073        if (code == Value::Null) {
5074            return code;
5075        }
5076        let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5077        if (currency == Value::Null) {
5078            currency = self.safe_currency(code.clone(), &[]);
5079        }
5080        if (currency != Value::Null) {
5081            return currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5082        }
5083        return code;
5084
5085    Value::Null
5086}
5087
5088    fn market_id(&self, mut symbol: Value) -> Value {
5089        let mut market: Value = self.market(symbol.clone());
5090        if (market != Value::Null) {
5091            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5092        }
5093        return symbol;
5094
5095    Value::Null
5096}
5097
5098    fn symbol(&self, mut symbol: Value) -> Value {
5099        if (symbol == Value::Null) {
5100            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" symbol() requires a symbol argument".into()))));
5101        }
5102        let mut market: Value = self.market(symbol.clone());
5103        return self.safe_string_k(market, "symbol", &[symbol]);
5104
5105    Value::Null
5106}
5107
5108/* eslint-disable no-unused-vars */
5109/* eslint-enable no-unused-vars */
5110    fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5111        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5112        let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue]);
5113        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5114        return Value::from(vec![value, paramsOmitted]);
5115
5116    Value::Null
5117}
5118
5119/* eslint-disable no-unused-vars */
5120/* eslint-enable no-unused-vars */
5121    fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5122        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5123        let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5124        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5125        return Value::from(vec![value, paramsOmitted]);
5126
5127    Value::Null
5128}
5129
5130    fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5131        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5132        let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue]);
5133        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5134        return Value::from(vec![value, paramsOmitted]);
5135
5136    Value::Null
5137}
5138
5139    fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5140        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5141        let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5142        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5143        return Value::from(vec![value, paramsOmitted]);
5144
5145    Value::Null
5146}
5147
5148    fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5149        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5150        let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue]);
5151        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5152        return Value::from(vec![value, paramsOmitted]);
5153
5154    Value::Null
5155}
5156
5157    fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5158        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5159        let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5160        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5161        return Value::from(vec![value, paramsOmitted]);
5162
5163    Value::Null
5164}
5165
5166/*
5167 * @param {object} params - extra parameters
5168 * @param {object} request - existing dictionary of request
5169 * @param {string} exchangeSpecificKey - the key for chain id to be set in request
5170 * @param {object} currencyCode - (optional) existing dictionary of request
5171 * @param {boolean} isRequired - (optional) whether that param is required to be present
5172 * @returns {object[]} - returns [request, params] where request is the modified request object and params is the modified params object
5173 */
5174    fn handle_request_network(&self, mut params: Value, mut request: Value, mut exchangeSpecificKey: Value, optional_args: &[Value]) -> Value {
5175        let mut currencyCode = get_arg(optional_args, 0, Value::Null);
5176        let mut isRequired = get_arg(optional_args, 1, Value::Bool(false));
5177        let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(params);
5178        let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5179        let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5180        if (networkCode != Value::Null) {
5181            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])); }
5182        }  else if is_true(&isRequired) {
5183            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" - \"network\" param is required for this request".into()))));
5184        }
5185        return Value::from(vec![request, paramsNetworkCode]);
5186
5187    Value::Null
5188}
5189
5190    fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5191        return Value::from(vec![self.implode_params(path.clone(), params.clone()), self.omit(params, self.extract_params(path), &[])]);
5192
5193    Value::Null
5194}
5195
5196    fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5197        let mut newArray: Value = objects.clone();
5198        if !(matches!(&objects, Value::Arr(_))) {
5199            newArray = self.to_array(objects.clone());
5200        }
5201        let mut results: Value = Value::from(vec![]);
5202        {
5203                        let mut i: Value = Value::Int(0);
5204            let mut __for_first_128: bool = true;
5205            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) } {
5206            append_to_array(&mut results, get_value(&get_value(&newArray, &i), &key));
5207        }
5208        }
5209        return results;
5210
5211    Value::Null
5212}
5213
5214    fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5215        let mut marketType = get_arg(optional_args, 0, Value::Null);
5216        let mut subType = get_arg(optional_args, 1, Value::Null);
5217        let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5218        let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5219        let mut filteredMarkets: Value = self.markets.clone();
5220        if (marketType != Value::Null) {
5221            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".into()), marketType, &[]);
5222        }
5223        if (subType != Value::Null) {
5224            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())])]);
5225            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".into()), subType, &[]);
5226        }
5227        let mut activeStatuses: Value = Value::from(vec![]);
5228        if is_true(&symbolWithActiveStatus) {
5229            append_to_array(&mut activeStatuses, Value::Bool(true));
5230        }
5231        if is_true(&symbolWithUnknownStatus) {
5232            append_to_array(&mut activeStatuses, Value::Null);
5233        }
5234        filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".into()), &[activeStatuses, Value::Bool(false)]);
5235        return self.get_list_from_object_values(filteredMarkets, Value::Str("symbol".into()));
5236
5237    Value::Null
5238}
5239
5240    fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5241        let mut values = get_arg(optional_args, 0, Value::Null);
5242        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5243        let mut objectsValue: Value = self.to_array(objects);
5244        // return all of them if no values were passed
5245        if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5246            // return indexed ? this.indexBy (objects, key) : objects;
5247            if is_true(&indexed) {
5248                return self.index_by(objectsValue.clone(), key.clone());
5249            }  else {
5250                return objectsValue;
5251            }
5252        }
5253        let mut results: Value = Value::from(vec![]);
5254        {
5255                        let mut i: Value = Value::Int(0);
5256            let mut __for_first_129: bool = true;
5257            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) } {
5258            if self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true) {
5259                append_to_array(&mut results, get_value(&objectsValue, &i));
5260            }
5261        }
5262        }
5263        // return indexed ? this.indexBy (results, key) : results;
5264        if is_true(&indexed) {
5265            return self.index_by(results.clone(), key);
5266        }
5267        return results;
5268
5269    Value::Null
5270}
5271
5272    fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5273        let mut values = get_arg(optional_args, 0, Value::Null);
5274        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5275        let mut objectsValue: Value = self.to_array(objects);
5276        // return all of them if no values were passed
5277        if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5278            // return indexed ? this.indexBy (objects, key) : objects;
5279            if is_true(&indexed) {
5280                return self.index_by(objectsValue.clone(), key.clone());
5281            }  else {
5282                return objectsValue;
5283            }
5284        }
5285        let mut results: Value = Value::from(vec![]);
5286        {
5287                        let mut i: Value = Value::Int(0);
5288            let mut __for_first_130: bool = true;
5289            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) } {
5290            if !(self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true)) {
5291                append_to_array(&mut results, get_value(&objectsValue, &i));
5292            }
5293        }
5294        }
5295        // return indexed ? this.indexBy (results, key) : results;
5296        if is_true(&indexed) {
5297            return self.index_by(results.clone(), key);
5298        }
5299        return results;
5300
5301    Value::Null
5302}
5303
5304    fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5305        let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
5306        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5307        let mut params = get_arg(optional_args, 2, Value::Map({
5308    let mut m = indexmap::IndexMap::new();
5309    m
5310}));
5311        let mut headers = get_arg(optional_args, 3, Value::Null);
5312        let mut body = get_arg(optional_args, 4, Value::Null);
5313        let mut config = get_arg(optional_args, 5, Value::Map({
5314    let mut m = indexmap::IndexMap::new();
5315    m
5316}));
5317        if is_true(&self.enableRateLimit) {
5318            let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config]);
5319            self.throttle(&[cost]).await;
5320        }
5321        let mut retries: Value = Value::Int(0);
5322        // implicit endpoints may pass a list body as params: keep it an untyped box
5323        let mut requestParams: Value = params;
5324        let mut retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable = self.handle_option_integer_and_params(requestParams, path.clone(), Value::Str("maxRetriesOnFailure".into()), &[retries]);
5325        let mut retriesMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5326        let mut paramsMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5327        let mut retryDelay: Value = Value::Int(0);
5328        let mut retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable = self.handle_option_integer_and_params(paramsMaxRetriesOnFailure, path.clone(), Value::Str("maxRetriesOnFailureDelay".into()), &[retryDelay]);
5329        let mut retryDelayMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5330        let mut paramsMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5331        let mut fetchDataCacheEnabled: bool = self.fetchHistoryCacheSize.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64);
5332        {
5333                        let mut i: Value = Value::Int(0);
5334            let mut __for_first_131: bool = true;
5335            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) } {
5336            let mut fetchData: Value = Value::Null;
5337            if fetchDataCacheEnabled {
5338                fetchData = Value::Map({
5339                    let mut m = indexmap::IndexMap::new();
5340                        m.insert("request".to_string(), Value::Null);
5341                        m.insert("response".to_string(), Value::Map({
5342    let mut m = indexmap::IndexMap::new();
5343        m.insert("body".to_string(), Value::Null);
5344    m
5345}));
5346                        m.insert("error".to_string(), Value::Null);
5347                    m
5348                });
5349            }
5350            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5351                self.set_last_rest_request_timestamp();
5352                let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), paramsMaxRetriesOnFailureDelay.clone(), headers.clone(), body.clone()]);
5353                if (fetchData != Value::Null) {
5354                    add_element_to_object(&mut fetchData, &Value::Str("request".into()), request.clone());
5355                }
5356                self.set_last_request(request.clone());
5357                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;
5358                if (fetchData != Value::Null) {
5359                    add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".into())), &Value::Str("body".into()), response.clone());
5360                    self.add_fetch_cache(fetchData.clone());
5361                }
5362                return response;
5363             #[allow(unreachable_code)] { Value::Null }})).await;
5364match _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); 
5365                if (fetchData != Value::Null) {
5366                    add_element_to_object(&mut fetchData, &Value::Str("error".into()), e.clone());
5367                    self.add_fetch_cache(fetchData);
5368                }
5369                if is_instance(&e, &Value::Str("OperationFailed".into())) {
5370                    if i.as_f64().unwrap_or(f64::NAN) < retriesMaxRetriesOnFailure.as_f64().unwrap_or(f64::NAN) {
5371                        if is_true(&self.verbose) {
5372                            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 });
5373                            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()));
5374                        }
5375                        if (retryDelayMaxRetriesOnFailureDelay != Value::Null) && (retryDelayMaxRetriesOnFailureDelay.as_f64() != Some(0.0)) {
5376                            self.sleep(retryDelayMaxRetriesOnFailureDelay.clone()).await;
5377                        }
5378                    }  else {
5379                        panic!("{}", e);
5380                    }
5381                }  else {
5382                    panic!("{}", e);
5383                }
5384             } }
5385        }
5386        }
5387        return Value::Null;
5388
5389    Value::Null
5390} }
5391
5392    fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5393        let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
5394        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5395        let mut params = get_arg(optional_args, 2, Value::Map({
5396    let mut m = indexmap::IndexMap::new();
5397    m
5398}));
5399        let mut headers = get_arg(optional_args, 3, Value::Null);
5400        let mut body = get_arg(optional_args, 4, Value::Null);
5401        let mut config = get_arg(optional_args, 5, Value::Map({
5402    let mut m = indexmap::IndexMap::new();
5403    m
5404}));
5405        return self.fetch2(path, &[api, method, params, headers, body, config]).await;
5406
5407    Value::Null
5408} }
5409
5410    fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5411        let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5412        let mut params = get_arg(optional_args, 1, Value::Map({
5413    let mut m = indexmap::IndexMap::new();
5414    m
5415}));
5416        if is_true(&reload) {
5417            { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5418        }  else {
5419            if (self.accounts.clone() != Value::Null) {
5420                return self.accounts.clone();
5421            }  else {
5422                { let __t = self.fetch_accounts(&[params]).await; self.accounts = __t; }
5423            }
5424        }
5425        { let __t = self.index_by(self.accounts.clone(), Value::Str("id".into())); self.accountsById = __t; }
5426        return self.accounts.clone();
5427
5428    Value::Null
5429} }
5430
5431    fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5432        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
5433        let mut since = get_arg(optional_args, 1, Value::Int(0));
5434        let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5435        // given a sorted arrays of trades (recent last) and a timeframe builds an array of OHLCV candles
5436        // note, default limit value (2147483647) is max int32 value
5437        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 });
5438        let mut ohlcvs: Value = Value::from(vec![]);
5439        let mut i_timestamp: Value = Value::Int(0);
5440        // const open = 1;
5441        let mut i_high: Value = Value::Int(2);
5442        let mut i_low: Value = Value::Int(3);
5443        let mut i_close: Value = Value::Int(4);
5444        let mut i_volume: Value = Value::Int(5);
5445        let mut i_count: Value = Value::Int(6);
5446        let mut tradesLength: Value = Value::Int(trades.len() as i64);
5447        let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5448        let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5449    let mut m = indexmap::IndexMap::new();
5450    m
5451})]);
5452        let mut skipZeroPrices: Value = self.safe_bool_k(options, "skipZeroPrices", &[Value::Bool(true)]);
5453        {
5454                        let mut i: Value = Value::Int(0);
5455            let mut __for_first_132: bool = true;
5456            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) } {
5457            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);
5458            let mut ts: Value = trade.as_map().and_then(|__m| __m.get("timestamp")).cloned().unwrap_or(Value::Null);
5459            let mut price: Value = trade.as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null);
5460            if (ts == Value::Null) || (price == Value::Null) {
5461                continue;
5462            }
5463            if ts.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5464                continue;
5465            }
5466            if (ts == Value::Null) {
5467                panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing ts".into()))));
5468            }
5469            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)
5470            if openingTime.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5471                continue;
5472            }
5473            let mut ohlcv_length: Value = Value::Int(ohlcvs.len() as i64);
5474            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 });
5475            if (price == Value::Null) {
5476                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() requires a price argument".into()))));
5477            }
5478            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)) {
5479                continue;
5480            }
5481            let mut isNewCandle: bool = candle.as_f64() == Value::Int(-1).as_f64();
5482            if !isNewCandle {
5483                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);
5484                if (candleTimestamp == Value::Null) {
5485                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing candle timestamp".into()))));
5486                }
5487                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);
5488            }
5489            if isNewCandle {
5490                // moved to a new timeframe -> create a new candle from opening trade
5491                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)]));
5492            }  else {
5493                // still processing the same timeframe -> update opening trade
5494                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);
5495                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);
5496                let mut prevHighValue: Value = (if (prevHigh == Value::Null) { price.clone() } else { prevHigh });
5497                let mut prevLowValue: Value = (if (prevLow == Value::Null) { price.clone() } else { prevLow });
5498                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
5499                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
5500                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price);
5501                { 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); };
5502                { 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); };
5503            }
5504        }
5505        }
5506        return ohlcvs;
5507
5508    Value::Null
5509}
5510
5511    fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5512        let mut market = get_arg(optional_args, 0, Value::Null);
5513        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
5514        let mut since = get_arg(optional_args, 2, Value::Null);
5515        let mut limit = get_arg(optional_args, 3, Value::Null);
5516        let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs, &[]);
5517        return self.parse_ohlc_vs(result, &[market, timeframe, since, limit]);
5518
5519    Value::Null
5520}
5521
5522    fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5523        let mut code = get_arg(optional_args, 0, Value::Null);
5524        let mut symbol = get_arg(optional_args, 1, Value::Null);
5525        let mut since = get_arg(optional_args, 2, Value::Null);
5526        let mut limit = get_arg(optional_args, 3, Value::Null);
5527        let mut params = get_arg(optional_args, 4, Value::Map({
5528    let mut m = indexmap::IndexMap::new();
5529    m
5530}));
5531        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowInterest() is not supported yet".into()))));
5532
5533    Value::Null
5534} }
5535
5536    fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5537        // async-virtual: try the derived exchange first
5538        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 {
5539            if !matches!(__v, crate::Value::Null) { return __v; }
5540        }
5541
5542        let mut code = get_arg(optional_args, 0, Value::Null);
5543        let mut since = get_arg(optional_args, 1, Value::Null);
5544        let mut limit = get_arg(optional_args, 2, Value::Null);
5545        let mut params = get_arg(optional_args, 3, Value::Map({
5546    let mut m = indexmap::IndexMap::new();
5547    m
5548}));
5549        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedger() is not supported yet".into()))));
5550
5551    Value::Null
5552} }
5553
5554    fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5555        let mut code = get_arg(optional_args, 0, Value::Null);
5556        let mut params = get_arg(optional_args, 1, Value::Map({
5557    let mut m = indexmap::IndexMap::new();
5558    m
5559}));
5560        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedgerEntry() is not supported yet".into()))));
5561
5562    Value::Null
5563} }
5564
5565    fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5566        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5567        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5568        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5569        let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5570        let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5571        let mut countOrId: Value = self.safe_integer(bidask, countOrIdKey, &[]);
5572        let mut bidAsk: Value = Value::from(vec![price, amount]);
5573        if (countOrId != Value::Null) {
5574            append_to_array(&mut bidAsk, countOrId);
5575        }
5576        return bidAsk;
5577
5578    Value::Null
5579}
5580
5581    fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5582        let mut currency = get_arg(optional_args, 0, Value::Null);
5583        if (currencyId == Value::Null) && (currency != Value::Null) {
5584            return currency;
5585        }
5586        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) {
5587            return get_value(&self.currencies_by_id, &currencyId);
5588        }
5589        let mut code: Value = currencyId.clone();
5590        if (currencyId != Value::Null) {
5591            code = self.common_currency_code(to_upper(&currencyId));
5592        }
5593        return self.safe_currency_structure(Value::Map({
5594    let mut m = indexmap::IndexMap::new();
5595        m.insert("id".to_string(), currencyId);
5596        m.insert("code".to_string(), code);
5597        m.insert("precision".to_string(), Value::Null);
5598    m
5599}));
5600
5601    Value::Null
5602}
5603
5604    fn safe_market(&self, optional_args: &[Value]) -> Value {
5605        let mut marketId = get_arg(optional_args, 0, Value::Null);
5606        let mut market = get_arg(optional_args, 1, Value::Null);
5607        let mut delimiter = get_arg(optional_args, 2, Value::Null);
5608        let mut marketType = get_arg(optional_args, 3, Value::Null);
5609        if (marketId != Value::Null) {
5610            if (self.markets_by_id.clone() != Value::Null) && (in_op(&self.markets_by_id, &marketId)) {
5611                let mut markets: Value = get_value(&self.markets_by_id, &marketId);
5612                let mut numMarkets: Value = get_array_length(&markets);
5613                if is_equal(&numMarkets, &Value::Int(1)) {
5614                    return get_value(&markets, &Value::Int(0));
5615                }  else {
5616                    if (marketType == Value::Null) && (market == Value::Null) {
5617                        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()))));
5618                    }
5619                    let mut marketTypeResolved: Value = (if (marketType == Value::Null) { self.safe_string_k(market.clone(), "type", &[Value::Str("".into())]) } else { marketType });
5620                    {
5621                                                let mut i: Value = Value::Int(0);
5622                        let mut __for_first_133: bool = true;
5623                        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) } {
5624                        let mut currentMarket: Value = get_value(&markets, &i);
5625                        let mut currentMarket: Value = get_value(&markets, &i);
5626                        if is_equal(&get_value(&currentMarket, &marketTypeResolved), &Value::Bool(true)) {
5627                            return currentMarket;
5628                        }
5629                    }
5630                    }
5631                }
5632            }  else if (delimiter != Value::Null) && (delimiter.as_str() != Some("")) {
5633                let mut parts: Value = split(&marketId, &delimiter);
5634                let mut partsLength: f64 = ((parts.len() as i64) as f64);
5635                let mut result: Value = self.safe_market_structure(&[Value::Map({
5636    let mut m = indexmap::IndexMap::new();
5637        m.insert("symbol".to_string(), marketId.clone());
5638        m.insert("marketId".to_string(), marketId.clone());
5639    m
5640})]);
5641                if (result == Value::Null) {
5642                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5643                }
5644                if (partsLength == 2.0) {
5645                    let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
5646                    let mut quoteId: Value = self.safe_string(parts, Value::Int(1), &[]);
5647                    let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
5648                    let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
5649                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("baseId".into(), baseId); }
5650                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quoteId); }
5651                    if (base != Value::Null) {
5652                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("base".into(), base.clone()); }
5653                    }
5654                    if (quote != Value::Null) {
5655                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quote".into(), quote.clone()); }
5656                    }
5657                    if (base != Value::Null) && (quote != Value::Null) {
5658                        add_element_to_object(&mut result, &Value::Str("symbol".into()), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
5659                    }
5660                }
5661                return result;
5662            }
5663        }
5664        if (market != Value::Null) {
5665            return market;
5666        }
5667        let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5668    let mut m = indexmap::IndexMap::new();
5669        m.insert("symbol".to_string(), marketId.clone());
5670        m.insert("marketId".to_string(), marketId);
5671    m
5672})]);
5673        if (emptyMarket == Value::Null) {
5674            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5675        }
5676        return emptyMarket;
5677
5678    Value::Null
5679}
5680
5681    fn market_or_null(&self, optional_args: &[Value]) -> Value {
5682        let mut symbol = get_arg(optional_args, 0, Value::Null);
5683        if (symbol == Value::Null) {
5684            return Value::Null;
5685        }
5686        return self.market(symbol);
5687
5688    Value::Null
5689}
5690
5691    fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5692        let mut error = get_arg(optional_args, 0, Value::Bool(true));
5693        /*
5694         * @ignore
5695         * @method
5696         * @param {boolean} error throw an error that a credential is required if true
5697         * @returns {boolean} true if all required credentials have been set, otherwise false or an error is thrown is param error=true
5698         */
5699        let mut keys: Value = object_keys(&self.requiredCredentials);
5700        {
5701                        let mut i: Value = Value::Int(0);
5702            let mut __for_first_134: bool = true;
5703            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) } {
5704            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);
5705            let mut credentialValue: Value = self.prop(&key);
5706            let mut credentialMissing: bool = (credentialValue == Value::Null) || (credentialValue == Value::Null) || (is_equal(&credentialValue, &Value::Bool(false))) || (credentialValue.as_str() == Some(""));
5707            if (get_value(&self.requiredCredentials, &key).as_bool() == Some(true)) && credentialMissing {
5708                if is_true(&error) {
5709                    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()))));
5710                }  else {
5711                    return Value::Bool(false);
5712                }
5713            }
5714        }
5715        }
5716        return Value::Bool(true);
5717
5718    Value::Null
5719}
5720
5721    fn oath(&self) -> Value {
5722        if (self.twofa.clone() != Value::Null) {
5723            return totp(self.twofa.clone());
5724        }  else {
5725            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".into()))));
5726        }
5727
5728    Value::Null
5729}
5730
5731    fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5732        // async-virtual: try the derived exchange first
5733        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 {
5734            if !matches!(__v, crate::Value::Null) { return __v; }
5735        }
5736
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(" fetchBalance() is not supported yet".into()))));
5742
5743    Value::Null
5744} }
5745
5746    fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5747        let mut params = get_arg(optional_args, 0, Value::Map({
5748    let mut m = indexmap::IndexMap::new();
5749    m
5750}));
5751        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalanceWs() is not supported yet".into()))));
5752
5753    Value::Null
5754} }
5755
5756    fn parse_balance(&self, mut response: Value) -> Value {
5757        // virtual-dispatch (static: DerivedExchange::parse_balance(self, ...))
5758        { let __v = crate::exchange::DerivedExchange::parse_balance(self, response); if !matches!(__v, crate::Value::Null) { return __v; } }
5759
5760        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBalance() is not supported yet".into()))));
5761
5762    Value::Null
5763}
5764
5765    fn watch_balance(&mut self, 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        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBalance() is not supported yet".into()))));
5771
5772    Value::Null
5773} }
5774
5775    fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5776        let mut params = get_arg(optional_args, 0, Value::Map({
5777    let mut m = indexmap::IndexMap::new();
5778    m
5779}));
5780        let mut balance: Value = self.fetch_balance(&[params]).await;
5781        return get_value(&balance, &part);
5782
5783    Value::Null
5784} }
5785
5786    fn fetch_free_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("free".into()), &[params]).await;
5792
5793    Value::Null
5794} }
5795
5796    fn fetch_used_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("used".into()), &[params]).await;
5802
5803    Value::Null
5804} }
5805
5806    fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5807        let mut params = get_arg(optional_args, 0, Value::Map({
5808    let mut m = indexmap::IndexMap::new();
5809    m
5810}));
5811        return self.fetch_partial_balance(Value::Str("total".into()), &[params]).await;
5812
5813    Value::Null
5814} }
5815
5816    fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5817        // async-virtual: try the derived exchange first
5818        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 {
5819            if !matches!(__v, crate::Value::Null) { return __v; }
5820        }
5821
5822        let mut params = get_arg(optional_args, 0, Value::Map({
5823    let mut m = indexmap::IndexMap::new();
5824    m
5825}));
5826        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchStatus() is not supported yet".into()))));
5827
5828    Value::Null
5829} }
5830
5831    fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5832        let mut params = get_arg(optional_args, 0, Value::Map({
5833    let mut m = indexmap::IndexMap::new();
5834    m
5835}));
5836        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)) {
5837            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFee() is not supported yet".into()))));
5838        }
5839        return self.fetch_transaction_fees(&[Value::from(vec![code]), params]).await;
5840
5841    Value::Null
5842} }
5843
5844    fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5845        let mut codes = get_arg(optional_args, 0, Value::Null);
5846        let mut params = get_arg(optional_args, 1, Value::Map({
5847    let mut m = indexmap::IndexMap::new();
5848    m
5849}));
5850        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFees() is not supported yet".into()))));
5851
5852    Value::Null
5853} }
5854
5855    fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5856        // async-virtual: try the derived exchange first
5857        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 {
5858            if !matches!(__v, crate::Value::Null) { return __v; }
5859        }
5860
5861        let mut codes = get_arg(optional_args, 0, Value::Null);
5862        let mut params = get_arg(optional_args, 1, Value::Map({
5863    let mut m = indexmap::IndexMap::new();
5864    m
5865}));
5866        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFees() is not supported yet".into()))));
5867
5868    Value::Null
5869} }
5870
5871    fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5872        // async-virtual: try the derived exchange first
5873        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 {
5874            if !matches!(__v, crate::Value::Null) { return __v; }
5875        }
5876
5877        let mut params = get_arg(optional_args, 0, Value::Map({
5878    let mut m = indexmap::IndexMap::new();
5879    m
5880}));
5881        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)) {
5882            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFee() is not supported yet".into()))));
5883        }
5884        let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::from(vec![code.clone()]), params]).await;
5885        return self.safe_value(fees, code, &[]);
5886
5887    Value::Null
5888} }
5889
5890    fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
5891        let mut mapping = get_arg(optional_args, 0, Value::Map({
5892    let mut m = indexmap::IndexMap::new();
5893    m
5894}));
5895        if (key == Value::Null) {
5896            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" getSupportedMapping() requires a key argument".into()))));
5897        }
5898        if (in_op(&mapping, &key)) {
5899            return mapping.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
5900        }  else {
5901            let mut keys: Value = object_keys(&mapping);
5902            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())))));
5903        }
5904
5905    Value::Null
5906}
5907
5908    fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5909        let mut params = get_arg(optional_args, 0, Value::Map({
5910    let mut m = indexmap::IndexMap::new();
5911    m
5912}));
5913        self.load_markets(&[]).await;
5914        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)) {
5915            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() is not supported yet".into()))));
5916        }
5917        let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params]).await;
5918        let mut rate: Value = self.safe_dict(borrowRates, code.clone(), &[]);
5919        if (rate == Value::Null) {
5920            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)));
5921        }
5922        return rate;
5923
5924    Value::Null
5925} }
5926
5927    fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5928        let mut params = get_arg(optional_args, 0, Value::Map({
5929    let mut m = indexmap::IndexMap::new();
5930    m
5931}));
5932        self.load_markets(&[]).await;
5933        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)) {
5934            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() is not supported yet".into()))));
5935        }
5936        let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params]).await;
5937        let mut rate: Value = self.safe_dict(borrowRates, symbol.clone(), &[]);
5938        if (rate == Value::Null) {
5939            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)));
5940        }
5941        return rate;
5942
5943    Value::Null
5944} }
5945
5946/* eslint-disable no-unused-vars */
5947/* eslint-enable no-unused-vars */
5948    fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
5949        let mut message = get_arg(optional_args, 0, Value::Null);
5950        if (value == Value::Null) {
5951            let mut errorMessage: Value = (if (message != Value::Null) { message } else { Value::Str("value is required".into()) });
5952            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), errorMessage)));
5953        }
5954        return value;
5955
5956    Value::Null
5957}
5958
5959/* eslint-disable no-unused-vars */
5960/* eslint-enable no-unused-vars */
5961    fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5962        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5963        // This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
5964        let mut defaultOptionName: Value = Value::Str(format!("{}{}", Value::Str("default".into()), self.capitalize(optionName.clone())).into()); // we also need to check the 'defaultXyzWhatever'
5965        // check if params contain the key
5966        let mut value: Value = self.safe_value2(params.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
5967        if (value != Value::Null) {
5968            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
5969            return Value::from(vec![value.clone(), paramsOmitted]);
5970        }  else {
5971            // handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
5972            let mut callerMethodNameparamsCallerMethodNameVariable = self.handle_param_string(params, Value::Str("callerMethodName".into()), &[methodName]);
5973            let mut callerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5974            let mut paramsCallerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5975            // check if exchange has properties for this method
5976            let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), callerMethodName, &[]);
5977            if (exchangeWideMethodOptions != Value::Null) {
5978                // check if the option is defined inside this method's props
5979                value = self.safe_value2(exchangeWideMethodOptions, optionName.clone(), defaultOptionName.clone(), &[]);
5980            }
5981            if (value == Value::Null) {
5982                // if it's still undefined, check if global exchange-wide option exists
5983                value = self.safe_value2(self.options.clone(), optionName, defaultOptionName, &[]);
5984            }
5985            // if it's still undefined, use the default value
5986            value = (if (value != Value::Null) { value.clone() } else { defaultValue });
5987            return Value::from(vec![value, paramsCallerMethodName]);
5988        }
5989
5990    Value::Null
5991}
5992
5993/* eslint-disable no-unused-vars */
5994/* eslint-enable no-unused-vars */
5995    fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
5996        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5997        let mut valueparamsOption1Variable = self.handle_option_and_params(params, methodName1.clone(), optionName1, &[]);
5998        let mut value: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5999        let mut paramsOption1: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6000        if (value != Value::Null) {
6001            // omit optionName2 too from params
6002            let mut paramsOmitted: Value = self.omit(paramsOption1.clone(), optionName2.clone(), &[]);
6003            return Value::from(vec![value, paramsOmitted]);
6004        }
6005        return self.handle_option_and_params(paramsOption1, methodName1, optionName2, &[defaultValue]);
6006
6007    Value::Null
6008}
6009
6010/* eslint-disable no-unused-vars */
6011/* eslint-enable no-unused-vars */
6012    fn handle_option_string_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6013        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6014        // handleOptionAndParams read as a string; the statically typed ports throw on another type
6015        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6016        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6017        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6018        return Value::from(vec![self.check_option_string(methodName, optionName, value), newParams]);
6019
6020    Value::Null
6021}
6022
6023/* eslint-disable no-unused-vars */
6024/* eslint-enable no-unused-vars */
6025    fn handle_option_string_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6026        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6027        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6028        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6029        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6030        return Value::from(vec![self.check_option_string(methodName, optionName1, value), newParams]);
6031
6032    Value::Null
6033}
6034
6035/* eslint-disable no-unused-vars */
6036/* eslint-enable no-unused-vars */
6037    fn handle_option_bool_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6038        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6039        // handleOptionAndParams read as a boolean; the statically typed ports throw on another type
6040        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6041        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6042        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6043        return Value::from(vec![self.check_option_bool(methodName, optionName, value), newParams]);
6044
6045    Value::Null
6046}
6047
6048/* eslint-disable no-unused-vars */
6049/* eslint-enable no-unused-vars */
6050    fn handle_option_bool_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6051        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6052        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6053        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6054        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6055        return Value::from(vec![self.check_option_bool(methodName, optionName1, value), newParams]);
6056
6057    Value::Null
6058}
6059
6060/* eslint-disable no-unused-vars */
6061/* eslint-enable no-unused-vars */
6062    fn handle_option_integer_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6063        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6064        // handleOptionAndParams read as an integer; the statically typed ports throw on another type
6065        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6066        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6067        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6068        return Value::from(vec![self.check_option_integer(methodName, optionName, value), newParams]);
6069
6070    Value::Null
6071}
6072
6073/* eslint-disable no-unused-vars */
6074/* eslint-enable no-unused-vars */
6075    fn handle_option_integer_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6076        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6077        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6078        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6079        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6080        return Value::from(vec![self.check_option_integer(methodName, optionName1, value), newParams]);
6081
6082    Value::Null
6083}
6084
6085    fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6086        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6087        let mut res: Value = self.handle_option_and_params(Value::Map({
6088    let mut m = indexmap::IndexMap::new();
6089    m
6090}), methodName, optionName, &[defaultValue]);
6091        return self.safe_value(res, Value::Int(0), &[]);
6092
6093    Value::Null
6094}
6095
6096    fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6097        let mut market = get_arg(optional_args, 0, Value::Null);
6098        let mut params = get_arg(optional_args, 1, Value::Map({
6099    let mut m = indexmap::IndexMap::new();
6100    m
6101}));
6102        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6103        /*
6104         * @ignore
6105         * @method
6106         * @name exchange#handleMarketTypeAndParams
6107         * @param methodName the method calling handleMarketTypeAndParams
6108         * @param {Market} market
6109         * @param {object} params
6110         * @param {string} [params.type] type assigned by user
6111         * @param {string} [params.defaultType] same as params.type
6112         * @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
6113         * @returns {[string, object]} the market type and params with type and defaultType omitted
6114         */
6115        // type from param
6116        let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6117        if (type_var != Value::Null) {
6118            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("defaultType".into()), Value::Str("type".into())]), &[]);
6119            return Value::from(vec![type_var, paramsOmitted]);
6120        }
6121        // type from market
6122        if (market != Value::Null) {
6123            return Value::from(vec![market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), params.clone()]);
6124        }
6125        // type from default-argument
6126        if (defaultValue != Value::Null) {
6127            return Value::from(vec![defaultValue, params.clone()]);
6128        }
6129        let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName, &[]);
6130        if (methodOptions != Value::Null) {
6131            if matches!(&methodOptions, Value::Str(_)) {
6132                return Value::from(vec![methodOptions.clone(), params.clone()]);
6133            }  else {
6134                let mut typeFromMethod: Value = self.safe_string2(methodOptions, Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6135                if (typeFromMethod != Value::Null) {
6136                    return Value::from(vec![typeFromMethod, params.clone()]);
6137                }
6138            }
6139        }
6140        let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[Value::Str("spot".into())]);
6141        return Value::from(vec![defaultType, params]);
6142
6143    Value::Null
6144}
6145
6146    fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6147        let mut market = get_arg(optional_args, 0, Value::Null);
6148        let mut params = get_arg(optional_args, 1, Value::Map({
6149    let mut m = indexmap::IndexMap::new();
6150    m
6151}));
6152        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6153        let mut subType: Value = Value::Null;
6154        // if set in params, it takes precedence
6155        let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".into()), Value::Str("defaultSubType".into()), &[]);
6156        // avoid omitting if it's not present
6157        if (subTypeInParams != Value::Null) {
6158            if (subTypeInParams.as_str() == Some("linear")) || (subTypeInParams.as_str() == Some("inverse")) {
6159                subType = subTypeInParams;
6160            }
6161            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("subType".into()), Value::Str("defaultSubType".into())]), &[]);
6162            return Value::from(vec![subType.clone(), paramsOmitted]);
6163        }  else {
6164            // at first, check from market object
6165            if (market != Value::Null) {
6166                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6167                    subType = Value::Str("linear".into());
6168                }  else if (market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6169                    subType = Value::Str("inverse".into());
6170                }
6171            }
6172            // if it was not defined in market object
6173            if (subType == Value::Null) {
6174                let mut values: Value = self.handle_option_and_params(Value::Map({
6175    let mut m = indexmap::IndexMap::new();
6176    m
6177}), methodName, Value::Str("subType".into()), &[defaultValue]); // no need to re-test params here
6178                subType = values.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6179            }
6180        }
6181        return Value::from(vec![subType, params]);
6182
6183    Value::Null
6184}
6185
6186    fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6187        let mut params = get_arg(optional_args, 0, Value::Map({
6188    let mut m = indexmap::IndexMap::new();
6189    m
6190}));
6191        let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6192        return self.handle_option_string_and_params(params, methodName, Value::Str("marginMode".into()), &[defaultValue]);
6193
6194    Value::Null
6195}
6196
6197    fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6198        if (string == Value::Null) {
6199            return;
6200        }
6201        if (in_op(&exact, &string)) {
6202            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
6203        }
6204}
6205
6206    fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6207        let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string);
6208        if (broadKey != Value::Null) {
6209            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
6210        }
6211}
6212
6213    fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6214        // a helper for matching error strings exactly vs broadly
6215        let mut keys: Value = object_keys(&broad);
6216        {
6217                        let mut i: Value = Value::Int(0);
6218            let mut __for_first_135: bool = true;
6219            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) } {
6220            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);
6221            if (string != Value::Null) {
6222                if get_index_of(&string, &key).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
6223                    return key;
6224                }
6225            }
6226        }
6227        }
6228        return Value::Null;
6229
6230    Value::Null
6231}
6232
6233    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 {
6234        // virtual-dispatch (static: DerivedExchange::handle_errors(self, ...))
6235        { 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; } }
6236
6237        return Value::Null;
6238
6239    Value::Null
6240}
6241
6242    fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6243        let mut config = get_arg(optional_args, 0, Value::Map({
6244    let mut m = indexmap::IndexMap::new();
6245    m
6246}));
6247        let __config_empty = indexmap::IndexMap::new();
6248        let config = config.as_map().unwrap_or(&__config_empty);
6249        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) });
6250
6251    Value::Null
6252}
6253
6254    fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6255        let mut symbols = get_arg(optional_args, 0, Value::Null);
6256        let mut params = get_arg(optional_args, 1, Value::Map({
6257    let mut m = indexmap::IndexMap::new();
6258    m
6259}));
6260        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotTickers() is not supported yet".into()))));
6261
6262    Value::Null
6263} }
6264
6265    fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6266        let mut symbols = get_arg(optional_args, 0, Value::Null);
6267        let mut params = get_arg(optional_args, 1, Value::Map({
6268    let mut m = indexmap::IndexMap::new();
6269    m
6270}));
6271        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractTickers() is not supported yet".into()))));
6272
6273    Value::Null
6274} }
6275
6276    fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6277        let mut symbols = get_arg(optional_args, 0, Value::Null);
6278        let mut limit = get_arg(optional_args, 1, Value::Null);
6279        let mut params = get_arg(optional_args, 2, Value::Map({
6280    let mut m = indexmap::IndexMap::new();
6281    m
6282}));
6283        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBooks() is not supported yet".into()))));
6284
6285    Value::Null
6286} }
6287
6288    fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6289        let mut symbols = get_arg(optional_args, 0, Value::Null);
6290        let mut params = get_arg(optional_args, 1, 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(" unWatchTickers() is not supported yet".into()))));
6295
6296    Value::Null
6297} }
6298
6299    fn un_watch_funding_rate(&mut self, mut symbol: 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(" unWatchFundingRate() is not supported yet".into()))));
6305
6306    Value::Null
6307} }
6308
6309    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 {
6310        let mut params = get_arg(optional_args, 0, Value::Map({
6311    let mut m = indexmap::IndexMap::new();
6312    m
6313}));
6314        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTwapOrder() is not supported yet".into()))));
6315
6316    Value::Null
6317} }
6318
6319    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 {
6320        let mut amount = get_arg(optional_args, 0, Value::Null);
6321        let mut params = get_arg(optional_args, 1, Value::Map({
6322    let mut m = indexmap::IndexMap::new();
6323    m
6324}));
6325        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() is not supported yet".into()))));
6326
6327    Value::Null
6328} }
6329
6330    fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6331        let mut code = get_arg(optional_args, 0, Value::Null);
6332        let mut params = get_arg(optional_args, 1, Value::Map({
6333    let mut m = indexmap::IndexMap::new();
6334    m
6335}));
6336        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTrade() is not supported yet".into()))));
6337
6338    Value::Null
6339} }
6340
6341    fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6342        let mut code = get_arg(optional_args, 0, Value::Null);
6343        let mut since = get_arg(optional_args, 1, Value::Null);
6344        let mut limit = get_arg(optional_args, 2, Value::Null);
6345        let mut params = get_arg(optional_args, 3, Value::Map({
6346    let mut m = indexmap::IndexMap::new();
6347    m
6348}));
6349        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTradeHistory() is not supported yet".into()))));
6350
6351    Value::Null
6352} }
6353
6354    fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6355        // async-virtual: try the derived exchange first
6356        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 {
6357            if !matches!(__v, crate::Value::Null) { return __v; }
6358        }
6359
6360        let mut symbol = get_arg(optional_args, 0, Value::Null);
6361        let mut params = get_arg(optional_args, 1, 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(" fetchPositionMode() is not supported yet".into()))));
6366
6367    Value::Null
6368} }
6369
6370    fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6371        let mut params = get_arg(optional_args, 0, Value::Map({
6372    let mut m = indexmap::IndexMap::new();
6373    m
6374}));
6375        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchADLRank() is not supported yet".into()))));
6376
6377    Value::Null
6378} }
6379
6380    fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6381        // async-virtual: try the derived exchange first
6382        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 {
6383            if !matches!(__v, crate::Value::Null) { return __v; }
6384        }
6385
6386        let mut symbols = get_arg(optional_args, 0, Value::Null);
6387        let mut params = get_arg(optional_args, 1, Value::Map({
6388    let mut m = indexmap::IndexMap::new();
6389    m
6390}));
6391        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6392
6393    Value::Null
6394} }
6395
6396    fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6397        // async-virtual: try the derived exchange first
6398        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 {
6399            if !matches!(__v, crate::Value::Null) { return __v; }
6400        }
6401
6402        let mut params = get_arg(optional_args, 0, Value::Map({
6403    let mut m = indexmap::IndexMap::new();
6404    m
6405}));
6406        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)) {
6407            self.load_markets(&[]).await;
6408            let mut market: Value = self.market(symbol);
6409            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
6410            let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::from(vec![symbolResolved.clone()]), params]).await;
6411            let mut rank: Value = self.safe_dict(ranks, Value::Int(0), &[]);
6412            if (rank == Value::Null) {
6413                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)));
6414            }  else {
6415                return rank;
6416            }
6417        }  else {
6418            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6419        }
6420
6421    Value::Null
6422} }
6423
6424    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 {
6425        let mut price = get_arg(optional_args, 0, Value::Null);
6426        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6427        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6428        let mut params = get_arg(optional_args, 3, Value::Map({
6429    let mut m = indexmap::IndexMap::new();
6430    m
6431}));
6432        if (takeProfit == Value::Null) && (stopLoss == Value::Null) {
6433            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".into()))));
6434        }
6435        if (takeProfit != Value::Null) {
6436            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), Value::Map({
6437    let mut m = indexmap::IndexMap::new();
6438        m.insert("triggerPrice".to_string(), takeProfit);
6439    m
6440})); }
6441        }
6442        if (stopLoss != Value::Null) {
6443            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), Value::Map({
6444    let mut m = indexmap::IndexMap::new();
6445        m.insert("triggerPrice".to_string(), stopLoss);
6446    m
6447})); }
6448        }
6449        let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
6450        let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
6451        let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
6452        let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
6453        let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
6454        let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
6455        let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
6456        let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
6457        if (takeProfitType != Value::Null) {
6458            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("type".into()), takeProfitType);
6459        }
6460        if (takeProfitPriceType != Value::Null) {
6461            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("priceType".into()), takeProfitPriceType);
6462        }
6463        if (takeProfitLimitPrice != Value::Null) {
6464            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("price".into()), self.parse_to_numeric(takeProfitLimitPrice));
6465        }
6466        if (takeProfitAmount != Value::Null) {
6467            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("amount".into()), self.parse_to_numeric(takeProfitAmount));
6468        }
6469        if (stopLossType != Value::Null) {
6470            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("type".into()), stopLossType);
6471        }
6472        if (stopLossPriceType != Value::Null) {
6473            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("priceType".into()), stopLossPriceType);
6474        }
6475        if (stopLossLimitPrice != Value::Null) {
6476            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("price".into()), self.parse_to_numeric(stopLossLimitPrice));
6477        }
6478        if (stopLossAmount != Value::Null) {
6479            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("amount".into()), self.parse_to_numeric(stopLossAmount));
6480        }
6481        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())]), &[]);
6482        return paramsOmitted;
6483
6484    Value::Null
6485}
6486
6487    fn create_spot_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(" createSpotOrders() is not supported yet".into()))));
6493
6494    Value::Null
6495} }
6496
6497    fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6498        let mut params = get_arg(optional_args, 0, Value::Map({
6499    let mut m = indexmap::IndexMap::new();
6500    m
6501}));
6502        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createContractOrders() is not supported yet".into()))));
6503
6504    Value::Null
6505} }
6506
6507    fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6508        let mut symbol = get_arg(optional_args, 0, Value::Null);
6509        let mut params = get_arg(optional_args, 1, Value::Map({
6510    let mut m = indexmap::IndexMap::new();
6511    m
6512}));
6513        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelSpotOrder() is not supported yet".into()))));
6514
6515    Value::Null
6516} }
6517
6518    fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6519        let mut symbol = get_arg(optional_args, 0, Value::Null);
6520        let mut params = get_arg(optional_args, 1, Value::Map({
6521    let mut m = indexmap::IndexMap::new();
6522    m
6523}));
6524        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelContractOrder() is not supported yet".into()))));
6525
6526    Value::Null
6527} }
6528
6529    fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6530        let mut symbol = get_arg(optional_args, 0, Value::Null);
6531        let mut params = get_arg(optional_args, 1, Value::Map({
6532    let mut m = indexmap::IndexMap::new();
6533    m
6534}));
6535        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllSpotOrders() is not supported yet".into()))));
6536
6537    Value::Null
6538} }
6539
6540    fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6541        let mut symbol = get_arg(optional_args, 0, Value::Null);
6542        let mut params = get_arg(optional_args, 1, 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(" cancelAllContractOrders() is not supported yet".into()))));
6547
6548    Value::Null
6549} }
6550
6551    fn cancel_all_orders_after(&mut self, mut timeout: 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(" cancelAllOrdersAfter() is not supported yet".into()))));
6557
6558    Value::Null
6559} }
6560
6561    fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6562        let mut params = get_arg(optional_args, 0, Value::Map({
6563    let mut m = indexmap::IndexMap::new();
6564    m
6565}));
6566        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersForSymbols() is not supported yet".into()))));
6567
6568    Value::Null
6569} }
6570
6571    fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6572        let mut symbol = get_arg(optional_args, 0, Value::Null);
6573        let mut since = get_arg(optional_args, 1, Value::Null);
6574        let mut limit = get_arg(optional_args, 2, Value::Null);
6575        let mut params = get_arg(optional_args, 3, Value::Map({
6576    let mut m = indexmap::IndexMap::new();
6577    m
6578}));
6579        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() is not supported yet".into()))));
6580
6581    Value::Null
6582} }
6583
6584    fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6585        let mut since = get_arg(optional_args, 0, Value::Null);
6586        let mut limit = get_arg(optional_args, 1, Value::Null);
6587        let mut params = get_arg(optional_args, 2, 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(" fetchLiquidations() is not supported yet".into()))));
6592
6593    Value::Null
6594} }
6595
6596    fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6597        let mut params = get_arg(optional_args, 0, Value::Map({
6598    let mut m = indexmap::IndexMap::new();
6599    m
6600}));
6601        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchGreeks() is not supported yet".into()))));
6602
6603    Value::Null
6604} }
6605
6606    fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6607        let mut symbols = get_arg(optional_args, 0, Value::Null);
6608        let mut params = get_arg(optional_args, 1, 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(" fetchAllGreeks() is not supported yet".into()))));
6613
6614    Value::Null
6615} }
6616
6617    fn fetch_option_chain(&mut self, mut code: 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(" fetchOptionChain() is not supported yet".into()))));
6623
6624    Value::Null
6625} }
6626
6627    fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6628        let mut params = get_arg(optional_args, 0, Value::Map({
6629    let mut m = indexmap::IndexMap::new();
6630    m
6631}));
6632        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOption() is not supported yet".into()))));
6633
6634    Value::Null
6635} }
6636
6637    fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6638        let mut amount = get_arg(optional_args, 0, Value::Null);
6639        let mut params = get_arg(optional_args, 1, Value::Map({
6640    let mut m = indexmap::IndexMap::new();
6641    m
6642}));
6643        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertQuote() is not supported yet".into()))));
6644
6645    Value::Null
6646} }
6647
6648    fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6649        // async-virtual: try the derived exchange first
6650        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 {
6651            if !matches!(__v, crate::Value::Null) { return __v; }
6652        }
6653
6654        let mut code = get_arg(optional_args, 0, Value::Null);
6655        let mut since = get_arg(optional_args, 1, Value::Null);
6656        let mut limit = get_arg(optional_args, 2, Value::Null);
6657        let mut params = get_arg(optional_args, 3, Value::Map({
6658    let mut m = indexmap::IndexMap::new();
6659    m
6660}));
6661        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWithdrawals() is not supported yet".into()))));
6662
6663    Value::Null
6664} }
6665
6666    fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6667        // async-virtual: try the derived exchange first
6668        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 {
6669            if !matches!(__v, crate::Value::Null) { return __v; }
6670        }
6671
6672        let mut code = get_arg(optional_args, 0, Value::Null);
6673        let mut since = get_arg(optional_args, 1, Value::Null);
6674        let mut limit = get_arg(optional_args, 2, Value::Null);
6675        let mut params = get_arg(optional_args, 3, Value::Map({
6676    let mut m = indexmap::IndexMap::new();
6677    m
6678}));
6679        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposits() is not supported yet".into()))));
6680
6681    Value::Null
6682} }
6683
6684    fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6685        // async-virtual: try the derived exchange first
6686        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 {
6687            if !matches!(__v, crate::Value::Null) { return __v; }
6688        }
6689
6690        let mut code = get_arg(optional_args, 0, Value::Null);
6691        let mut since = get_arg(optional_args, 1, Value::Null);
6692        let mut limit = get_arg(optional_args, 2, Value::Null);
6693        let mut params = get_arg(optional_args, 3, Value::Map({
6694    let mut m = indexmap::IndexMap::new();
6695    m
6696}));
6697        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawals() is not supported yet".into()))));
6698
6699    Value::Null
6700} }
6701
6702    fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6703        let mut code = get_arg(optional_args, 0, Value::Null);
6704        let mut since = get_arg(optional_args, 1, Value::Null);
6705        let mut limit = get_arg(optional_args, 2, Value::Null);
6706        let mut params = get_arg(optional_args, 3, Value::Map({
6707    let mut m = indexmap::IndexMap::new();
6708    m
6709}));
6710        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWs() is not supported yet".into()))));
6711
6712    Value::Null
6713} }
6714
6715    fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6716        let mut code = get_arg(optional_args, 0, Value::Null);
6717        let mut since = get_arg(optional_args, 1, Value::Null);
6718        let mut limit = get_arg(optional_args, 2, Value::Null);
6719        let mut params = get_arg(optional_args, 3, Value::Map({
6720    let mut m = indexmap::IndexMap::new();
6721    m
6722}));
6723        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawalsWs() is not supported yet".into()))));
6724
6725    Value::Null
6726} }
6727
6728    fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6729        // async-virtual: try the derived exchange first
6730        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 {
6731            if !matches!(__v, crate::Value::Null) { return __v; }
6732        }
6733
6734        let mut symbol = get_arg(optional_args, 0, Value::Null);
6735        let mut since = get_arg(optional_args, 1, Value::Null);
6736        let mut limit = get_arg(optional_args, 2, Value::Null);
6737        let mut params = get_arg(optional_args, 3, Value::Map({
6738    let mut m = indexmap::IndexMap::new();
6739    m
6740}));
6741        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() is not supported yet".into()))));
6742
6743    Value::Null
6744} }
6745
6746    fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6747        let mut symbol = get_arg(optional_args, 0, Value::Null);
6748        let mut since = get_arg(optional_args, 1, Value::Null);
6749        let mut limit = get_arg(optional_args, 2, Value::Null);
6750        let mut params = get_arg(optional_args, 3, Value::Map({
6751    let mut m = indexmap::IndexMap::new();
6752    m
6753}));
6754        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() is not supported yet".into()))));
6755
6756    Value::Null
6757} }
6758
6759    fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
6760        // virtual-dispatch (static: DerivedExchange::parse_last_price(self, ...))
6761        { 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; } }
6762
6763        let mut market = get_arg(optional_args, 0, Value::Null);
6764        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLastPrice() is not supported yet".into()))));
6765
6766    Value::Null
6767}
6768
6769    fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6770        // async-virtual: try the derived exchange first
6771        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 {
6772            if !matches!(__v, crate::Value::Null) { return __v; }
6773        }
6774
6775        let mut params = get_arg(optional_args, 0, Value::Map({
6776    let mut m = indexmap::IndexMap::new();
6777    m
6778}));
6779        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)) {
6780            let mut depositAddresses: Value = self.fetch_deposit_addresses(&[Value::from(vec![code.clone()]), params.clone()]).await;
6781            let mut depositAddress: Value = self.safe_value(depositAddresses, code.clone(), &[]);
6782            if (depositAddress == Value::Null) {
6783                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()))));
6784            }  else {
6785                return depositAddress;
6786            }
6787        }  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)) {
6788            let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
6789            let mut paramsOmitted: Value = self.omit(params, Value::Str("network".into()), &[]);
6790            let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code, &[paramsOmitted]).await;
6791            if (network != Value::Null) {
6792                return self.safe_dict(addressStructures.clone(), network, &[]);
6793            }  else {
6794                let mut keys: Value = object_keys(&addressStructures);
6795                let mut key: Value = keys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6796                return self.safe_dict(addressStructures, key, &[]);
6797            }
6798        }  else {
6799            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() is not supported yet".into()))));
6800        }
6801
6802    Value::Null
6803} }
6804
6805    fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6806        let mut params = get_arg(optional_args, 0, Value::Map({
6807    let mut m = indexmap::IndexMap::new();
6808    m
6809}));
6810        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractDepositAddress() is not supported yet".into()))));
6811
6812    Value::Null
6813} }
6814
6815    fn account(&self) -> Value {
6816        return Value::Map({
6817    let mut m = indexmap::IndexMap::new();
6818        m.insert("free".to_string(), Value::Null);
6819        m.insert("used".to_string(), Value::Null);
6820        m.insert("total".to_string(), Value::Null);
6821    m
6822});
6823
6824    Value::Null
6825}
6826
6827/*
6828 * @ignore
6829 * @method
6830 * @description merges a per-market (isolated margin) account into a flat code-keyed balance dict, summing string fields when the code recurs across markets
6831 * @param {object} result the code-keyed balance dict being built
6832 * @param {string} code unified currency code
6833 * @param {object} account a balance account with string free/used/total/debt
6834 * @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
6835 */
6836    fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
6837        if !(in_op(&result, &code)) {
6838            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
6839            return result;
6840        }
6841        let mut fields: Value = Value::from(vec![Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into()), Value::Str("debt".into())]);
6842        {
6843                        let mut i: Value = Value::Int(0);
6844            let mut __for_first_136: bool = true;
6845            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) } {
6846            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);
6847            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(), &[]);
6848            let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
6849            if (current == Value::Null) {
6850                add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
6851            }  else if (incoming != Value::Null) {
6852                add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(&current, &incoming));
6853            }
6854        }
6855        }
6856        return result;
6857
6858    Value::Null
6859}
6860
6861    fn common_currency_code(&self, mut code: Value) -> Value {
6862        if !is_true(&self.substituteCommonCurrencyCodes) {
6863            return code;
6864        }
6865        return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
6866
6867    Value::Null
6868}
6869
6870    fn currency(&self, mut code: Value) -> Value {
6871        if (code == Value::Null) {
6872            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currency() requires a code argument".into()))));
6873        }
6874        let mut keys: Value = object_keys(&self.currencies);
6875        let mut numCurrencies: f64 = ((keys.len() as i64) as f64);
6876        if (numCurrencies == 0.0) {
6877            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" currencies not loaded".into()))));
6878        }
6879        if matches!(&code, Value::Str(_)) {
6880            let mut currencies: Value = self.currencies.clone();
6881            let mut currenciesById: Value = self.currencies_by_id.clone();
6882            if (in_op(&currencies, &code)) {
6883                return currencies.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6884            }  else if (currenciesById != Value::Null) && (in_op(&currenciesById, &code)) {
6885                return currenciesById.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6886            }
6887        }
6888        panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have currency code ".into())).into()), code)));
6889
6890    Value::Null
6891}
6892
6893    fn market(&self, mut symbol: Value) -> Value {
6894        if (symbol == Value::Null) {
6895            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" market() requires a symbol argument".into()))));
6896        }
6897        let mut markets: Value = self.markets.clone();
6898        if (markets == Value::Null) {
6899            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
6900        }
6901        let mut marketsById: Value = self.markets_by_id.clone();
6902        if (in_op(&markets, &symbol)) {
6903            return get_value(&markets, &symbol);
6904        }  else if (marketsById != Value::Null) && (in_op(&marketsById, &symbol)) {
6905            let mut marketsList: Value = get_value(&marketsById, &symbol);
6906            let mut marketsList: Value = get_value(&marketsById, &symbol);
6907            let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("defaultSubType".into()), &[Value::Str("spot".into())]);
6908            {
6909                                let mut i: Value = Value::Int(0);
6910                let mut __for_first_137: bool = true;
6911                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) } {
6912                let mut market: Value = get_value(&marketsList, &i);
6913                let mut market: Value = get_value(&marketsList, &i);
6914                if is_equal(&get_value(&market, &defaultType), &Value::Bool(true)) {
6915                    return market;
6916                }
6917            }
6918            }
6919            return get_value(&marketsList, &Value::Int(0));
6920        }  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()))) {
6921            return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
6922        }
6923        panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have market symbol ".into())).into()), symbol)));
6924
6925    Value::Null
6926}
6927
6928    fn create_expired_option_market(&self, mut symbol: Value) -> Value {
6929        // virtual-dispatch (static: DerivedExchange::create_expired_option_market(self, ...))
6930        { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol); if !matches!(__v, crate::Value::Null) { return __v; } }
6931
6932        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createExpiredOptionMarket () is not supported yet".into()))));
6933
6934    Value::Null
6935}
6936
6937    fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
6938        let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
6939        let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
6940        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())]);
6941        {
6942                        let mut i: Value = Value::Int(0);
6943            let mut __for_first_138: bool = true;
6944            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) } {
6945            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);
6946            let mut endsWithSuffix: bool = ends_with(&currencyCode, &leverageSuffix);
6947            if endsWithSuffix {
6948                if !is_true(&checkBaseCoin) {
6949                    return Value::Bool(true);
6950                }  else {
6951                    // check if base currency is inside dict
6952                    let mut baseCurrencyCode: Value = replace_str(&currencyCode, &leverageSuffix, &Value::Str("".into()));
6953                    if (existingCurrencies != Value::Null) && (in_op(&existingCurrencies, &baseCurrencyCode)) {
6954                        return Value::Bool(true);
6955                    }
6956                }
6957            }
6958        }
6959        }
6960        return Value::Bool(false);
6961
6962    Value::Null
6963}
6964
6965    fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
6966        if (cost == Value::Null) {
6967            return Value::Null;
6968        }
6969        let mut market: Value = self.market(symbol);
6970        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()]);
6971
6972    Value::Null
6973}
6974
6975    fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
6976        if (price == Value::Null) {
6977            return Value::Null;
6978        }
6979        let mut market: Value = self.market(symbol);
6980        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()]);
6981        if (result.as_str() == Some("0")) {
6982            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));
6983            if (pricePrecision == Value::Null) {
6984                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()))));
6985            }
6986            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)));
6987        }
6988        return result;
6989
6990    Value::Null
6991}
6992
6993    fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
6994        if (amount == Value::Null) {
6995            return Value::Null;
6996        }
6997        let mut market: Value = self.market(symbol);
6998        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()]);
6999        if (result.as_str() == Some("0")) {
7000            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));
7001            if (amountPrecision == Value::Null) {
7002                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()))));
7003            }
7004            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)));
7005        }
7006        return result;
7007
7008    Value::Null
7009}
7010
7011    fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
7012        if (fee == Value::Null) {
7013            return Value::Null;
7014        }
7015        let mut market: Value = self.market(symbol);
7016        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()]);
7017
7018    Value::Null
7019}
7020
7021    fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
7022        let mut networkCode = get_arg(optional_args, 0, Value::Null);
7023        if (code == Value::Null) {
7024            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currencyToPrecision() requires a code argument".into()))));
7025        }
7026        let mut currency: Value = get_value(&self.currencies, &code);
7027        let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
7028        if (networkCode != Value::Null) {
7029            let mut networks: Value = self.safe_dict_k(currency, "networks", &[Value::Map({
7030    let mut m = indexmap::IndexMap::new();
7031    m
7032})]);
7033            let mut networkItem: Value = self.safe_dict(networks, networkCode, &[Value::Map({
7034    let mut m = indexmap::IndexMap::new();
7035    m
7036})]);
7037            precision = self.safe_value_k(networkItem, "precision", &[precision.clone()]);
7038        }
7039        if (precision == Value::Null) {
7040            return self.force_string(fee.clone());
7041        }  else {
7042            let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
7043            return self.decimal_to_precision(fee, roundingMode, precision, &[self.precisionMode.clone(), self.paddingMode.clone()]);
7044        }
7045
7046    Value::Null
7047}
7048
7049    fn force_string(&self, mut value: Value) -> Value {
7050        if !matches!(&value, Value::Str(_)) {
7051            return self.number_to_string(value.clone());
7052        }
7053        return value;
7054
7055    Value::Null
7056}
7057
7058    fn is_tick_precision(&self) -> Value {
7059        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64());
7060
7061    Value::Null
7062}
7063
7064    fn is_significant_precision(&self) -> Value {
7065        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::SIGNIFICANT_DIGITS).as_f64());
7066
7067    Value::Null
7068}
7069
7070    fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
7071        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7072        let mut value: Value = self.safe_string(obj, key, &[]);
7073        return self.parse_number(value, &[defaultNumber]);
7074
7075    Value::Null
7076}
7077
7078    fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
7079        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7080        let mut value: Value = self.safe_string_n(obj, arr, &[]);
7081        return self.parse_number(value, &[defaultNumber]);
7082
7083    Value::Null
7084}
7085
7086    fn parse_precision(&self, optional_args: &[Value]) -> Value {
7087        let mut precision = get_arg(optional_args, 0, Value::Null);
7088        /*
7089         * @ignore
7090         * @method
7091         * @param {string} precision The number of digits to the right of the decimal
7092         * @returns {string} a string number equal to 1e-precision
7093         */
7094        if (precision == Value::Null) {
7095            return Value::Null;
7096        }
7097        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 });
7098        if (precisionNumber.as_f64() == Some(0.0)) {
7099            return Value::Str("1".into());
7100        }
7101        if precisionNumber.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
7102            let mut parsedPrecision: Value = Value::Str("0.".into());
7103            {
7104                                let mut i: Value = Value::Int(0);
7105                let mut __for_first_139: bool = true;
7106                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) } {
7107                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7108            }
7109            }
7110            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("1".into())).into());
7111        }  else {
7112            let mut parsedPrecision: Value = Value::Str("1".into());
7113            {
7114                                let mut i: Value = Value::Int(0);
7115                let mut __for_first_140: bool = true;
7116                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) } {
7117                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7118            }
7119            }
7120            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7121        }
7122
7123    Value::Null
7124}
7125
7126    fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7127        /*
7128         * @ignore
7129         * @method
7130         * @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
7131         * @param {string} precision The number of digits to the right of the decimal
7132         * @returns {string} a string number equal to 1e-precision
7133         */
7134        if (precision == Value::Null) {
7135            return Value::Null;
7136        }
7137        if is_true(&crate::precise::Precise::stringGe(&precision, &Value::Str("0".into()))) {
7138            return self.parse_precision(&[precision.clone()]);
7139        }  else {
7140            let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7141            if (positivePrecisionString == Value::Null) {
7142                return Value::Null;
7143            }
7144            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 });
7145            let mut parsedPrecision: Value = Value::Str("1".into());
7146            {
7147                                let mut i: Value = Value::Int(0);
7148                let mut __for_first_141: bool = true;
7149                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) } {
7150                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7151            }
7152            }
7153            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7154        }
7155}
7156
7157    fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7158        let mut params = get_arg(optional_args, 0, Value::Map({
7159    let mut m = indexmap::IndexMap::new();
7160    m
7161}));
7162        let mut serverTime: Value = self.fetch_time(&[params]).await;
7163        let mut after: Value = self.milliseconds();
7164        if (serverTime == Value::Null) {
7165            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" loadTimeDifference() missing serverTime".into()))));
7166        }
7167        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 })); }
7168        return self.options.as_map().and_then(|__m| __m.get("timeDifference")).cloned().unwrap_or(Value::Null);
7169
7170    Value::Null
7171} }
7172
7173    fn implode_hostname(&self, mut url: Value) -> Value {
7174        return self.implode_params(url, Value::Map({
7175    let mut m = indexmap::IndexMap::new();
7176        m.insert("hostname".to_string(), self.hostname.clone());
7177    m
7178}));
7179
7180    Value::Null
7181}
7182
7183    fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7184        // async-virtual: try the derived exchange first
7185        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 {
7186            if !matches!(__v, crate::Value::Null) { return __v; }
7187        }
7188
7189        let mut params = get_arg(optional_args, 0, Value::Map({
7190    let mut m = indexmap::IndexMap::new();
7191    m
7192}));
7193        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)) {
7194            let mut market: Value = self.market(symbol.clone());
7195            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7196                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() supports contract markets only".into()))));
7197            }
7198            let mut tiers: Value = self.fetch_leverage_tiers(&[Value::from(vec![symbol.clone()])]).await;
7199            return self.safe_value(tiers, symbol, &[]);
7200        }  else {
7201            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() is not supported yet".into()))));
7202        }
7203
7204    Value::Null
7205} }
7206
7207    fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7208        let mut params = get_arg(optional_args, 0, Value::Map({
7209    let mut m = indexmap::IndexMap::new();
7210    m
7211}));
7212        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSubAccount() is not supported yet".into()))));
7213
7214    Value::Null
7215} }
7216
7217    fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7218        let mut currency = get_arg(optional_args, 0, Value::Null);
7219        let mut currencyResolved: Value = self.safe_currency(currencyId, &[currency]);
7220        return currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
7221
7222    Value::Null
7223}
7224
7225    fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7226        let mut symbol = 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("symbol".into()), &[symbol, since, limit, Value::Str("timestamp".into()), tail]);
7231
7232    Value::Null
7233}
7234
7235    fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7236        let mut code = 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        return self.filter_by_value_since_limit(array, Value::Str("currency".into()), &[code, since, limit, Value::Str("timestamp".into()), tail]);
7241
7242    Value::Null
7243}
7244
7245    fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7246        let mut symbols = get_arg(optional_args, 0, Value::Null);
7247        let mut since = get_arg(optional_args, 1, Value::Null);
7248        let mut limit = get_arg(optional_args, 2, Value::Null);
7249        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7250        let mut result: Value = self.filter_by_array(array, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
7251        return self.filter_by_since_limit(result, &[since, limit, Value::Str("timestamp".into()), tail]);
7252
7253    Value::Null
7254}
7255
7256    fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7257        let mut symbols = get_arg(optional_args, 0, Value::Null);
7258        let mut params = get_arg(optional_args, 1, Value::Map({
7259    let mut m = indexmap::IndexMap::new();
7260    m
7261}));
7262        //
7263        // the value of tickers is either a dict or a list
7264        //
7265        // dict
7266        //
7267        //     {
7268        //         'marketId1': { ... },
7269        //         'marketId2': { ... },
7270        //         ...
7271        //     }
7272        //
7273        // list
7274        //
7275        //     [
7276        //         { 'market': 'marketId1', ... },
7277        //         { 'market': 'marketId2', ... },
7278        //         ...
7279        //     ]
7280        //
7281        let mut results: Value = Value::from(vec![]);
7282        if (matches!(&pricesData, Value::Arr(_))) {
7283            {
7284                                let mut i: Value = Value::Int(0);
7285                let mut __for_first_142: bool = true;
7286                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) } {
7287                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()]);
7288                append_to_array(&mut results, priceData.clone());
7289            }
7290            }
7291        }  else {
7292            let mut marketIds: Value = object_keys(&pricesData);
7293            {
7294                                let mut i: Value = Value::Int(0);
7295                let mut __for_first_143: bool = true;
7296                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) } {
7297                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);
7298                let mut market: Value = self.safe_market(&[marketId.clone()]);
7299                let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market]), &[params.clone()]);
7300                append_to_array(&mut results, priceData);
7301            }
7302            }
7303        }
7304        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7305        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbolsNormalized]);
7306
7307    Value::Null
7308}
7309
7310    fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7311        let mut symbols = get_arg(optional_args, 0, Value::Null);
7312        let mut params = get_arg(optional_args, 1, Value::Map({
7313    let mut m = indexmap::IndexMap::new();
7314    m
7315}));
7316        //
7317        // the value of tickers is either a dict or a list
7318        //
7319        //
7320        // dict
7321        //
7322        //     {
7323        //         'marketId1': { ... },
7324        //         'marketId2': { ... },
7325        //         'marketId3': { ... },
7326        //         ...
7327        //     }
7328        //
7329        // list
7330        //
7331        //     [
7332        //         { 'market': 'marketId1', ... },
7333        //         { 'market': 'marketId2', ... },
7334        //         { 'market': 'marketId3', ... },
7335        //         ...
7336        //     ]
7337        //
7338        let mut results: Value = Value::from(vec![]);
7339        if (matches!(&tickers, Value::Arr(_))) {
7340            {
7341                                let mut i: Value = Value::Int(0);
7342                let mut __for_first_144: bool = true;
7343                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) } {
7344                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), &[]);
7345                let mut ticker: Value = self.extend(parsedTicker, &[params.clone()]);
7346                append_to_array(&mut results, ticker.clone());
7347            }
7348            }
7349        }  else {
7350            let mut marketIds: Value = object_keys(&tickers);
7351            {
7352                                let mut i: Value = Value::Int(0);
7353                let mut __for_first_145: bool = true;
7354                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) } {
7355                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);
7356                let mut market: Value = self.safe_market(&[marketId.clone()]);
7357                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market]);
7358                let mut ticker: Value = self.extend(parsed, &[params.clone()]);
7359                append_to_array(&mut results, ticker);
7360            }
7361            }
7362        }
7363        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7364        return self.filter_by_array_tickers(results, Value::Str("symbol".into()), &[symbolsNormalized]);
7365
7366    Value::Null
7367}
7368
7369    fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7370        let mut codes = get_arg(optional_args, 0, Value::Null);
7371        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7372        let mut params = get_arg(optional_args, 2, Value::Map({
7373    let mut m = indexmap::IndexMap::new();
7374    m
7375}));
7376        let mut result: Value = Value::from(vec![]);
7377        {
7378                        let mut i: Value = Value::Int(0);
7379            let mut __for_first_146: bool = true;
7380            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) } {
7381            let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7382            append_to_array(&mut result, address);
7383        }
7384        }
7385        if (codes != Value::Null) {
7386            result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[codes, Value::Bool(false)]);
7387        }
7388        if is_true(&indexed) {
7389            result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[Value::Null, indexed.clone()]);
7390        }
7391        return result;
7392
7393    Value::Null
7394}
7395
7396    fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7397        let mut market = get_arg(optional_args, 0, Value::Null);
7398        let mut interests: Value = Value::from(vec![]);
7399        {
7400                        let mut i: Value = Value::Int(0);
7401            let mut __for_first_147: bool = true;
7402            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) } {
7403            let mut row: Value = get_value(&response, &i);
7404            let mut row: Value = get_value(&response, &i);
7405            append_to_array(&mut interests, <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row, &[market.clone()]));
7406        }
7407        }
7408        return interests;
7409
7410    Value::Null
7411}
7412
7413    fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7414        // virtual-dispatch (static: DerivedExchange::parse_borrow_rate(self, ...))
7415        { 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; } }
7416
7417        let mut currency = get_arg(optional_args, 0, Value::Null);
7418        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowRate() is not supported yet".into()))));
7419
7420    Value::Null
7421}
7422
7423    fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7424        let mut result: Value = Value::from(vec![]);
7425        {
7426                        let mut i: Value = Value::Int(0);
7427            let mut __for_first_148: bool = true;
7428            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) } {
7429            let mut item: Value = get_value(&response, &i);
7430            let mut item: Value = get_value(&response, &i);
7431            let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item, &[]);
7432            append_to_array(&mut result, borrowRate);
7433        }
7434        }
7435        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
7436        return self.filter_by_currency_since_limit(sorted, &[code, since, limit]);
7437
7438    Value::Null
7439}
7440
7441    fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7442        let mut result: Value = Value::Map({
7443            let mut m = indexmap::IndexMap::new();
7444            m
7445        });
7446        {
7447                        let mut i: Value = Value::Int(0);
7448            let mut __for_first_149: bool = true;
7449            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) } {
7450            let mut item: Value = get_value(&info, &i);
7451            let mut item: Value = get_value(&info, &i);
7452            let mut borrowRate: Value = self.parse_isolated_borrow_rate(item, &[]);
7453            let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
7454            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), borrowRate); }
7455        }
7456        }
7457        return result;
7458
7459    Value::Null
7460}
7461
7462    fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7463        let mut market = get_arg(optional_args, 0, Value::Null);
7464        let mut since = get_arg(optional_args, 1, Value::Null);
7465        let mut limit = get_arg(optional_args, 2, Value::Null);
7466        let mut rates: Value = Value::from(vec![]);
7467        {
7468                        let mut i: Value = Value::Int(0);
7469            let mut __for_first_150: bool = true;
7470            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) } {
7471            let mut entry: Value = get_value(&response, &i);
7472            let mut entry: Value = get_value(&response, &i);
7473            append_to_array(&mut rates, <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry, &[market.clone()]));
7474        }
7475        }
7476        let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7477        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) });
7478        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7479
7480    Value::Null
7481}
7482
7483    fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7484        let mut market = get_arg(optional_args, 0, Value::Null);
7485        let mut delimiter = get_arg(optional_args, 1, Value::Null);
7486        let mut marketType = get_arg(optional_args, 2, Value::Null);
7487        let mut marketResolved: Value = self.safe_market(&[marketId, market, delimiter, marketType]);
7488        return marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7489
7490    Value::Null
7491}
7492
7493    fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7494        // virtual-dispatch (static: DerivedExchange::parse_funding_rate(self, ...))
7495        { 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; } }
7496
7497        let mut market = get_arg(optional_args, 0, Value::Null);
7498        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRate() is not supported yet".into()))));
7499
7500    Value::Null
7501}
7502
7503    fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7504        let mut symbols = get_arg(optional_args, 0, Value::Null);
7505        let mut fundingRates: Value = Value::Map({
7506            let mut m = indexmap::IndexMap::new();
7507            m
7508        });
7509        {
7510                        let mut i: Value = Value::Int(0);
7511            let mut __for_first_151: bool = true;
7512            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) } {
7513            let mut entry: Value = get_value(&response, &i);
7514            let mut entry: Value = get_value(&response, &i);
7515            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry, &[]);
7516            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7517                add_element_to_object(&mut fundingRates, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7518            }
7519        }
7520        }
7521        return self.index_by(self.filter_by_array(fundingRates, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]), Value::Str("symbol".into()));
7522
7523    Value::Null
7524}
7525
7526    fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7527        let mut market = get_arg(optional_args, 0, Value::Null);
7528        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLongShortRatio() is not supported yet".into()))));
7529
7530    Value::Null
7531}
7532
7533    fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7534        let mut market = get_arg(optional_args, 0, Value::Null);
7535        let mut since = get_arg(optional_args, 1, Value::Null);
7536        let mut limit = get_arg(optional_args, 2, Value::Null);
7537        let mut rates: Value = Value::from(vec![]);
7538        {
7539                        let mut i: Value = Value::Int(0);
7540            let mut __for_first_152: bool = true;
7541            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) } {
7542            let mut entry: Value = get_value(&response, &i);
7543            let mut entry: Value = get_value(&response, &i);
7544            append_to_array(&mut rates, self.parse_long_short_ratio(entry, &[market.clone()]));
7545        }
7546        }
7547        let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7548        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) });
7549        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7550
7551    Value::Null
7552}
7553
7554    fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7555        let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7556        //
7557        let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
7558        let mut triggerPriceStr: Value = Value::Null;
7559        let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7560        let mut stopLossPriceStr: Value = Value::Null;
7561        let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7562        let mut takeProfitPriceStr: Value = Value::Null;
7563        //
7564        let mut keysToOmit: Value = Value::from(vec![]);
7565        if (triggerPrice != Value::Null) {
7566            if is_true(&omitParams) {
7567                append_to_array(&mut keysToOmit, Value::Str("triggerPrice".into()));
7568                append_to_array(&mut keysToOmit, Value::Str("stopPrice".into()));
7569            }
7570            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 }));
7571        }
7572        if (stopLossPrice != Value::Null) {
7573            if is_true(&omitParams) {
7574                append_to_array(&mut keysToOmit, Value::Str("stopLossPrice".into()));
7575            }
7576            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 }));
7577        }
7578        if (takeProfitPrice != Value::Null) {
7579            if is_true(&omitParams) {
7580                append_to_array(&mut keysToOmit, Value::Str("takeProfitPrice".into()));
7581            }
7582            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 }));
7583        }
7584        let mut keysToOmitLength: f64 = ((keysToOmit.len() as i64) as f64);
7585        let mut paramsOmitted: Value = (if (keysToOmitLength > ((0i64) as f64)) { self.omit(params.clone(), keysToOmit, &[]) } else { params });
7586        return Value::from(vec![triggerPriceStr, stopLossPriceStr, takeProfitPriceStr, paramsOmitted]);
7587
7588    Value::Null
7589}
7590
7591    fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7592        let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7593        let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7594        /*
7595         * @ignore
7596         * @method
7597         * @returns {[string, object]} the trigger-direction value and omited params
7598         */
7599        let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7600        let mut exchangeSpecificDefined: bool = (exchangeSpecificKey != Value::Null) && (in_op(&params, &exchangeSpecificKey));
7601        let mut paramsOmitted: Value = (if (triggerDirection != Value::Null) { self.omit(params.clone(), Value::Str("triggerDirection".into()), &[]) } else { params });
7602        // throw exception if:
7603        // A) if provided value is not unified (support old "up/down" strings too)
7604        // B) if exchange specific "trigger direction key" (eg. "stopPriceSide") was not provided
7605        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) {
7606            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()))));
7607        }
7608        // if old format was provided, overwrite to new
7609        if (triggerDirection.as_str() == Some("up")) || (triggerDirection.as_str() == Some("above")) {
7610            triggerDirection = Value::Str("ascending".into());
7611        }  else if (triggerDirection.as_str() == Some("down")) || (triggerDirection.as_str() == Some("below")) {
7612            triggerDirection = Value::Str("descending".into());
7613        }
7614        return Value::from(vec![triggerDirection, paramsOmitted]);
7615
7616    Value::Null
7617}
7618
7619    fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7620        let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[]);
7621        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 });
7622        return Value::from(vec![isTrigger, paramsOmitted]);
7623
7624    Value::Null
7625}
7626
7627    fn is_trigger_order(&self, mut params: Value) -> Value {
7628        return self.handle_trigger_and_params(params);
7629
7630    Value::Null
7631}
7632
7633    fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7634        let mut params = get_arg(optional_args, 0, Value::Map({
7635    let mut m = indexmap::IndexMap::new();
7636    m
7637}));
7638        /*
7639         * @ignore
7640         * @method
7641         * @param {string} type Order type
7642         * @param {boolean} exchangeSpecificParam exchange specific postOnly
7643         * @param {object} [params] exchange specific params
7644         * @returns {boolean} true if a post only order, false otherwise
7645         */
7646        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7647        let mut postOnly: Value = self.safe_bool2(params, Value::Str("postOnly".into()), Value::Str("post_only".into()), &[Value::Bool(false)]);
7648        // we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
7649        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7650        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7651        let mut timeInForcePostOnly: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7652        if (postOnly.as_bool() != Some(true)) {
7653            postOnly = timeInForcePostOnly;
7654        }
7655        if (postOnly.as_bool() != Some(true)) {
7656            postOnly = exchangeSpecificParam;
7657        }
7658        if (postOnly.as_bool() == Some(true)) {
7659            if ioc || fok {
7660                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)));
7661            }  else if is_true(&isMarketOrder) {
7662                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7663            }  else {
7664                return Value::Bool(true);
7665            }
7666        }  else {
7667            return Value::Bool(false);
7668        }
7669
7670    Value::Null
7671}
7672
7673    fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7674        let mut params = get_arg(optional_args, 0, Value::Map({
7675    let mut m = indexmap::IndexMap::new();
7676    m
7677}));
7678        /*
7679         * @ignore
7680         * @method
7681         * @param {string} type Order type
7682         * @param {boolean} exchangeSpecificBoolean exchange specific postOnly
7683         * @param {object} [params] exchange specific params
7684         * @returns {Array}
7685         */
7686        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7687        let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
7688        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7689        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7690        let mut po: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7691        if (postOnly.as_bool() != Some(true)) {
7692            postOnly = po.clone();
7693        }
7694        if (postOnly.as_bool() != Some(true)) {
7695            postOnly = exchangeSpecificPostOnlyOption;
7696        }
7697        if (postOnly.as_bool() == Some(true)) {
7698            if ioc || fok {
7699                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)));
7700            }  else if is_true(&isMarketOrder) {
7701                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7702            }  else {
7703                let mut keysToOmit: Value = Value::Null;
7704                if matches!(&po, Value::Bool(true)) {
7705                    keysToOmit = Value::from(vec![Value::Str("timeInForce".into()), Value::Str("postOnly".into())]);
7706                }  else {
7707                    keysToOmit = Value::from(vec![Value::Str("postOnly".into())]);
7708                }
7709                let mut paramsOmitted: Value = self.omit(params.clone(), keysToOmit, &[]);
7710                return Value::from(vec![Value::Bool(true), paramsOmitted]);
7711            }
7712        }
7713        return Value::from(vec![Value::Bool(false), params]);
7714
7715    Value::Null
7716}
7717
7718    fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7719        let mut symbols = get_arg(optional_args, 0, Value::Null);
7720        let mut params = get_arg(optional_args, 1, Value::Map({
7721    let mut m = indexmap::IndexMap::new();
7722    m
7723}));
7724        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLastPrices() is not supported yet".into()))));
7725
7726    Value::Null
7727} }
7728
7729    fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7730        // async-virtual: try the derived exchange first
7731        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 {
7732            if !matches!(__v, crate::Value::Null) { return __v; }
7733        }
7734
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(" fetchTradingFees() is not supported yet".into()))));
7740
7741    Value::Null
7742} }
7743
7744    fn fetch_trading_fees_ws(&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(" fetchTradingFeesWs() is not supported yet".into()))));
7750
7751    Value::Null
7752} }
7753
7754    fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7755        let mut params = get_arg(optional_args, 0, Value::Map({
7756    let mut m = indexmap::IndexMap::new();
7757    m
7758}));
7759        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertCurrencies() is not supported yet".into()))));
7760
7761    Value::Null
7762} }
7763
7764    fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
7765        // virtual-dispatch (static: DerivedExchange::parse_open_interest(self, ...))
7766        { 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; } }
7767
7768        let mut market = get_arg(optional_args, 0, Value::Null);
7769        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOpenInterest () is not supported yet".into()))));
7770
7771    Value::Null
7772}
7773
7774    fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7775        let mut symbols = get_arg(optional_args, 0, Value::Null);
7776        let mut result: Value = Value::Map({
7777            let mut m = indexmap::IndexMap::new();
7778            m
7779        });
7780        {
7781                        let mut i: Value = Value::Int(0);
7782            let mut __for_first_153: bool = true;
7783            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) } {
7784            let mut entry: Value = get_value(&response, &i);
7785            let mut entry: Value = get_value(&response, &i);
7786            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[]);
7787            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7788                add_element_to_object(&mut result, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7789            }
7790        }
7791        }
7792        return self.filter_by_array(result, Value::Str("symbol".into()), &[symbols]);
7793
7794    Value::Null
7795}
7796
7797    fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7798        let mut market = get_arg(optional_args, 0, Value::Null);
7799        let mut since = get_arg(optional_args, 1, Value::Null);
7800        let mut limit = get_arg(optional_args, 2, Value::Null);
7801        let mut interests: Value = Value::from(vec![]);
7802        {
7803                        let mut i: Value = Value::Int(0);
7804            let mut __for_first_154: bool = true;
7805            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) } {
7806            let mut entry: Value = get_value(&response, &i);
7807            let mut entry: Value = get_value(&response, &i);
7808            let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[market.clone()]);
7809            append_to_array(&mut interests, interest);
7810        }
7811        }
7812        let mut sorted: Value = self.sort_by(interests, Value::Str("timestamp".into()), &[]);
7813        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
7814        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7815
7816    Value::Null
7817}
7818
7819    fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7820        // async-virtual: try the derived exchange first
7821        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 {
7822            if !matches!(__v, crate::Value::Null) { return __v; }
7823        }
7824
7825        let mut params = get_arg(optional_args, 0, Value::Map({
7826    let mut m = indexmap::IndexMap::new();
7827    m
7828}));
7829        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)) {
7830            self.load_markets(&[]).await;
7831            let mut market: Value = self.market(symbol);
7832            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7833            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7834                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports contract markets only".into()))));
7835            }
7836            let mut rates: Value = self.fetch_funding_rates(&[Value::from(vec![symbolResolved.clone()]), params]).await;
7837            let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
7838            if (rate == Value::Null) {
7839                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () returned no data for ".into())).into()), symbolResolved)));
7840            }  else {
7841                return rate;
7842            }
7843        }  else {
7844            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () is not supported yet".into()))));
7845        }
7846
7847    Value::Null
7848} }
7849
7850    fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7851        // async-virtual: try the derived exchange first
7852        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 {
7853            if !matches!(__v, crate::Value::Null) { return __v; }
7854        }
7855
7856        let mut params = get_arg(optional_args, 0, Value::Map({
7857    let mut m = indexmap::IndexMap::new();
7858    m
7859}));
7860        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)) {
7861            self.load_markets(&[]).await;
7862            let mut market: Value = self.market(symbol);
7863            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7864            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7865                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() supports contract markets only".into()))));
7866            }
7867            let mut rates: Value = self.fetch_funding_intervals(&[Value::from(vec![symbolResolved.clone()]), params]).await;
7868            let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
7869            if (rate == Value::Null) {
7870                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() returned no data for ".into())).into()), symbolResolved)));
7871            }  else {
7872                return rate;
7873            }
7874        }  else {
7875            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() is not supported yet".into()))));
7876        }
7877
7878    Value::Null
7879} }
7880
7881    fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7882        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7883        let mut since = get_arg(optional_args, 1, Value::Null);
7884        let mut limit = get_arg(optional_args, 2, Value::Null);
7885        let mut params = get_arg(optional_args, 3, Value::Map({
7886    let mut m = indexmap::IndexMap::new();
7887    m
7888}));
7889        /*
7890         * @method
7891         * @name exchange#fetchMarkOHLCV
7892         * @description fetches historical mark price candlestick data containing the open, high, low, and close price of a market
7893         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7894         * @param {string} timeframe the length of time each candle represents
7895         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7896         * @param {int} [limit] the maximum amount of candles to fetch
7897         * @param {object} [params] extra parameters specific to the exchange API endpoint
7898         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
7899         */
7900        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)) {
7901            let mut request: Value = Value::Map({
7902                let mut m = indexmap::IndexMap::new();
7903                    m.insert("price".to_string(), Value::Str("mark".into()));
7904                m
7905            });
7906            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7907        }  else {
7908            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkOHLCV () is not supported yet".into()))));
7909        }
7910} }
7911
7912    fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7913        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7914        let mut since = get_arg(optional_args, 1, Value::Null);
7915        let mut limit = get_arg(optional_args, 2, Value::Null);
7916        let mut params = get_arg(optional_args, 3, Value::Map({
7917    let mut m = indexmap::IndexMap::new();
7918    m
7919}));
7920        /*
7921         * @method
7922         * @name exchange#fetchIndexOHLCV
7923         * @description fetches historical index price candlestick data containing the open, high, low, and close price of a market
7924         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7925         * @param {string} timeframe the length of time each candle represents
7926         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7927         * @param {int} [limit] the maximum amount of candles to fetch
7928         * @param {object} [params] extra parameters specific to the exchange API endpoint
7929         * @returns {} A list of candles ordered as timestamp, open, high, low, close, undefined
7930         */
7931        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)) {
7932            let mut request: Value = Value::Map({
7933                let mut m = indexmap::IndexMap::new();
7934                    m.insert("price".to_string(), Value::Str("index".into()));
7935                m
7936            });
7937            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7938        }  else {
7939            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIndexOHLCV () is not supported yet".into()))));
7940        }
7941} }
7942
7943    fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7944        // async-virtual: try the derived exchange first
7945        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 {
7946            if !matches!(__v, crate::Value::Null) { return __v; }
7947        }
7948
7949        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7950        let mut since = get_arg(optional_args, 1, Value::Null);
7951        let mut limit = get_arg(optional_args, 2, Value::Null);
7952        let mut params = get_arg(optional_args, 3, Value::Map({
7953    let mut m = indexmap::IndexMap::new();
7954    m
7955}));
7956        /*
7957         * @method
7958         * @name exchange#fetchPremiumIndexOHLCV
7959         * @description fetches historical premium index price candlestick data containing the open, high, low, and close price of a market
7960         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7961         * @param {string} timeframe the length of time each candle represents
7962         * @param {int} [since] timestamp in ms of the earliest candle to fetch
7963         * @param {int} [limit] the maximum amount of candles to fetch
7964         * @param {object} [params] extra parameters specific to the exchange API endpoint
7965         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
7966         */
7967        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)) {
7968            let mut request: Value = Value::Map({
7969                let mut m = indexmap::IndexMap::new();
7970                    m.insert("price".to_string(), Value::Str("premiumIndex".into()));
7971                m
7972            });
7973            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7974        }  else {
7975            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".into()))));
7976        }
7977} }
7978
7979    fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
7980        let mut params = get_arg(optional_args, 0, Value::Map({
7981    let mut m = indexmap::IndexMap::new();
7982    m
7983}));
7984        /*
7985         * @ignore
7986         * @method
7987         * Must add timeInForce to this.options to use this method
7988         * @returns {string} returns the exchange specific value for timeInForce
7989         */
7990        let mut timeInForce: Value = self.safe_string_upper_k(params, "timeInForce", &[]); // supported values GTC, IOC, PO
7991        if (timeInForce != Value::Null) {
7992            let mut exchangeValue: Value = self.safe_string(self.options.as_map().and_then(|__m| __m.get("timeInForce")).cloned().unwrap_or(Value::Null), timeInForce.clone(), &[]);
7993            if (exchangeValue == Value::Null) {
7994                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()))));
7995            }
7996            return exchangeValue;
7997        }
7998        return Value::Null;
7999
8000    Value::Null
8001}
8002
8003    fn convert_type_to_account(&self, mut account: Value) -> Value {
8004        /*
8005         * @ignore
8006         * @method
8007         * Must add accountsByType to this.options to use this method
8008         * @param {string} account key for account name in this.options['accountsByType']
8009         * @returns the exchange specific account name or the isolated margin id for transfers
8010         */
8011        let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
8012    let mut m = indexmap::IndexMap::new();
8013    m
8014})]);
8015        let mut lowercaseAccount: Value = to_lower(&account);
8016        if (in_op(&accountsByType, &lowercaseAccount)) {
8017            return get_value(&accountsByType, &lowercaseAccount);
8018        }
8019        let mut markets: Value = self.markets.clone();
8020        let mut marketsById: Value = self.markets_by_id.clone();
8021        if ((markets != Value::Null) && (in_op(&markets, &account))) || ((marketsById != Value::Null) && (in_op(&marketsById, &account))) {
8022            let mut market: Value = self.market(account.clone());
8023            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
8024        }  else {
8025            return account;
8026        }
8027
8028    Value::Null
8029}
8030
8031    fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
8032        let mut options = get_arg(optional_args, 0, Value::from(vec![]));
8033        /*
8034         * @ignore
8035         * @method
8036         * @param {string} methodName the name of the method that the argument is being checked for
8037         * @param {string} argument the argument's actual value provided
8038         * @param {string} argumentName the name of the argument being checked (for logging purposes)
8039         * @param {string[]} options a list of options that the argument can be
8040         * @returns {undefined}
8041         */
8042        let mut optionsLength: f64 = ((options.len() as i64) as f64);
8043        if (argument == Value::Null) || ((optionsLength > ((0i64) as f64)) && (!(self.in_array(argument, options.clone()).as_bool() == Some(true)))) {
8044            let mut messageOptions: Value = join(&options, &Value::Str(", ".into()));
8045            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());
8046            if (messageOptions.as_str() != Some("")) {
8047                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());
8048            }
8049            panic!("{}", crate::exchange_errors::arguments_required(message));
8050        }
8051}
8052
8053    fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
8054        /*
8055         * @ignore
8056         * @method
8057         * @param {string} symbol unified symbol of the market
8058         * @param {string} methodName name of the method that requires a symbol
8059         * @param {string} marginMode is either 'isolated' or 'cross'
8060         */
8061        if (marginMode.as_str() == Some("isolated")) && (symbol == Value::Null) {
8062            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()))));
8063        }  else if (marginMode.as_str() == Some("cross")) && (symbol != Value::Null) {
8064            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()))));
8065        }
8066}
8067
8068    fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
8069        let mut codes = get_arg(optional_args, 0, Value::Null);
8070        let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
8071        /*
8072         * @ignore
8073         * @method
8074         * @param {object[]|object} response unparsed response from the exchange
8075         * @param {string[]|undefined} codes the unified currency codes to fetch transactions fees for, returns all currencies when undefined
8076         * @param {str} currencyIdKey *should only be undefined when response is a dictionary* the object key that corresponds to the currency id
8077         * @returns {object} objects with withdraw and deposit fees, indexed by currency codes
8078         */
8079        let mut depositWithdrawFees: Value = Value::Map({
8080            let mut m = indexmap::IndexMap::new();
8081            m
8082        });
8083        let mut isArray: bool = matches!(&response, Value::Arr(_));
8084        let mut responseKeys: Value = response.clone();
8085        if !isArray {
8086            responseKeys = object_keys(&response);
8087        }
8088        {
8089                        let mut i: Value = Value::Int(0);
8090            let mut __for_first_155: bool = true;
8091            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) } {
8092            let mut entry: Value = get_value(&responseKeys, &i);
8093            let mut entry: Value = get_value(&responseKeys, &i);
8094            let mut dictionary: Value = (if isArray { entry.clone() } else { get_value(&response, &entry) });
8095            let mut currencyId: Value = entry;
8096            if isArray {
8097                currencyId = (if (currencyIdKey == Value::Null) { Value::Null } else { self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]) });
8098            }
8099            let mut currency: Value = self.safe_currency(currencyId, &[]);
8100            let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
8101            if (codes == Value::Null) || self.in_array(code.clone(), codes.clone()).as_bool() == Some(true) {
8102                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])); }
8103            }
8104        }
8105        }
8106        return depositWithdrawFees;
8107
8108    Value::Null
8109}
8110
8111    fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8112        // virtual-dispatch (static: DerivedExchange::parse_deposit_withdraw_fee(self, ...))
8113        { 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; } }
8114
8115        let mut currency = get_arg(optional_args, 0, Value::Null);
8116        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositWithdrawFee() is not supported yet".into()))));
8117
8118    Value::Null
8119}
8120
8121    fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8122        return Value::Map({
8123    let mut m = indexmap::IndexMap::new();
8124        m.insert("info".to_string(), info);
8125        m.insert("withdraw".to_string(), Value::Map({
8126    let mut m = indexmap::IndexMap::new();
8127        m.insert("fee".to_string(), Value::Null);
8128        m.insert("percentage".to_string(), Value::Null);
8129    m
8130}));
8131        m.insert("deposit".to_string(), Value::Map({
8132    let mut m = indexmap::IndexMap::new();
8133        m.insert("fee".to_string(), Value::Null);
8134        m.insert("percentage".to_string(), Value::Null);
8135    m
8136}));
8137        m.insert("networks".to_string(), Value::Map({
8138    let mut m = indexmap::IndexMap::new();
8139    m
8140}));
8141    m
8142});
8143
8144    Value::Null
8145}
8146
8147    fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8148        let mut currency = get_arg(optional_args, 0, Value::Null);
8149        let __currency_empty = indexmap::IndexMap::new();
8150        let currency = currency.as_map().unwrap_or(&__currency_empty);
8151        /*
8152         * @ignore
8153         * @method
8154         * @description Takes a depositWithdrawFee structure and assigns the default values for withdraw and deposit
8155         * @param {object} fee A deposit withdraw fee structure
8156         * @param {object} currency A currency structure, the response from this.currency ()
8157         * @returns {object} A deposit withdraw fee structure
8158         */
8159        let mut networkKeys: Value = object_keys(&crate::value::get_value_k(&fee, "networks"));
8160        let mut numNetworks: f64 = ((networkKeys.len() as i64) as f64);
8161        if (numNetworks == 1.0) {
8162            { 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); };
8163            { 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); };
8164            return fee;
8165        }
8166        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 });
8167        {
8168                        let mut i: Value = Value::Int(0);
8169            let mut __for_first_156: bool = true;
8170            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 } {
8171            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);
8172            if (network.as_str() == currencyCode.as_str()) {
8173                { 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); };
8174                { 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); };
8175            }
8176        }
8177        }
8178        return fee;
8179
8180    Value::Null
8181}
8182
8183    fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8184        // virtual-dispatch (static: DerivedExchange::parse_income(self, ...))
8185        { 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; } }
8186
8187        let mut market = get_arg(optional_args, 0, Value::Null);
8188        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIncome () is not supported yet".into()))));
8189
8190    Value::Null
8191}
8192
8193    fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8194        let mut market = get_arg(optional_args, 0, Value::Null);
8195        let mut since = get_arg(optional_args, 1, Value::Null);
8196        let mut limit = get_arg(optional_args, 2, Value::Null);
8197        /*
8198         * @ignore
8199         * @method
8200         * @description parses funding fee info from exchange response
8201         * @param {object[]} incomes each item describes once instance of currency being received or paid
8202         * @param {object} market ccxt market
8203         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
8204         * @param {int} [limit] limits the number of items in the response
8205         * @returns {object[]} an array of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure}
8206         */
8207        let mut result: Value = Value::from(vec![]);
8208        {
8209                        let mut i: Value = Value::Int(0);
8210            let mut __for_first_157: bool = true;
8211            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) } {
8212            let mut entry: Value = get_value(&incomes, &i);
8213            let mut entry: Value = get_value(&incomes, &i);
8214            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry, &[market.clone()]);
8215            append_to_array(&mut result, parsed);
8216        }
8217        }
8218        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8219        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8220        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8221
8222    Value::Null
8223}
8224
8225    fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8226        let mut symbols = get_arg(optional_args, 0, Value::Null);
8227        /*
8228         * @param {string[]|undefined} symbols list of unified symbols (first element selects the market)
8229         * @returns {MarketInterface|undefined} market structure for the first symbol, or undefined if symbols is undefined
8230         * Overloads: non-null `string[]` input yields `MarketInterface`; optional input yields `Market`.
8231         */
8232        if (symbols == Value::Null) {
8233            return Value::Null;
8234        }
8235        let mut firstMarket: Value = self.safe_string(symbols, Value::Int(0), &[]);
8236        if (firstMarket == Value::Null) {
8237            return Value::Null;
8238        }
8239        let mut market: Value = self.market(firstMarket);
8240        return market;
8241
8242    Value::Null
8243}
8244
8245    fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8246        let mut market = get_arg(optional_args, 0, Value::Null);
8247        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
8248        let mut since = get_arg(optional_args, 2, Value::Null);
8249        let mut limit = get_arg(optional_args, 3, Value::Null);
8250        let mut results: Value = Value::from(vec![]);
8251        {
8252                        let mut i: Value = Value::Int(0);
8253            let mut __for_first_158: bool = true;
8254            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) } {
8255            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()]));
8256        }
8257        }
8258        return results;
8259
8260    Value::Null
8261}
8262
8263    fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8264        let mut code = get_arg(optional_args, 0, Value::Null);
8265        let mut since = get_arg(optional_args, 1, Value::Null);
8266        let mut limit = get_arg(optional_args, 2, Value::Null);
8267        let mut params = get_arg(optional_args, 3, Value::Map({
8268    let mut m = indexmap::IndexMap::new();
8269    m
8270}));
8271        /*
8272         * @method
8273         * @name exchange#fetchTransactions
8274         * @deprecated
8275         * @description *DEPRECATED* use fetchDepositsWithdrawals instead
8276         * @param {string} code unified currency code for the currency of the deposit/withdrawals, default is undefined
8277         * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
8278         * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
8279         * @param {object} [params] extra parameters specific to the exchange API endpoint
8280         * @returns {object} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
8281         */
8282        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)) {
8283            return self.fetch_deposits_withdrawals(&[code, since, limit, params]).await;
8284        }  else {
8285            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactions () is not supported yet".into()))));
8286        }
8287} }
8288
8289    fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8290        let mut values = get_arg(optional_args, 0, Value::Null);
8291        return self.to_array(self.filter_by_array(objects, key, &[values, Value::Bool(false)]));
8292
8293    Value::Null
8294}
8295
8296    fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8297        let mut values = get_arg(optional_args, 0, Value::Null);
8298        return self.index_by(self.filter_by_array(objects, key.clone(), &[values, Value::Bool(false)]), key);
8299
8300    Value::Null
8301}
8302
8303    fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8304        let mut values = get_arg(optional_args, 0, Value::Null);
8305        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8306        return self.filter_by_array(objects, key, &[values, indexed]);
8307
8308    Value::Null
8309}
8310
8311    fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8312        let mut res: Value = Value::Map({
8313            let mut m = indexmap::IndexMap::new();
8314            m
8315        });
8316        if let Value::Dict(__d) = &mut res { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
8317    let mut m = indexmap::IndexMap::new();
8318    m
8319})); }
8320        add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data);
8321        return res;
8322
8323    Value::Null
8324}
8325
8326    fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8327        let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8328        let mut params = get_arg(optional_args, 1, Value::Map({
8329    let mut m = indexmap::IndexMap::new();
8330    m
8331}));
8332        let mut newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable = self.handle_option_integer_and_params(params, method, Value::Str("maxEntriesPerRequest".into()), &[]);
8333        let mut newMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8334        let mut paramsMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8335        let mut maxEntriesPerRequestOption: Value = (if (newMaxEntriesPerRequest != Value::Null) { newMaxEntriesPerRequest } else { maxEntriesPerRequest });
8336        let mut maxEntriesPerRequestResolved: Value = (if (maxEntriesPerRequestOption == Value::Null) { Value::Int(1000) } else { maxEntriesPerRequestOption }); // default to 1000
8337        return Value::from(vec![maxEntriesPerRequestResolved, paramsMaxEntriesPerRequest]);
8338
8339    Value::Null
8340}
8341
8342    fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8343        let mut symbol = get_arg(optional_args, 0, Value::Null);
8344        let mut since = get_arg(optional_args, 1, Value::Null);
8345        let mut limit = get_arg(optional_args, 2, Value::Null);
8346        let mut params = get_arg(optional_args, 3, Value::Map({
8347    let mut m = indexmap::IndexMap::new();
8348    m
8349}));
8350        let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8351        let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8352        let mut maxCalls: Value = Value::Int(10);
8353        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8354        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8355        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8356        let mut maxRetries: Value = Value::Int(3);
8357        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8358        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8359        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8360        let mut paginationDirectionparamsPaginationDirectionVariable = self.handle_option_and_params(paramsMaxRetries, method.clone(), Value::Str("paginationDirection".into()), &[Value::Str("backward".into())]);
8361        let mut paginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8362        let mut paramsPaginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8363        let mut paginationTimestamp: Value = Value::Null;
8364        let mut removeRepeatedOptionparamsRemoveRepeatedVariable = self.handle_option_and_params(paramsPaginationDirection, method.clone(), Value::Str("removeRepeated".into()), &[removeRepeated]);
8365        let mut removeRepeatedOption: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8366        let mut paramsRemoveRepeated: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8367        let mut calls: Value = Value::Int(0);
8368        let mut result: Value = Value::from(vec![]);
8369        let mut errors: Value = Value::Int(0);
8370        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
8371        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsRemoveRepeated]);
8372        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8373        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8374        if (paginationDirection.as_str() == Some("forward")) {
8375            if (since == Value::Null) {
8376                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" pagination requires a since argument when paginationDirection set to forward".into()))));
8377            }
8378            paginationTimestamp = since.clone();
8379        }
8380        while (calls.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN)) {
8381            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 });
8382            {
8383                if (paginationDirection.as_str() == Some("backward")) {
8384                    // do it backwards, starting from the last
8385                    // UNTIL filtering is required in order to work
8386                    if (paginationTimestamp != Value::Null) {
8387                        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 }));
8388                    }
8389                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (Value::Null).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8390                    let mut responseLength: Value = get_array_length(&response);
8391                    if is_true(&self.verbose) {
8392                        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());
8393                        if (paginationTimestamp != Value::Null) {
8394                            backwardMessage = Value::Str(format!("{}{}", backwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8395                        }
8396                        self.log(backwardMessage);
8397                    }
8398                    if (responseLength.as_f64() == Some(0.0)) {
8399                        break;
8400                    }
8401                    errors = Value::Int(0);
8402                    result = self.array_concat(result.clone(), response.clone());
8403                    let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
8404                    paginationTimestamp = self.safe_integer2(firstElement, Value::Str("timestamp".into()), Value::Int(0), &[]);
8405                    if (paginationTimestamp == Value::Null) {
8406                        break;
8407                    }
8408                    if (since != Value::Null) && (paginationTimestamp.as_f64().unwrap_or(f64::NAN) <= since.as_f64().unwrap_or(f64::NAN)) {
8409                        break;
8410                    }
8411                }  else {
8412                    // do it forwards, starting from the since
8413                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paginationTimestamp).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8414                    let mut responseLength: Value = get_array_length(&response);
8415                    if is_true(&self.verbose) {
8416                        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());
8417                        if (paginationTimestamp != Value::Null) {
8418                            forwardMessage = Value::Str(format!("{}{}", forwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8419                        }
8420                        self.log(forwardMessage);
8421                    }
8422                    if (responseLength.as_f64() == Some(0.0)) {
8423                        break;
8424                    }
8425                    errors = Value::Int(0);
8426                    result = self.array_concat(result.clone(), response.clone());
8427                    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 }), &[]);
8428                    let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[Value::Int(0)]);
8429                    if (lastTimestamp == Value::Null) {
8430                        break;
8431                    }
8432                    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 });
8433                    paginationTimestamp = nextPaginationTimestamp.clone();
8434                    if (until != Value::Null) && (nextPaginationTimestamp.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8435                        break;
8436                    }
8437                }
8438            }
8439        }
8440        let mut uniqueResults: Value = result.clone();
8441        if is_true(&removeRepeatedOption) {
8442            uniqueResults = self.remove_repeated_elements_from_array(result, &[]);
8443        }
8444        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8445        let mut sortedRes: Value = self.sort_by(uniqueResults, key.clone(), &[]);
8446        return self.filter_by_since_limit(sortedRes, &[since, limit, key]);
8447
8448    Value::Null
8449} }
8450
8451    fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8452        let mut symbol = get_arg(optional_args, 0, Value::Null);
8453        let mut since = get_arg(optional_args, 1, Value::Null);
8454        let mut limit = get_arg(optional_args, 2, Value::Null);
8455        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8456        let mut params = get_arg(optional_args, 4, Value::Map({
8457    let mut m = indexmap::IndexMap::new();
8458    m
8459}));
8460        let mut maxRetries: Value = Value::Int(3);
8461        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8462        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8463        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8464        let mut errors: Value = Value::Int(0);
8465        while is_less_than_or_equal(&errors, &maxRetriesOption) {
8466            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8467                if ((timeframe != Value::Null) && (timeframe.as_str() != Some(""))) && (method.as_str() != Some("fetchFundingRateHistory")) {
8468                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8469                }  else {
8470                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8471                }
8472             #[allow(unreachable_code)] { Value::Null }})).await;
8473match _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); 
8474                if matches!(&e, Value::Str(__s) if __s.contains("[RateLimitExceeded]")) {
8475                    panic!("{}", e);
8476                }
8477                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 });
8478                if errors.as_f64().unwrap_or(f64::NAN) > maxRetriesOption.as_f64().unwrap_or(f64::NAN) {
8479                    panic!("{}", e);
8480                }
8481             } }
8482        }
8483        return Value::from(vec![]);
8484
8485    Value::Null
8486} }
8487
8488    fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8489        let mut symbol = get_arg(optional_args, 0, Value::Null);
8490        let mut since = get_arg(optional_args, 1, Value::Null);
8491        let mut limit = get_arg(optional_args, 2, Value::Null);
8492        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8493        let mut params = get_arg(optional_args, 4, Value::Map({
8494    let mut m = indexmap::IndexMap::new();
8495    m
8496}));
8497        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8498        let mut maxCalls: Value = Value::Int(10);
8499        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8500        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8501        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8502        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsPaginationCalls]);
8503        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8504        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8505        // paginationDirection is only relevant to fetchPaginatedCallDynamic/Cursor; deterministic
8506        // pagination always walks forward internally, so strip it here to avoid leaking an
8507        // unrecognized param into the underlying exchange request (e.g. binance -1104 errors)
8508        let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("paginationDirection".into()), &[]);
8509        let mut current: Value = self.milliseconds();
8510        let mut tasks: Value = Value::from(vec![]);
8511        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 });
8512        let mut maxEntriesPerRequestValue: Value = self.require_value(maxEntriesPerRequestOption, &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".into())]);
8513        let mut step: Value = multiply(&time, &maxEntriesPerRequestValue);
8514        let mut until: Value = self.safe_integer2(paramsOmitted.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]); // do not omit it here
8515        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 });
8516        if (since != Value::Null) {
8517            if (until != Value::Null) {
8518                // the recent-window floor below would jump past a fully-historical [ since, until ]
8519                // range and return an empty result - requiredCalls is validated against maxCalls
8520                // further down, so anchoring at since directly is safe here,
8521                // see https://github.com/ccxt/ccxt/issues/26252
8522                currentSince = since.clone();
8523            }  else {
8524                currentSince = crate::runtime::Math::max(&currentSince, &since);
8525            }
8526        }  else {
8527            currentSince = crate::runtime::Math::max(&currentSince, &Value::Int(1241440531000)); // avoid timestamps older than 2009
8528        }
8529        if (until != Value::Null) {
8530            if (since == Value::Null) {
8531                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".into()))));
8532            }
8533            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 }));
8534            if requiredCalls.as_f64().unwrap_or(f64::NAN) > maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8535                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))));
8536            }
8537        }
8538        {
8539                        let mut i: Value = Value::Int(0);
8540            let mut __for_first_159: bool = true;
8541            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) } {
8542            if (until != Value::Null) && (currentSince.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8543                break;
8544            }
8545            if currentSince.as_f64().unwrap_or(f64::NAN) >= current.as_f64().unwrap_or(f64::NAN) {
8546                break;
8547            }
8548            append_to_array(&mut tasks, self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequestValue.clone(), timeframe.clone(), paramsOmitted.clone()]).await);
8549            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 });
8550        }
8551        }
8552        let mut results: Value = promise_all(&tasks).await;
8553        let mut result: Value = Value::from(vec![]);
8554        {
8555                        let mut i: Value = Value::Int(0);
8556            let mut __for_first_160: bool = true;
8557            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) } {
8558            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));
8559        }
8560        }
8561        let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result, &[]);
8562        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8563        return self.filter_by_since_limit(uniqueResults, &[since, limit, key]);
8564
8565    Value::Null
8566} }
8567
8568// the 'symbol' slot is forwarded to `this[method]` untouched and is only compared against
8569// undefined here, so fetchPositions/fetchPositionsHistory legitimately pass a symbol list
8570    fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8571        let mut symbol = get_arg(optional_args, 0, Value::Null);
8572        let mut since = get_arg(optional_args, 1, Value::Null);
8573        let mut limit = get_arg(optional_args, 2, Value::Null);
8574        let mut params = get_arg(optional_args, 3, Value::Map({
8575    let mut m = indexmap::IndexMap::new();
8576    m
8577}));
8578        let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8579        let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8580        let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8581        let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8582        let mut maxCalls: Value = Value::Int(10);
8583        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8584        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8585        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8586        let mut maxRetries: Value = Value::Int(3);
8587        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8588        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8589        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8590        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8591        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8592        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8593        let mut cursorValue: Value = Value::Null;
8594        let mut i: Value = Value::Int(0);
8595        let mut errors: Value = Value::Int(0);
8596        let mut result: Value = Value::from(vec![]);
8597        let mut timeframe: Value = self.safe_string_k(paramsMaxEntriesPerRequest.clone(), "timeframe", &[]);
8598        let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("timeframe".into()), &[]); // reading the timeframe from the method arguments to avoid changing the signature
8599        while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8600            {
8601                if (cursorValue != Value::Null) {
8602                    if (cursorIncrement != Value::Null) {
8603                        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 });
8604                    }
8605                    add_element_to_object(&mut paramsOmitted, &cursorSent, cursorValue.clone());
8606                }
8607                let mut response: Value = Value::Null;
8608                if (method.as_str() == Some("fetchAccounts")) {
8609                    response = self.call_dynamic_checked(method.clone(), vec![(paramsOmitted).clone()]).await;
8610                }  else if (method.as_str() == Some("getLeverageTiersPaginated")) || (method.as_str() == Some("fetchPositions")) {
8611                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paramsOmitted).clone()]).await;
8612                }  else if (method.as_str() == Some("fetchOpenInterestHistory")) {
8613                    if !matches!(&symbol, Value::Str(_)) {
8614                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".into()))));
8615                    }
8616                    if (timeframe == Value::Null) {
8617                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".into()))));
8618                    }
8619                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8620                }  else {
8621                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8622                }
8623                errors = Value::Int(0);
8624                if (response == Value::Null) {
8625                    panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() returned empty response".into()))));
8626                }
8627                let mut responseLength: Value = Value::Int(response.len() as i64);
8628                if is_true(&self.verbose) {
8629                    let mut cursorString: Value = (if (cursorValue == Value::Null) { Value::Str("".into()) } else { cursorValue.clone() });
8630                    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 }));
8631                    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);
8632                    self.log(cursorMessage);
8633                }
8634                if (responseLength.as_f64() == Some(0.0)) {
8635                    break;
8636                }
8637                if (response != Value::Null) {
8638                    result = self.array_concat(result.clone(), response.clone());
8639                }
8640                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 }), &[]);
8641                // cursorValue = this.safeValue (last['info'], cursorReceived);
8642                cursorValue = Value::Null; // search for the cursor
8643                {
8644                                        let mut j: Value = Value::Int(0);
8645                    let mut __for_first_161: bool = true;
8646                    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) } {
8647                    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 });
8648                    let mut entry: Value = self.safe_dict(response.clone(), index, &[]);
8649                    let mut info: Value = self.safe_dict_k(entry, "info", &[]);
8650                    let mut cursor: Value = (if (cursorReceived == Value::Null) { Value::Null } else { self.safe_value(info, cursorReceived.clone(), &[]) });
8651                    if (cursor != Value::Null) {
8652                        cursorValue = cursor;
8653                        break;
8654                    }
8655                }
8656                }
8657                if (cursorValue == Value::Null) {
8658                    break;
8659                }
8660                let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[]);
8661                if (since == Value::Null) {
8662                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a since argument".into()))));
8663                }
8664                if (lastTimestamp != Value::Null) && lastTimestamp.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
8665                    break;
8666                }
8667            }
8668            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 });
8669        }
8670        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8671        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8672        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8673
8674    Value::Null
8675} }
8676
8677    fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8678        let mut symbol = get_arg(optional_args, 0, Value::Null);
8679        let mut since = get_arg(optional_args, 1, Value::Null);
8680        let mut limit = get_arg(optional_args, 2, Value::Null);
8681        let mut params = get_arg(optional_args, 3, Value::Map({
8682    let mut m = indexmap::IndexMap::new();
8683    m
8684}));
8685        let mut pageKey = get_arg(optional_args, 4, Value::Null);
8686        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8687        let mut maxCalls: Value = Value::Int(10);
8688        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8689        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8690        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8691        let mut maxRetries: Value = Value::Int(3);
8692        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8693        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8694        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8695        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8696        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8697        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8698        let mut i: Value = Value::Int(0);
8699        let mut errors: Value = Value::Int(0);
8700        let mut result: Value = Value::from(vec![]);
8701        while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8702            {
8703                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 }));
8704                let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8705                errors = Value::Int(0);
8706                let mut responseLength: Value = get_array_length(&response);
8707                if is_true(&self.verbose) {
8708                    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 })));
8709                    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());
8710                    self.log(incrementalMessage);
8711                }
8712                if (responseLength.as_f64() == Some(0.0)) {
8713                    break;
8714                }
8715                result = self.array_concat(result.clone(), response);
8716            }
8717            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 });
8718        }
8719        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8720        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8721        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8722
8723    Value::Null
8724} }
8725
8726    fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
8727        let mut first: Value = self.safe_value(result.clone(), Value::Int(0), &[]);
8728        if (first != Value::Null) {
8729            if (in_op(&first, &Value::Str("timestamp".into()))) {
8730                return self.sort_by(result.clone(), Value::Str("timestamp".into()), &[Value::Bool(true)]);
8731            }
8732            if (in_op(&first, &Value::Str("id".into()))) {
8733                return self.sort_by(result.clone(), Value::Str("id".into()), &[Value::Bool(true)]);
8734            }
8735        }
8736        return result;
8737
8738    Value::Null
8739}
8740
8741    fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
8742        let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
8743        let mut uniqueDic: Value = Value::Map({
8744            let mut m = indexmap::IndexMap::new();
8745            m
8746        });
8747        let mut uniqueResult: Value = Value::from(vec![]);
8748        {
8749                        let mut i: Value = Value::Int(0);
8750            let mut __for_first_162: bool = true;
8751            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) } {
8752            let mut entry: Value = get_value(&input, &i);
8753            let mut entry: Value = get_value(&input, &i);
8754            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", &[]) });
8755            if (uniqValue != Value::Null) && !(in_op(&uniqueDic, &uniqValue)) {
8756                if let Value::Dict(__d) = &mut uniqueDic { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&uniqValue), Value::Int(1)); }
8757                append_to_array(&mut uniqueResult, entry);
8758            }
8759        }
8760        }
8761        let mut valuesLength: f64 = ((uniqueResult.len() as i64) as f64);
8762        if valuesLength > ((0i64) as f64) {
8763            return uniqueResult;
8764        }
8765        return input;
8766
8767    Value::Null
8768}
8769
8770    fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
8771        let mut uniqueResult: Value = Value::Map({
8772            let mut m = indexmap::IndexMap::new();
8773            m
8774        });
8775        {
8776                        let mut i: Value = Value::Int(0);
8777            let mut __for_first_163: bool = true;
8778            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) } {
8779            let mut entry: Value = get_value(&input, &i);
8780            let mut entry: Value = get_value(&input, &i);
8781            let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
8782            if (id == Value::Null) {
8783                let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
8784                let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
8785                let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
8786                let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
8787                // unique trade identifier
8788                if (timestamp == Value::Null) {
8789                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" removeRepeatedTradesFromArray() missing timestamp".into()))));
8790                }
8791                // optional parts are appended only when present, separators keep positions distinct
8792                id = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("t_".into()), to_string_val(&timestamp)).into()), Value::Str("_".into())).into());
8793                if (side != Value::Null) {
8794                    id = Value::Str(format!("{}{}", id, side).into());
8795                }
8796                id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
8797                if (price != Value::Null) {
8798                    id = Value::Str(format!("{}{}", id, price).into());
8799                }
8800                id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
8801                if (amount != Value::Null) {
8802                    id = Value::Str(format!("{}{}", id, amount).into());
8803                }
8804            }
8805            if (id != Value::Null) && !(in_op(&uniqueResult, &id)) {
8806                if let Value::Dict(__d) = &mut uniqueResult { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&id), entry); }
8807            }
8808        }
8809        }
8810        let mut values: Value = object_values(&uniqueResult);
8811        return values;
8812
8813    Value::Null
8814}
8815
8816    fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
8817        let mut keys: Value = object_keys(&dict);
8818        let mut newDict: Value = Value::Map({
8819            let mut m = indexmap::IndexMap::new();
8820            m
8821        });
8822        {
8823                        let mut i: Value = Value::Int(0);
8824            let mut __for_first_164: bool = true;
8825            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) } {
8826            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);
8827            if !(self.in_array(key.clone(), removeKeys.clone()).as_bool() == Some(true)) {
8828                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)); }
8829            }
8830        }
8831        }
8832        return newDict;
8833
8834    Value::Null
8835}
8836
8837    fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
8838        let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
8839        let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]);
8840        if (until != Value::Null) {
8841            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 }))); }
8842        }
8843        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 });
8844        return Value::from(vec![request, paramsOmitted]);
8845
8846    Value::Null
8847}
8848
8849    fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
8850        let mut market = get_arg(optional_args, 0, Value::Null);
8851        let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
8852        if (symbol == Value::Null) {
8853            symbol = self.safe_string_k(market, "symbol", &[]);
8854        }
8855        return self.extend(interest.clone(), &[Value::Map({
8856    let mut m = indexmap::IndexMap::new();
8857        m.insert("symbol".to_string(), symbol);
8858        m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
8859        m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
8860        m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
8861        m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
8862        m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
8863        m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
8864        m.insert("info".to_string(), self.safe_value_k(interest, "info", &[]));
8865    m
8866})]);
8867
8868    Value::Null
8869}
8870
8871    fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
8872        // virtual-dispatch (static: DerivedExchange::parse_liquidation(self, ...))
8873        { 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; } }
8874
8875        let mut market = get_arg(optional_args, 0, Value::Null);
8876        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLiquidation () is not supported yet".into()))));
8877
8878    Value::Null
8879}
8880
8881    fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
8882        let mut market = get_arg(optional_args, 0, Value::Null);
8883        let mut since = get_arg(optional_args, 1, Value::Null);
8884        let mut limit = get_arg(optional_args, 2, Value::Null);
8885        /*
8886         * @ignore
8887         * @method
8888         * @description parses liquidation info from the exchange response
8889         * @param {object[]} liquidations each item describes an instance of a liquidation event
8890         * @param {object} market ccxt market
8891         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
8892         * @param {int} [limit] limits the number of items in the response
8893         * @returns {object[]} an array of [liquidation structures]{@link https://docs.ccxt.com/?id=liquidation-structure}
8894         */
8895        let mut result: Value = Value::from(vec![]);
8896        {
8897                        let mut i: Value = Value::Int(0);
8898            let mut __for_first_165: bool = true;
8899            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) } {
8900            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);
8901            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry, &[market.clone()]);
8902            append_to_array(&mut result, parsed);
8903        }
8904        }
8905        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8906        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8907        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8908
8909    Value::Null
8910}
8911
8912    fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8913        // virtual-dispatch (static: DerivedExchange::parse_greeks(self, ...))
8914        { 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; } }
8915
8916        let mut market = get_arg(optional_args, 0, Value::Null);
8917        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseGreeks () is not supported yet".into()))));
8918
8919    Value::Null
8920}
8921
8922    fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8923        let mut symbols = get_arg(optional_args, 0, Value::Null);
8924        let mut params = get_arg(optional_args, 1, Value::Map({
8925    let mut m = indexmap::IndexMap::new();
8926    m
8927}));
8928        //
8929        // the value of greeks is either a dict or a list
8930        //
8931        let mut results: Value = Value::from(vec![]);
8932        if (matches!(&greeks, Value::Arr(_))) {
8933            {
8934                                let mut i: Value = Value::Int(0);
8935                let mut __for_first_166: bool = true;
8936                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) } {
8937                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), &[]);
8938                let mut greek: Value = self.extend(parsedTicker, &[params.clone()]);
8939                append_to_array(&mut results, greek.clone());
8940            }
8941            }
8942        }  else {
8943            let mut marketIds: Value = object_keys(&greeks);
8944            {
8945                                let mut i: Value = Value::Int(0);
8946                let mut __for_first_167: bool = true;
8947                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) } {
8948                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);
8949                let mut market: Value = self.safe_market(&[marketId.clone()]);
8950                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market]);
8951                let mut greek: Value = self.extend(parsed, &[params.clone()]);
8952                append_to_array(&mut results, greek);
8953            }
8954            }
8955        }
8956        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
8957        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbolsNormalized]);
8958
8959    Value::Null
8960}
8961
8962    fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
8963        let mut currency = get_arg(optional_args, 0, Value::Null);
8964        let mut market = get_arg(optional_args, 1, Value::Null);
8965        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOption () is not supported yet".into()))));
8966
8967    Value::Null
8968}
8969
8970    fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
8971        let mut currencyKey = get_arg(optional_args, 0, Value::Null);
8972        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8973        let mut optionStructures: Value = Value::Map({
8974            let mut m = indexmap::IndexMap::new();
8975            m
8976        });
8977        {
8978                        let mut i: Value = Value::Int(0);
8979            let mut __for_first_168: bool = true;
8980            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) } {
8981            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);
8982            let mut currencyId: Value = (if (currencyKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), currencyKey.clone(), &[]) });
8983            let mut currency: Value = self.safe_currency(currencyId, &[]);
8984            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
8985            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("option".into())]);
8986            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()]));
8987        }
8988        }
8989        return optionStructures;
8990
8991    Value::Null
8992}
8993
8994    fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
8995        let mut symbols = get_arg(optional_args, 0, Value::Null);
8996        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8997        let mut marketType = get_arg(optional_args, 2, Value::Null);
8998        let mut marginModeStructures: Value = Value::Map({
8999            let mut m = indexmap::IndexMap::new();
9000            m
9001        });
9002        let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); // default to swap
9003        {
9004                        let mut i: Value = Value::Int(0);
9005            let mut __for_first_169: bool = true;
9006            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) } {
9007            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);
9008            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9009            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9010            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) {
9011                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()]));
9012            }
9013        }
9014        }
9015        return marginModeStructures;
9016
9017    Value::Null
9018}
9019
9020    fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
9021        // virtual-dispatch (static: DerivedExchange::parse_margin_mode(self, ...))
9022        { 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; } }
9023
9024        let mut market = get_arg(optional_args, 0, Value::Null);
9025        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginMode () is not supported yet".into()))));
9026
9027    Value::Null
9028}
9029
9030    fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
9031        let mut symbols = get_arg(optional_args, 0, Value::Null);
9032        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9033        let mut marketType = get_arg(optional_args, 2, Value::Null);
9034        let mut leverageStructures: Value = Value::Map({
9035            let mut m = indexmap::IndexMap::new();
9036            m
9037        });
9038        let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); // default to swap
9039        {
9040                        let mut i: Value = Value::Int(0);
9041            let mut __for_first_170: bool = true;
9042            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) } {
9043            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);
9044            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9045            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9046            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) {
9047                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()]));
9048            }
9049        }
9050        }
9051        return leverageStructures;
9052
9053    Value::Null
9054}
9055
9056    fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
9057        // virtual-dispatch (static: DerivedExchange::parse_leverage(self, ...))
9058        { 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; } }
9059
9060        let mut market = get_arg(optional_args, 0, Value::Null);
9061        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLeverage () is not supported yet".into()))));
9062
9063    Value::Null
9064}
9065
9066    fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
9067        let mut code = get_arg(optional_args, 0, Value::Null);
9068        let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
9069        let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
9070        let mut since = get_arg(optional_args, 3, Value::Null);
9071        let mut limit = get_arg(optional_args, 4, Value::Null);
9072        let mut params = get_arg(optional_args, 5, Value::Map({
9073    let mut m = indexmap::IndexMap::new();
9074    m
9075}));
9076        let mut conversionsArray: Value = self.to_array(conversions);
9077        let mut result: Value = Value::from(vec![]);
9078        let mut fromCurrency: Value = Value::Null;
9079        let mut toCurrency: Value = Value::Null;
9080        {
9081                        let mut i: Value = Value::Int(0);
9082            let mut __for_first_171: bool = true;
9083            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) } {
9084            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);
9085            let mut fromId: Value = (if (fromCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]) });
9086            let mut toId: Value = (if (toCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]) });
9087            if (fromId != Value::Null) {
9088                fromCurrency = self.safe_currency(fromId, &[]);
9089            }
9090            if (toId != Value::Null) {
9091                toCurrency = self.safe_currency(toId, &[]);
9092            }
9093            let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry, &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
9094            append_to_array(&mut result, conversion);
9095        }
9096        }
9097        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
9098        if (code == Value::Null) {
9099            return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
9100        }
9101        let mut currency: Value = self.safe_currency(code, &[]);
9102        if (currency == Value::Null) {
9103            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseConversions() could not resolve currency".into()))));
9104        }
9105        let mut currencyCode: Value = currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
9106        let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".into()), currencyCode.clone(), &[]);
9107        let mut toConversion: Value = self.filter_by(sorted, Value::Str("toCurrency".into()), currencyCode, &[]);
9108        let mut both: Value = self.array_concat(fromConversion, toConversion);
9109        return self.filter_by_since_limit(both, &[since, limit]);
9110
9111    Value::Null
9112}
9113
9114    fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
9115        // virtual-dispatch (static: DerivedExchange::parse_conversion(self, ...))
9116        { 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; } }
9117
9118        let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
9119        let mut toCurrency = get_arg(optional_args, 1, Value::Null);
9120        if (conversion == Value::Null) {
9121            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9122        }
9123        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9124
9125    Value::Null
9126}
9127
9128    fn convert_expire_date(&self, mut date: Value) -> Value {
9129        if (date == Value::Null) {
9130            return Value::Null;
9131        }
9132        // parse YYMMDD to datetime string
9133        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);
9134        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);
9135        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);
9136        // the milliseconds are spelled out because every caller writes the result into
9137        // expiryDatetime, which types.ts documents in the ISO 8601 form with them
9138        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());
9139        return reconstructedDate;
9140
9141    Value::Null
9142}
9143
9144    fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9145        if (date == Value::Null) {
9146            return Value::Null;
9147        }
9148        // parse 240119 to 19JAN24
9149        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);
9150        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);
9151        let mut month: Value = Value::Null;
9152        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);
9153        if (monthRaw.as_str() == Some("01")) {
9154            month = Value::Str("JAN".into());
9155        }  else if (monthRaw.as_str() == Some("02")) {
9156            month = Value::Str("FEB".into());
9157        }  else if (monthRaw.as_str() == Some("03")) {
9158            month = Value::Str("MAR".into());
9159        }  else if (monthRaw.as_str() == Some("04")) {
9160            month = Value::Str("APR".into());
9161        }  else if (monthRaw.as_str() == Some("05")) {
9162            month = Value::Str("MAY".into());
9163        }  else if (monthRaw.as_str() == Some("06")) {
9164            month = Value::Str("JUN".into());
9165        }  else if (monthRaw.as_str() == Some("07")) {
9166            month = Value::Str("JUL".into());
9167        }  else if (monthRaw.as_str() == Some("08")) {
9168            month = Value::Str("AUG".into());
9169        }  else if (monthRaw.as_str() == Some("09")) {
9170            month = Value::Str("SEP".into());
9171        }  else if (monthRaw.as_str() == Some("10")) {
9172            month = Value::Str("OCT".into());
9173        }  else if (monthRaw.as_str() == Some("11")) {
9174            month = Value::Str("NOV".into());
9175        }  else if (monthRaw.as_str() == Some("12")) {
9176            month = Value::Str("DEC".into());
9177        }
9178        if (month == Value::Null) {
9179            panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9180        }
9181        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9182        return reconstructedDate;
9183
9184    Value::Null
9185}
9186
9187    fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9188        if (date == Value::Null) {
9189            return Value::Null;
9190        }
9191        // parse 03JAN24 to 240103.
9192        let mut monthMappping: Value = Value::Map({
9193            let mut m = indexmap::IndexMap::new();
9194                m.insert("JAN".to_string(), Value::Str("01".into()));
9195                m.insert("FEB".to_string(), Value::Str("02".into()));
9196                m.insert("MAR".to_string(), Value::Str("03".into()));
9197                m.insert("APR".to_string(), Value::Str("04".into()));
9198                m.insert("MAY".to_string(), Value::Str("05".into()));
9199                m.insert("JUN".to_string(), Value::Str("06".into()));
9200                m.insert("JUL".to_string(), Value::Str("07".into()));
9201                m.insert("AUG".to_string(), Value::Str("08".into()));
9202                m.insert("SEP".to_string(), Value::Str("09".into()));
9203                m.insert("OCT".to_string(), Value::Str("10".into()));
9204                m.insert("NOV".to_string(), Value::Str("11".into()));
9205                m.insert("DEC".to_string(), Value::Str("12".into()));
9206            m
9207        });
9208        // if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
9209        let mut datePadded: Value = date.clone();
9210        if (Value::Int(date.len() as i64).as_f64() == Some(6.0)) {
9211            datePadded = Value::Str(format!("{}{}", Value::Str("0".into()), date).into());
9212        }
9213        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);
9214        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);
9215        let mut month: Value = self.safe_string(monthMappping, monthName, &[]);
9216        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);
9217        if (month == Value::Null) {
9218            panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9219        }
9220        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9221        return reconstructedDate;
9222
9223    Value::Null
9224}
9225
9226    fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9227        promise_all(&Value::from(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9228
9229    Value::Null
9230} }
9231
9232    fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9233        // virtual-dispatch (static: DerivedExchange::parse_margin_modification(self, ...))
9234        { 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; } }
9235
9236        let mut market = get_arg(optional_args, 0, Value::Null);
9237        if (data == Value::Null) {
9238            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9239        }
9240        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9241
9242    Value::Null
9243}
9244
9245    fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9246        let mut symbols = get_arg(optional_args, 0, Value::Null);
9247        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9248        let mut marketType = get_arg(optional_args, 2, Value::Null);
9249        let mut marginModifications: Value = Value::from(vec![]);
9250        if (response == Value::Null) {
9251            return marginModifications;
9252        }
9253        {
9254                        let mut i: Value = Value::Int(0);
9255            let mut __for_first_172: bool = true;
9256            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) } {
9257            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);
9258            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9259            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
9260            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) {
9261                append_to_array(&mut marginModifications, <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info, &[market]));
9262            }
9263        }
9264        }
9265        return marginModifications;
9266
9267    Value::Null
9268}
9269
9270    fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9271        let mut code = get_arg(optional_args, 0, Value::Null);
9272        let mut params = get_arg(optional_args, 1, Value::Map({
9273    let mut m = indexmap::IndexMap::new();
9274    m
9275}));
9276        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfer () is not supported yet".into()))));
9277
9278    Value::Null
9279} }
9280
9281    fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9282        let mut code = get_arg(optional_args, 0, Value::Null);
9283        let mut since = get_arg(optional_args, 1, Value::Null);
9284        let mut limit = get_arg(optional_args, 2, Value::Null);
9285        let mut params = get_arg(optional_args, 3, Value::Map({
9286    let mut m = indexmap::IndexMap::new();
9287    m
9288}));
9289        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfers () is not supported yet".into()))));
9290
9291    Value::Null
9292} }
9293
9294    fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9295        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
9296        let mut params = get_arg(optional_args, 1, 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(" unWatchOHLCV () is not supported yet".into()))));
9301
9302    Value::Null
9303} }
9304
9305    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 {
9306        let mut params = get_arg(optional_args, 0, Value::Map({
9307    let mut m = indexmap::IndexMap::new();
9308    m
9309}));
9310        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdrawWs () is not supported yet".into()))));
9311
9312    Value::Null
9313} }
9314
9315    fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9316        let mut symbol = get_arg(optional_args, 0, Value::Null);
9317        let mut params = get_arg(optional_args, 1, Value::Map({
9318    let mut m = indexmap::IndexMap::new();
9319    m
9320}));
9321        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMyTrades () is not supported yet".into()))));
9322
9323    Value::Null
9324} }
9325
9326    fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9327        let mut symbol = get_arg(optional_args, 0, Value::Null);
9328        let mut since = get_arg(optional_args, 1, Value::Null);
9329        let mut limit = get_arg(optional_args, 2, Value::Null);
9330        let mut params = get_arg(optional_args, 3, Value::Map({
9331    let mut m = indexmap::IndexMap::new();
9332    m
9333}));
9334        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersByStatusWs () is not supported yet".into()))));
9335
9336    Value::Null
9337} }
9338
9339    fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9340        let mut symbols = get_arg(optional_args, 0, Value::Null);
9341        let mut params = get_arg(optional_args, 1, Value::Map({
9342    let mut m = indexmap::IndexMap::new();
9343    m
9344}));
9345        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchBidsAsks () is not supported yet".into()))));
9346
9347    Value::Null
9348} }
9349
9350    fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9351        let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9352        if (unsubHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &unsubHash)) {
9353            remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &unsubHash);
9354        }
9355        if !is_true(&subHashIsPrefix) {
9356            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &subHash)) {
9357                remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &subHash);
9358            }
9359            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("futures".into())), &subHash)) {
9360                let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), subHash));
9361                client.reject(&[Value::from(error.clone()), subHash.clone()]);
9362            }
9363        }  else {
9364            let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".into())));
9365            {
9366                                let mut i: Value = Value::Int(0);
9367                let mut __for_first_173: bool = true;
9368                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) } {
9369                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);
9370                if (sub != Value::Null) && (subHash != Value::Null) && (starts_with(&sub, &subHash)) {
9371                    remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &sub);
9372                }
9373            }
9374            }
9375            let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
9376            {
9377                                let mut i: Value = Value::Int(0);
9378                let mut __for_first_174: bool = true;
9379                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) } {
9380                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);
9381                if (future != Value::Null) && (subHash != Value::Null) && (starts_with(&future, &subHash)) {
9382                    let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), future));
9383                    client.reject(&[Value::from(error), future.clone()]);
9384                }
9385            }
9386            }
9387        }
9388        client.resolve(&[Value::Bool(true), unsubHash]);
9389}
9390
9391    fn clean_cache(&mut self, mut subscription: Value) {
9392        let __subscription_empty = indexmap::IndexMap::new();
9393        let subscription = subscription.as_map().unwrap_or(&__subscription_empty);
9394        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);
9395        let mut symbols: Value = (match subscription.get("symbols") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9396        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
9397        if (topic.as_deref() == Some("ohlcv")) {
9398            let mut symbolsAndTimeframes: Value = (match subscription.get("symbolsAndTimeframes") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9399            {
9400                                let mut i: Value = Value::Int(0);
9401                let mut __for_first_175: bool = true;
9402                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) } {
9403                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9404                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9405                let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9406                let mut timeframe: Value = self.safe_string(symbolAndTimeFrame, Value::Int(1), &[]);
9407                if (symbol == Value::Null) {
9408                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a symbol argument".into()))));
9409                }
9410                if (timeframe == Value::Null) {
9411                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a timeframe argument".into()))));
9412                }
9413                if (self.ohlcvs.clone() != Value::Null) && (in_op(&self.ohlcvs, &symbol)) {
9414                    if (in_op(&get_value(&self.ohlcvs, &symbol), &timeframe)) {
9415                        remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
9416                    }
9417                }
9418            }
9419            }
9420        }  else if symbolsLength > ((0i64) as f64) {
9421            {
9422                                let mut i: Value = Value::Int(0);
9423                let mut __for_first_176: bool = true;
9424                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) } {
9425                let mut symbol: Value = get_value(&symbols, &i);
9426                let mut symbol: Value = get_value(&symbols, &i);
9427                if (topic.as_deref() == Some("trades")) {
9428                    if (in_op(&self.trades, &symbol)) {
9429                        remove(&mut self.trades.clone(), &symbol);
9430                    }
9431                }  else if (topic.as_deref() == Some("orderbook")) {
9432                    if (in_op(&self.orderbooks, &symbol)) {
9433                        remove(&mut self.orderbooks.clone(), &symbol);
9434                    }
9435                }  else if (topic.as_deref() == Some("ticker")) {
9436                    if (in_op(&self.tickers, &symbol)) {
9437                        remove(&mut self.tickers.clone(), &symbol);
9438                    }
9439                }  else if (topic.as_deref() == Some("bidsasks")) {
9440                    if (in_op(&self.bidsasks, &symbol)) {
9441                        remove(&mut self.bidsasks.clone(), &symbol);
9442                    }
9443                }
9444            }
9445            }
9446        }  else {
9447            if (topic.as_deref() == Some("myTrades")) && (self.myTrades.clone() != Value::Null) {
9448                self.myTrades = Value::Null;
9449            }  else if (topic.as_deref() == Some("orders")) && (self.orders.clone() != Value::Null) {
9450                self.orders = Value::Null;
9451            }  else if (topic.as_deref() == Some("positions")) && (self.positions.clone() != Value::Null) {
9452                self.positions = Value::Null;
9453                let mut clients: Value = object_values(&self.clients);
9454                {
9455                                        let mut i: Value = Value::Int(0);
9456                    let mut __for_first_177: bool = true;
9457                    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) } {
9458                    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);
9459                    let mut futures: Value = get_value(&client, &Value::Str("futures".into()));
9460                    if (futures != Value::Null) && (matches!(&futures, Value::Dict(__d) if __d.contains_key("fetchPositionsSnapshot"))) {
9461                        remove(&mut futures, &Value::Str("fetchPositionsSnapshot".into()));
9462                    }
9463                }
9464                }
9465            }  else if ((topic.as_deref() == Some("ticker")) || (topic.as_deref() == Some("markPrice"))) && (self.tickers.clone() != Value::Null) {
9466                let mut tickerSymbols: Value = object_keys(&self.tickers);
9467                {
9468                                        let mut i: Value = Value::Int(0);
9469                    let mut __for_first_178: bool = true;
9470                    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) } {
9471                    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);
9472                    if (in_op(&self.tickers, &tickerSymbol)) {
9473                        remove(&mut self.tickers.clone(), &tickerSymbol);
9474                    }
9475                }
9476                }
9477            }  else if (topic.as_deref() == Some("bidsasks")) && (self.bidsasks.clone() != Value::Null) {
9478                let mut bidsaskSymbols: Value = object_keys(&self.bidsasks);
9479                {
9480                                        let mut i: Value = Value::Int(0);
9481                    let mut __for_first_179: bool = true;
9482                    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) } {
9483                    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);
9484                    if (in_op(&self.bidsasks, &bidsaskSymbol)) {
9485                        remove(&mut self.bidsasks.clone(), &bidsaskSymbol);
9486                    }
9487                }
9488                }
9489            }
9490        }
9491}
9492
9493    fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9494        if ms.as_f64().unwrap_or(f64::NAN) <= ((0i64) as f64) {
9495            return Value::Str("".into());
9496        }
9497        let mut second: Value = Value::Int(1000);
9498        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 });
9499        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 });
9500        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 });
9501        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 });
9502        if (mod_val(&ms, &week).as_f64() == Some(0.0)) {
9503            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()));
9504        }
9505        if (mod_val(&ms, &day).as_f64() == Some(0.0)) {
9506            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()));
9507        }
9508        if (mod_val(&ms, &hour).as_f64() == Some(0.0)) {
9509            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()));
9510        }
9511        if (mod_val(&ms, &minute).as_f64() == Some(0.0)) {
9512            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()));
9513        }
9514        if (mod_val(&ms, &second).as_f64() == Some(0.0)) {
9515            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()));
9516        }
9517        return Value::Str("".into());
9518
9519    Value::Null
9520}
9521
9522    fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9523        let mut params = get_arg(optional_args, 0, Value::Map({
9524    let mut m = indexmap::IndexMap::new();
9525    m
9526}));
9527        return Value::Bool(false);
9528
9529    Value::Null
9530} }
9531    fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9532        let mut side = get_arg(optional_args, 0, Value::Null);
9533        let mut params = get_arg(optional_args, 1, 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(" closePosition() is not supported yet".into()))));
9538
9539    Value::Null
9540} }
9541
9542    fn close_all_positions(&mut self, 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(" closeAllPositions() is not supported yet".into()))));
9548
9549    Value::Null
9550} }
9551
9552    fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9553        let mut params = get_arg(optional_args, 0, Value::Map({
9554    let mut m = indexmap::IndexMap::new();
9555    m
9556}));
9557        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" editOrders() is not supported yet".into()))));
9558
9559    Value::Null
9560} }
9561
9562    fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9563        let mut symbol = get_arg(optional_args, 0, Value::Null);
9564        let mut since = get_arg(optional_args, 1, Value::Null);
9565        let mut limit = get_arg(optional_args, 2, Value::Null);
9566        let mut params = get_arg(optional_args, 3, Value::Map({
9567    let mut m = indexmap::IndexMap::new();
9568    m
9569}));
9570        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".into()))));
9571
9572    Value::Null
9573} }
9574
9575    fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9576        // async-virtual: try the derived exchange first
9577        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 {
9578            if !matches!(__v, crate::Value::Null) { return __v; }
9579        }
9580
9581        let mut since = get_arg(optional_args, 0, Value::Null);
9582        let mut limit = get_arg(optional_args, 1, Value::Null);
9583        let mut params = get_arg(optional_args, 2, Value::Map({
9584    let mut m = indexmap::IndexMap::new();
9585    m
9586}));
9587        /*
9588         * @method
9589         * @name exchange#fetchPositionHistory
9590         * @description fetches the history of margin added or reduced from contract isolated positions
9591         * @param {string} [symbol] unified market symbol
9592         * @param {int} [since] timestamp in ms of the position
9593         * @param {int} [limit] the maximum amount of candles to fetch, default=1000
9594         * @param {object} params extra parameters specific to the exchange api endpoint
9595         * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
9596         */
9597        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)) {
9598            let mut positions: Value = self.fetch_positions_history(&[Value::from(vec![symbol]), since, limit, params]).await;
9599            return positions;
9600        }  else {
9601            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionHistory () is not supported yet".into()))));
9602        }
9603} }
9604
9605    fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9606        // async-virtual: try the derived exchange first
9607        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 {
9608            if !matches!(__v, crate::Value::Null) { return __v; }
9609        }
9610
9611        let mut symbols = get_arg(optional_args, 0, Value::Null);
9612        let mut since = get_arg(optional_args, 1, Value::Null);
9613        let mut limit = get_arg(optional_args, 2, Value::Null);
9614        let mut params = get_arg(optional_args, 3, Value::Map({
9615    let mut m = indexmap::IndexMap::new();
9616    m
9617}));
9618        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsHistory () is not supported yet".into()))));
9619
9620    Value::Null
9621} }
9622
9623    fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9624        let mut symbols = get_arg(optional_args, 0, Value::Null);
9625        let mut params = get_arg(optional_args, 1, 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(" fetchPositionsRisk() is not supported yet".into()))));
9630
9631    Value::Null
9632} }
9633
9634    fn fetch_positions_for_symbol(&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 fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9645        let mut params = get_arg(optional_args, 0, Value::Map({
9646    let mut m = indexmap::IndexMap::new();
9647    m
9648}));
9649        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9650
9651    Value::Null
9652} }
9653
9654    fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9655        let mut symbol = get_arg(optional_args, 0, Value::Null);
9656        let mut params = get_arg(optional_args, 1, Value::Map({
9657    let mut m = indexmap::IndexMap::new();
9658    m
9659}));
9660        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPosition() is not supported yet".into()))));
9661
9662    Value::Null
9663} }
9664
9665    fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9666        let mut since = get_arg(optional_args, 0, Value::Null);
9667        let mut limit = get_arg(optional_args, 1, Value::Null);
9668        let mut params = get_arg(optional_args, 2, Value::Map({
9669    let mut m = indexmap::IndexMap::new();
9670    m
9671}));
9672        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTradesForSymbols() is not supported yet".into()))));
9673
9674    Value::Null
9675} }
9676
9677    fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9678        let mut since = get_arg(optional_args, 0, Value::Null);
9679        let mut limit = get_arg(optional_args, 1, Value::Null);
9680        let mut params = get_arg(optional_args, 2, Value::Map({
9681    let mut m = indexmap::IndexMap::new();
9682    m
9683}));
9684        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTradesForSymbols() is not supported yet".into()))));
9685
9686    Value::Null
9687} }
9688
9689    fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9690        let mut symbols = get_arg(optional_args, 0, Value::Null);
9691        let mut params = get_arg(optional_args, 1, Value::Map({
9692    let mut m = indexmap::IndexMap::new();
9693    m
9694}));
9695        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBidsAsks() is not supported yet".into()))));
9696
9697    Value::Null
9698} }
9699
9700    fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9701        let mut params = get_arg(optional_args, 0, Value::Map({
9702    let mut m = indexmap::IndexMap::new();
9703    m
9704}));
9705        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)) {
9706            self.load_markets(&[]).await;
9707            let mut market: Value = self.market(symbol);
9708            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
9709            let mut tickers: Value = self.fetch_mark_prices(&[Value::from(vec![symbolResolved.clone()]), params]).await;
9710            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
9711            if (ticker == Value::Null) {
9712                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)));
9713            }  else {
9714                return ticker;
9715            }
9716        }  else {
9717            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9718        }
9719
9720    Value::Null
9721} }
9722
9723    fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9724        let mut symbols = get_arg(optional_args, 0, Value::Null);
9725        let mut params = get_arg(optional_args, 1, Value::Map({
9726    let mut m = indexmap::IndexMap::new();
9727    m
9728}));
9729        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9730
9731    Value::Null
9732} }
9733
9734    fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9735        let mut symbols = get_arg(optional_args, 0, Value::Null);
9736        let mut params = get_arg(optional_args, 1, 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(" watchBidsAsks() is not supported yet".into()))));
9741
9742    Value::Null
9743} }
9744
9745    fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9746        let mut params = get_arg(optional_args, 0, Value::Map({
9747    let mut m = indexmap::IndexMap::new();
9748    m
9749}));
9750        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrice () is not supported yet".into()))));
9751
9752    Value::Null
9753} }
9754
9755    fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9756        let mut symbols = get_arg(optional_args, 0, Value::Null);
9757        let mut params = get_arg(optional_args, 1, Value::Map({
9758    let mut m = indexmap::IndexMap::new();
9759    m
9760}));
9761        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrices () is not supported yet".into()))));
9762
9763    Value::Null
9764} }
9765
9766    fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9767        let mut limit = get_arg(optional_args, 0, Value::Null);
9768        let mut params = get_arg(optional_args, 1, Value::Map({
9769    let mut m = indexmap::IndexMap::new();
9770    m
9771}));
9772        panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchL3OrderBook() is not supported yet".into()))));
9773
9774    Value::Null
9775} }
9776
9777    fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9778        let mut limit = get_arg(optional_args, 0, Value::Null);
9779        let mut params = get_arg(optional_args, 1, Value::Map({
9780    let mut m = indexmap::IndexMap::new();
9781    m
9782}));
9783        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBookForSymbols() is not supported yet".into()))));
9784
9785    Value::Null
9786} }
9787
9788    fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9789        let mut since = get_arg(optional_args, 0, Value::Null);
9790        let mut limit = get_arg(optional_args, 1, Value::Null);
9791        let mut params = get_arg(optional_args, 2, Value::Map({
9792    let mut m = indexmap::IndexMap::new();
9793    m
9794}));
9795        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrdersForSymbols() is not supported yet".into()))));
9796
9797    Value::Null
9798} }
9799
9800    fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9801        let mut symbol = get_arg(optional_args, 0, Value::Null);
9802        let mut params = get_arg(optional_args, 1, Value::Map({
9803    let mut m = indexmap::IndexMap::new();
9804    m
9805}));
9806        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersWs() is not supported yet".into()))));
9807
9808    Value::Null
9809} }
9810
9811    fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9812        let mut symbol = get_arg(optional_args, 0, Value::Null);
9813        let mut params = get_arg(optional_args, 1, Value::Map({
9814    let mut m = indexmap::IndexMap::new();
9815    m
9816}));
9817        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrderWs() is not supported yet".into()))));
9818
9819    Value::Null
9820} }
9821
9822    fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9823        let mut symbol = get_arg(optional_args, 0, Value::Null);
9824        let mut params = get_arg(optional_args, 1, Value::Map({
9825    let mut m = indexmap::IndexMap::new();
9826    m
9827}));
9828        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersWs() is not supported yet".into()))));
9829
9830    Value::Null
9831} }
9832
9833    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 {
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()), Value::Str("buy".into()), amount, &[price, params]).await;
9839
9840    Value::Null
9841} }
9842
9843    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 {
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()), side, amount, &[price, params]).await;
9849
9850    Value::Null
9851} }
9852
9853    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 {
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("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
9859
9860    Value::Null
9861} }
9862
9863    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 {
9864        let mut params = get_arg(optional_args, 0, Value::Map({
9865    let mut m = indexmap::IndexMap::new();
9866    m
9867}));
9868        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
9869
9870    Value::Null
9871} }
9872
9873    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 {
9874        let mut params = get_arg(optional_args, 0, Value::Map({
9875    let mut m = indexmap::IndexMap::new();
9876    m
9877}));
9878        /*
9879         * @method
9880         * @name createMarketOrderWithCostWs
9881         * @description create a market order by providing the symbol, side and cost
9882         * @param {string} symbol unified symbol of the market to create an order in
9883         * @param {string} side 'buy' or 'sell'
9884         * @param {float} cost how much you want to trade in units of the quote currency
9885         * @param {object} [params] extra parameters specific to the exchange API endpoint
9886         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
9887         */
9888        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)))) {
9889            return self.create_order_ws(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
9890        }
9891        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCostWs() is not supported yet".into()))));
9892
9893    Value::Null
9894} }
9895
9896    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 {
9897        let mut price = get_arg(optional_args, 0, Value::Null);
9898        let mut params = get_arg(optional_args, 1, Value::Map({
9899    let mut m = indexmap::IndexMap::new();
9900    m
9901}));
9902        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
9903
9904    Value::Null
9905} }
9906
9907    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 {
9908        let mut params = get_arg(optional_args, 0, Value::Map({
9909    let mut m = indexmap::IndexMap::new();
9910    m
9911}));
9912        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
9913
9914    Value::Null
9915} }
9916
9917    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 {
9918        let mut price = get_arg(optional_args, 0, Value::Null);
9919        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
9920        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
9921        let mut params = get_arg(optional_args, 3, Value::Map({
9922    let mut m = indexmap::IndexMap::new();
9923    m
9924}));
9925        /*
9926         * @method
9927         * @name createOrderWithTakeProfitAndStopLossWs
9928         * @description create an order with a stop loss or take profit attached (type 3)
9929         * @param {string} symbol unified symbol of the market to create an order in
9930         * @param {string} type 'market' or 'limit'
9931         * @param {string} side 'buy' or 'sell'
9932         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
9933         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
9934         * @param {float} [takeProfit] the take profit price, in units of the quote currency
9935         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
9936         * @param {object} [params] extra parameters specific to the exchange API endpoint
9937         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
9938         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
9939         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
9940         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
9941         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
9942         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
9943         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
9944         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
9945         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
9946         */
9947        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()]);
9948        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)) {
9949            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsValue]).await;
9950        }
9951        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".into()))));
9952
9953    Value::Null
9954} }
9955
9956    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 {
9957        let mut price = get_arg(optional_args, 0, Value::Null);
9958        let mut params = get_arg(optional_args, 1, 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(" createOrderWs() is not supported yet".into()))));
9963
9964    Value::Null
9965} }
9966
9967    fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9968        let mut params = get_arg(optional_args, 0, Value::Map({
9969    let mut m = indexmap::IndexMap::new();
9970    m
9971}));
9972        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrdersWs () is not supported yet".into()))));
9973
9974    Value::Null
9975} }
9976
9977    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 {
9978        let mut price = get_arg(optional_args, 0, Value::Null);
9979        let mut params = get_arg(optional_args, 1, Value::Map({
9980    let mut m = indexmap::IndexMap::new();
9981    m
9982}));
9983        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)) {
9984            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrderWs() is not supported yet".into()))));
9985        }
9986        let mut query: Value = self.extend(params, &[Value::Map({
9987            let mut m = indexmap::IndexMap::new();
9988                m.insert("postOnly".to_string(), Value::Bool(true));
9989            m
9990        })]);
9991        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
9992
9993    Value::Null
9994} }
9995
9996    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 {
9997        let mut price = get_arg(optional_args, 0, Value::Null);
9998        let mut params = get_arg(optional_args, 1, Value::Map({
9999    let mut m = indexmap::IndexMap::new();
10000    m
10001}));
10002        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)) {
10003            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrderWs() is not supported yet".into()))));
10004        }
10005        let mut query: Value = self.extend(params, &[Value::Map({
10006            let mut m = indexmap::IndexMap::new();
10007                m.insert("reduceOnly".to_string(), Value::Bool(true));
10008            m
10009        })]);
10010        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10011
10012    Value::Null
10013} }
10014
10015    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 {
10016        let mut params = get_arg(optional_args, 0, Value::Map({
10017    let mut m = indexmap::IndexMap::new();
10018    m
10019}));
10020        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)) {
10021            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrderWs() is not supported yet".into()))));
10022        }
10023        let mut query: Value = self.extend(params, &[Value::Map({
10024            let mut m = indexmap::IndexMap::new();
10025                m.insert("stopPrice".to_string(), triggerPrice);
10026            m
10027        })]);
10028        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
10029
10030    Value::Null
10031} }
10032
10033    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 {
10034        let mut price = get_arg(optional_args, 0, Value::Null);
10035        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10036        let mut params = get_arg(optional_args, 2, Value::Map({
10037    let mut m = indexmap::IndexMap::new();
10038    m
10039}));
10040        /*
10041         * @method
10042         * @name createStopLossOrderWs
10043         * @description create a trigger stop loss order (type 2)
10044         * @param {string} symbol unified symbol of the market to create an order in
10045         * @param {string} type 'market' or 'limit'
10046         * @param {string} side 'buy' or 'sell'
10047         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10048         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10049         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
10050         * @param {object} [params] extra parameters specific to the exchange API endpoint
10051         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10052         */
10053        if (stopLossPrice == Value::Null) {
10054            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".into()))));
10055        }
10056        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10057            let mut m = indexmap::IndexMap::new();
10058                m.insert("stopLossPrice".to_string(), stopLossPrice);
10059            m
10060        })]);
10061        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)) {
10062            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10063        }
10064        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() is not supported yet".into()))));
10065
10066    Value::Null
10067} }
10068
10069    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 {
10070        let mut params = get_arg(optional_args, 0, Value::Map({
10071    let mut m = indexmap::IndexMap::new();
10072    m
10073}));
10074        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)) {
10075            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrderWs() is not supported yet".into()))));
10076        }
10077        let mut query: Value = self.extend(params, &[Value::Map({
10078            let mut m = indexmap::IndexMap::new();
10079                m.insert("stopPrice".to_string(), triggerPrice);
10080            m
10081        })]);
10082        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
10083
10084    Value::Null
10085} }
10086
10087    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 {
10088        let mut price = get_arg(optional_args, 0, Value::Null);
10089        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10090        let mut params = get_arg(optional_args, 2, Value::Map({
10091    let mut m = indexmap::IndexMap::new();
10092    m
10093}));
10094        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)) {
10095            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() is not supported yet".into()))));
10096        }
10097        if (triggerPrice == Value::Null) {
10098            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() requires a stopPrice argument".into()))));
10099        }
10100        let mut query: Value = self.extend(params, &[Value::Map({
10101            let mut m = indexmap::IndexMap::new();
10102                m.insert("stopPrice".to_string(), triggerPrice);
10103            m
10104        })]);
10105        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10106
10107    Value::Null
10108} }
10109
10110    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 {
10111        let mut price = get_arg(optional_args, 0, Value::Null);
10112        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10113        let mut params = get_arg(optional_args, 2, Value::Map({
10114    let mut m = indexmap::IndexMap::new();
10115    m
10116}));
10117        /*
10118         * @method
10119         * @name createTakeProfitOrderWs
10120         * @description create a trigger take profit order (type 2)
10121         * @param {string} symbol unified symbol of the market to create an order in
10122         * @param {string} type 'market' or 'limit'
10123         * @param {string} side 'buy' or 'sell'
10124         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10125         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10126         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
10127         * @param {object} [params] extra parameters specific to the exchange API endpoint
10128         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10129         */
10130        if (takeProfitPrice == Value::Null) {
10131            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".into()))));
10132        }
10133        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10134            let mut m = indexmap::IndexMap::new();
10135                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
10136            m
10137        })]);
10138        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)) {
10139            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10140        }
10141        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() is not supported yet".into()))));
10142
10143    Value::Null
10144} }
10145
10146    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 {
10147        let mut price = get_arg(optional_args, 0, Value::Null);
10148        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10149        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10150        let mut params = get_arg(optional_args, 3, Value::Map({
10151    let mut m = indexmap::IndexMap::new();
10152    m
10153}));
10154        /*
10155         * @method
10156         * @name createTrailingAmountOrderWs
10157         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
10158         * @param {string} symbol unified symbol of the market to create an order in
10159         * @param {string} type 'market' or 'limit'
10160         * @param {string} side 'buy' or 'sell'
10161         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10162         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10163         * @param {float} trailingAmount the quote amount to trail away from the current market price
10164         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10165         * @param {object} [params] extra parameters specific to the exchange API endpoint
10166         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10167         */
10168        if (trailingAmount == Value::Null) {
10169            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".into()))));
10170        }
10171        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10172        if (trailingTriggerPrice != Value::Null) {
10173            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10174        }
10175        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)) {
10176            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10177        }
10178        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() is not supported yet".into()))));
10179
10180    Value::Null
10181} }
10182
10183    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 {
10184        let mut price = get_arg(optional_args, 0, Value::Null);
10185        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10186        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10187        let mut params = get_arg(optional_args, 3, Value::Map({
10188    let mut m = indexmap::IndexMap::new();
10189    m
10190}));
10191        /*
10192         * @method
10193         * @name createTrailingPercentOrderWs
10194         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
10195         * @param {string} symbol unified symbol of the market to create an order in
10196         * @param {string} type 'market' or 'limit'
10197         * @param {string} side 'buy' or 'sell'
10198         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10199         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10200         * @param {float} trailingPercent the percent to trail away from the current market price
10201         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10202         * @param {object} [params] extra parameters specific to the exchange API endpoint
10203         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10204         */
10205        if (trailingPercent == Value::Null) {
10206            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".into()))));
10207        }
10208        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10209        if (trailingTriggerPrice != Value::Null) {
10210            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10211        }
10212        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)) {
10213            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10214        }
10215        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() is not supported yet".into()))));
10216
10217    Value::Null
10218} }
10219
10220    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 {
10221        let mut price = get_arg(optional_args, 0, Value::Null);
10222        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10223        let mut params = get_arg(optional_args, 2, Value::Map({
10224    let mut m = indexmap::IndexMap::new();
10225    m
10226}));
10227        /*
10228         * @method
10229         * @name createTriggerOrderWs
10230         * @description create a trigger stop order (type 1)
10231         * @param {string} symbol unified symbol of the market to create an order in
10232         * @param {string} type 'market' or 'limit'
10233         * @param {string} side 'buy' or 'sell'
10234         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10235         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10236         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10237         * @param {object} [params] extra parameters specific to the exchange API endpoint
10238         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10239         */
10240        if (triggerPrice == Value::Null) {
10241            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".into()))));
10242        }
10243        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10244            let mut m = indexmap::IndexMap::new();
10245                m.insert("triggerPrice".to_string(), triggerPrice);
10246            m
10247        })]);
10248        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)) {
10249            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10250        }
10251        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() is not supported yet".into()))));
10252
10253    Value::Null
10254} }
10255
10256    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 {
10257        let mut amount = get_arg(optional_args, 0, Value::Null);
10258        let mut price = get_arg(optional_args, 1, Value::Null);
10259        let mut params = get_arg(optional_args, 2, Value::Map({
10260    let mut m = indexmap::IndexMap::new();
10261    m
10262}));
10263        self.cancel_order_ws(id, &[symbol.clone()]).await;
10264        return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10265
10266    Value::Null
10267} }
10268
10269    fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10270        let mut symbol = get_arg(optional_args, 0, Value::Null);
10271        let mut since = get_arg(optional_args, 1, Value::Null);
10272        let mut limit = get_arg(optional_args, 2, Value::Null);
10273        let mut params = get_arg(optional_args, 3, Value::Map({
10274    let mut m = indexmap::IndexMap::new();
10275    m
10276}));
10277        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)) {
10278            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10279            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
10280        }
10281        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrdersWs() is not supported yet".into()))));
10282
10283    Value::Null
10284} }
10285
10286    fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10287        let mut symbol = get_arg(optional_args, 0, Value::Null);
10288        let mut since = get_arg(optional_args, 1, Value::Null);
10289        let mut limit = get_arg(optional_args, 2, Value::Null);
10290        let mut params = get_arg(optional_args, 3, Value::Map({
10291    let mut m = indexmap::IndexMap::new();
10292    m
10293}));
10294        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTradesWs() is not supported yet".into()))));
10295
10296    Value::Null
10297} }
10298
10299    fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10300        let mut symbol = get_arg(optional_args, 0, Value::Null);
10301        let mut since = get_arg(optional_args, 1, Value::Null);
10302        let mut limit = get_arg(optional_args, 2, Value::Null);
10303        let mut params = get_arg(optional_args, 3, Value::Map({
10304    let mut m = indexmap::IndexMap::new();
10305    m
10306}));
10307        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)) {
10308            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10309            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
10310        }
10311        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrdersWs() is not supported yet".into()))));
10312
10313    Value::Null
10314} }
10315
10316    fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10317        let mut limit = get_arg(optional_args, 0, Value::Null);
10318        let mut params = get_arg(optional_args, 1, Value::Map({
10319    let mut m = indexmap::IndexMap::new();
10320    m
10321}));
10322        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBookWs() is not supported yet".into()))));
10323
10324    Value::Null
10325} }
10326
10327    fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10328        let mut symbol = get_arg(optional_args, 0, Value::Null);
10329        let mut params = get_arg(optional_args, 1, Value::Map({
10330    let mut m = indexmap::IndexMap::new();
10331    m
10332}));
10333        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderWs() is not supported yet".into()))));
10334
10335    Value::Null
10336} }
10337
10338    fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10339        let mut symbol = get_arg(optional_args, 0, Value::Null);
10340        let mut since = get_arg(optional_args, 1, Value::Null);
10341        let mut limit = get_arg(optional_args, 2, Value::Null);
10342        let mut params = get_arg(optional_args, 3, 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(" fetchOrdersWs() is not supported yet".into()))));
10347
10348    Value::Null
10349} }
10350
10351    fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10352        let mut params = get_arg(optional_args, 0, Value::Map({
10353    let mut m = indexmap::IndexMap::new();
10354    m
10355}));
10356        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionWs() is not supported yet".into()))));
10357
10358    Value::Null
10359} }
10360
10361    fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10362        let mut symbols = get_arg(optional_args, 0, Value::Null);
10363        let mut params = get_arg(optional_args, 1, Value::Map({
10364    let mut m = indexmap::IndexMap::new();
10365    m
10366}));
10367        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10368
10369    Value::Null
10370} }
10371
10372    fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10373        let mut params = get_arg(optional_args, 0, Value::Map({
10374    let mut m = indexmap::IndexMap::new();
10375    m
10376}));
10377        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)) {
10378            self.load_markets(&[]).await;
10379            let mut market: Value = self.market(symbol);
10380            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10381            let mut tickers: Value = self.fetch_tickers_ws(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10382            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10383            if (ticker == Value::Null) {
10384                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)));
10385            }  else {
10386                return ticker;
10387            }
10388        }  else {
10389            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() is not supported yet".into()))));
10390        }
10391
10392    Value::Null
10393} }
10394
10395    fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10396        let mut symbols = get_arg(optional_args, 0, Value::Null);
10397        let mut params = get_arg(optional_args, 1, Value::Map({
10398    let mut m = indexmap::IndexMap::new();
10399    m
10400}));
10401        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickersWs() is not supported yet".into()))));
10402
10403    Value::Null
10404} }
10405
10406    fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10407        let mut since = get_arg(optional_args, 0, Value::Null);
10408        let mut limit = get_arg(optional_args, 1, Value::Null);
10409        let mut params = get_arg(optional_args, 2, Value::Map({
10410    let mut m = indexmap::IndexMap::new();
10411    m
10412}));
10413        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradesWs() is not supported yet".into()))));
10414
10415    Value::Null
10416} }
10417
10418
10419    fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10420        // async-virtual: try the derived exchange first
10421        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 {
10422            if !matches!(__v, crate::Value::Null) { return __v; }
10423        }
10424
10425        let mut since = get_arg(optional_args, 0, Value::Null);
10426        let mut limit = get_arg(optional_args, 1, Value::Null);
10427        let mut params = get_arg(optional_args, 2, Value::Map({
10428    let mut m = indexmap::IndexMap::new();
10429    m
10430}));
10431        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() is not supported yet".into()))));
10432
10433    Value::Null
10434} }
10435
10436    fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10437        let mut since = get_arg(optional_args, 0, Value::Null);
10438        let mut limit = get_arg(optional_args, 1, Value::Null);
10439        let mut params = get_arg(optional_args, 2, Value::Map({
10440    let mut m = indexmap::IndexMap::new();
10441    m
10442}));
10443        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTrades() is not supported yet".into()))));
10444
10445    Value::Null
10446} }
10447
10448    fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10449        // async-virtual: try the derived exchange first
10450        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 {
10451            if !matches!(__v, crate::Value::Null) { return __v; }
10452        }
10453
10454        let mut limit = get_arg(optional_args, 0, Value::Null);
10455        let mut params = get_arg(optional_args, 1, Value::Map({
10456    let mut m = indexmap::IndexMap::new();
10457    m
10458}));
10459        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() is not supported yet".into()))));
10460
10461    Value::Null
10462} }
10463
10464    fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10465        let mut limit = get_arg(optional_args, 0, Value::Null);
10466        let mut params = get_arg(optional_args, 1, Value::Map({
10467    let mut m = indexmap::IndexMap::new();
10468    m
10469}));
10470        let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".into()), Value::Str("maxRetries".into()), &[Value::Int(3)]);
10471        {
10472                        let mut i: Value = Value::Int(0);
10473            let mut __for_first_180: bool = true;
10474            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) } {
10475            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10476                let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10477                return orderBook;
10478             #[allow(unreachable_code)] { Value::Null }})).await;
10479match _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); 
10480                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) {
10481                    panic!("{}", e);
10482                }
10483             } }
10484        }
10485        }
10486        return Value::Null;
10487
10488    Value::Null
10489} }
10490
10491    fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10492        let mut limit = get_arg(optional_args, 0, Value::Null);
10493        let mut params = get_arg(optional_args, 1, Value::Map({
10494    let mut m = indexmap::IndexMap::new();
10495    m
10496}));
10497        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBook() is not supported yet".into()))));
10498
10499    Value::Null
10500} }
10501
10502    fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10503        // async-virtual: try the derived exchange first
10504        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 {
10505            if !matches!(__v, crate::Value::Null) { return __v; }
10506        }
10507
10508        let mut params = get_arg(optional_args, 0, Value::Map({
10509    let mut m = indexmap::IndexMap::new();
10510    m
10511}));
10512        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)) {
10513            let mut openInterests: Value = self.fetch_open_interests(&[Value::from(vec![symbol.clone()]), params]).await;
10514            let mut openInterest: Value = self.safe_dict(openInterests, symbol, &[]);
10515            return openInterest;
10516        }  else {
10517            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterest() is not supported yet".into()))));
10518        }
10519
10520    Value::Null
10521} }
10522
10523    fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10524        let mut limit = get_arg(optional_args, 0, Value::Null);
10525        let mut params = get_arg(optional_args, 1, Value::Map({
10526    let mut m = indexmap::IndexMap::new();
10527    m
10528}));
10529        let mut orderbook: Value = self.fetch_order_book(symbol, &[limit, params]).await;
10530        return self.extend(orderbook.clone(), &[Value::Map({
10531    let mut m = indexmap::IndexMap::new();
10532        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), &[]));
10533        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)]));
10534    m
10535})]);
10536
10537    Value::Null
10538} }
10539
10540    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 {
10541        let mut price = get_arg(optional_args, 0, Value::Null);
10542        let mut params = get_arg(optional_args, 1, Value::Map({
10543    let mut m = indexmap::IndexMap::new();
10544    m
10545}));
10546        return self.edit_limit_order(id, symbol, Value::Str("buy".into()), amount, &[price, params]).await;
10547
10548    Value::Null
10549} }
10550
10551    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 {
10552        let mut price = get_arg(optional_args, 0, Value::Null);
10553        let mut params = get_arg(optional_args, 1, Value::Map({
10554    let mut m = indexmap::IndexMap::new();
10555    m
10556}));
10557        return self.edit_limit_order(id, symbol, Value::Str("sell".into()), amount, &[price, params]).await;
10558
10559    Value::Null
10560} }
10561
10562    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 {
10563        let mut price = get_arg(optional_args, 0, Value::Null);
10564        let mut params = get_arg(optional_args, 1, Value::Map({
10565    let mut m = indexmap::IndexMap::new();
10566    m
10567}));
10568        return self.edit_order(id, symbol, Value::Str("limit".into()), side, &[amount, price, params]).await;
10569
10570    Value::Null
10571} }
10572
10573    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 {
10574        // async-virtual: try the derived exchange first
10575        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 {
10576            if !matches!(__v, crate::Value::Null) { return __v; }
10577        }
10578
10579        let mut amount = get_arg(optional_args, 0, Value::Null);
10580        let mut price = get_arg(optional_args, 1, Value::Null);
10581        let mut params = get_arg(optional_args, 2, Value::Map({
10582    let mut m = indexmap::IndexMap::new();
10583    m
10584}));
10585        self.cancel_order(id, &[symbol.clone()]).await;
10586        return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10587
10588    Value::Null
10589} }
10590
10591    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 {
10592        let mut amount = get_arg(optional_args, 0, Value::Null);
10593        let mut price = get_arg(optional_args, 1, Value::Null);
10594        let mut params = get_arg(optional_args, 2, Value::Map({
10595    let mut m = indexmap::IndexMap::new();
10596    m
10597}));
10598        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10599            let mut m = indexmap::IndexMap::new();
10600                m.insert("clientOrderId".to_string(), clientOrderId);
10601            m
10602        })]);
10603        return self.edit_order(Value::Str("".into()), symbol, type_var, side, &[amount, price, extendedParams]).await;
10604
10605    Value::Null
10606} }
10607
10608    fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10609        // async-virtual: try the derived exchange first
10610        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 {
10611            if !matches!(__v, crate::Value::Null) { return __v; }
10612        }
10613
10614        let mut params = get_arg(optional_args, 0, Value::Map({
10615    let mut m = indexmap::IndexMap::new();
10616    m
10617}));
10618        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPosition() is not supported yet".into()))));
10619
10620    Value::Null
10621} }
10622
10623    fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10624        let mut symbols = get_arg(optional_args, 0, Value::Null);
10625        let mut since = get_arg(optional_args, 1, Value::Null);
10626        let mut limit = get_arg(optional_args, 2, Value::Null);
10627        let mut params = get_arg(optional_args, 3, Value::Map({
10628    let mut m = indexmap::IndexMap::new();
10629    m
10630}));
10631        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPositions() is not supported yet".into()))));
10632
10633    Value::Null
10634} }
10635
10636    fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10637        let mut symbols = get_arg(optional_args, 0, Value::Null);
10638        let mut since = get_arg(optional_args, 1, Value::Null);
10639        let mut limit = get_arg(optional_args, 2, Value::Null);
10640        let mut params = get_arg(optional_args, 3, Value::Map({
10641    let mut m = indexmap::IndexMap::new();
10642    m
10643}));
10644        return self.watch_positions(&[symbols, since, limit, params]).await;
10645
10646    Value::Null
10647} }
10648
10649    fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10650        // async-virtual: try the derived exchange first
10651        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 {
10652            if !matches!(__v, crate::Value::Null) { return __v; }
10653        }
10654
10655        let mut symbols = get_arg(optional_args, 0, Value::Null);
10656        let mut params = get_arg(optional_args, 1, Value::Map({
10657    let mut m = indexmap::IndexMap::new();
10658    m
10659}));
10660        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10661
10662    Value::Null
10663} }
10664
10665    fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10666        // async-virtual: try the derived exchange first
10667        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 {
10668            if !matches!(__v, crate::Value::Null) { return __v; }
10669        }
10670
10671        let mut params = get_arg(optional_args, 0, Value::Map({
10672    let mut m = indexmap::IndexMap::new();
10673    m
10674}));
10675        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)) {
10676            self.load_markets(&[]).await;
10677            let mut market: Value = self.market(symbol);
10678            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10679            let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10680            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10681            if (ticker == Value::Null) {
10682                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)));
10683            }  else {
10684                return ticker;
10685            }
10686        }  else {
10687            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() is not supported yet".into()))));
10688        }
10689
10690    Value::Null
10691} }
10692
10693    fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10694        let mut params = get_arg(optional_args, 0, Value::Map({
10695    let mut m = indexmap::IndexMap::new();
10696    m
10697}));
10698        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTicker() is not supported yet".into()))));
10699
10700    Value::Null
10701} }
10702
10703    fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10704        // async-virtual: try the derived exchange first
10705        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 {
10706            if !matches!(__v, crate::Value::Null) { return __v; }
10707        }
10708
10709        let mut symbols = get_arg(optional_args, 0, Value::Null);
10710        let mut params = get_arg(optional_args, 1, Value::Map({
10711    let mut m = indexmap::IndexMap::new();
10712    m
10713}));
10714        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() is not supported yet".into()))));
10715
10716    Value::Null
10717} }
10718
10719    fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10720        let mut symbols = get_arg(optional_args, 0, Value::Null);
10721        let mut params = get_arg(optional_args, 1, Value::Map({
10722    let mut m = indexmap::IndexMap::new();
10723    m
10724}));
10725        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTickers() is not supported yet".into()))));
10726
10727    Value::Null
10728} }
10729
10730    fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10731        // async-virtual: try the derived exchange first
10732        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 {
10733            if !matches!(__v, crate::Value::Null) { return __v; }
10734        }
10735
10736        let mut symbol = get_arg(optional_args, 0, Value::Null);
10737        let mut params = get_arg(optional_args, 1, Value::Map({
10738    let mut m = indexmap::IndexMap::new();
10739    m
10740}));
10741        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() is not supported yet".into()))));
10742
10743    Value::Null
10744} }
10745
10746/*
10747 * @method
10748 * @name fetchOrderWithClientOrderId
10749 * @description create a market order by providing the symbol, side and cost
10750 * @param {string} clientOrderId client order Id
10751 * @param {string} symbol unified symbol of the market to create an order in
10752 * @param {object} [params] extra parameters specific to the exchange API endpoint
10753 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10754 */
10755    fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10756        let mut symbol = get_arg(optional_args, 0, Value::Null);
10757        let mut params = get_arg(optional_args, 1, Value::Map({
10758    let mut m = indexmap::IndexMap::new();
10759    m
10760}));
10761        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10762            let mut m = indexmap::IndexMap::new();
10763                m.insert("clientOrderId".to_string(), clientOrderId);
10764            m
10765        })]);
10766        return self.fetch_order(Value::Str("".into()), &[symbol, extendedParams]).await;
10767
10768    Value::Null
10769} }
10770
10771    fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10772        let mut symbol = get_arg(optional_args, 0, Value::Null);
10773        let mut params = get_arg(optional_args, 1, Value::Map({
10774    let mut m = indexmap::IndexMap::new();
10775    m
10776}));
10777        // TODO: TypeScript: change method signature by replacing
10778        // Promise<string> with Promise<Order['status']>.
10779        let mut order: Value = self.fetch_order(id, &[symbol, params]).await;
10780        return order.as_map().and_then(|__m| __m.get("status")).cloned().unwrap_or(Value::Null);
10781
10782    Value::Null
10783} }
10784
10785    fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10786        let mut params = get_arg(optional_args, 0, Value::Map({
10787    let mut m = indexmap::IndexMap::new();
10788    m
10789}));
10790        return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
10791
10792    Value::Null
10793} }
10794
10795    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 {
10796        // async-virtual: try the derived exchange first
10797        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 {
10798            if !matches!(__v, crate::Value::Null) { return __v; }
10799        }
10800
10801        let mut price = get_arg(optional_args, 0, Value::Null);
10802        let mut params = get_arg(optional_args, 1, Value::Map({
10803    let mut m = indexmap::IndexMap::new();
10804    m
10805}));
10806        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() is not supported yet".into()))));
10807
10808    Value::Null
10809} }
10810
10811    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 {
10812        let mut price = get_arg(optional_args, 0, Value::Null);
10813        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10814        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10815        let mut params = get_arg(optional_args, 3, Value::Map({
10816    let mut m = indexmap::IndexMap::new();
10817    m
10818}));
10819        /*
10820         * @method
10821         * @name createTrailingAmountOrder
10822         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
10823         * @param {string} symbol unified symbol of the market to create an order in
10824         * @param {string} type 'market' or 'limit'
10825         * @param {string} side 'buy' or 'sell'
10826         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10827         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10828         * @param {float} trailingAmount the quote amount to trail away from the current market price
10829         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10830         * @param {object} [params] extra parameters specific to the exchange API endpoint
10831         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10832         */
10833        if (trailingAmount == Value::Null) {
10834            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".into()))));
10835        }
10836        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10837        if (trailingTriggerPrice != Value::Null) {
10838            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10839        }
10840        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)) {
10841            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10842        }
10843        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() is not supported yet".into()))));
10844
10845    Value::Null
10846} }
10847
10848    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 {
10849        let mut price = get_arg(optional_args, 0, Value::Null);
10850        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10851        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10852        let mut params = get_arg(optional_args, 3, Value::Map({
10853    let mut m = indexmap::IndexMap::new();
10854    m
10855}));
10856        /*
10857         * @method
10858         * @name createTrailingPercentOrder
10859         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
10860         * @param {string} symbol unified symbol of the market to create an order in
10861         * @param {string} type 'market' or 'limit'
10862         * @param {string} side 'buy' or 'sell'
10863         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10864         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10865         * @param {float} trailingPercent the percent to trail away from the current market price
10866         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10867         * @param {object} [params] extra parameters specific to the exchange API endpoint
10868         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10869         */
10870        if (trailingPercent == Value::Null) {
10871            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".into()))));
10872        }
10873        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10874        if (trailingTriggerPrice != Value::Null) {
10875            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10876        }
10877        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)) {
10878            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10879        }
10880        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() is not supported yet".into()))));
10881
10882    Value::Null
10883} }
10884
10885    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 {
10886        let mut params = get_arg(optional_args, 0, Value::Map({
10887    let mut m = indexmap::IndexMap::new();
10888    m
10889}));
10890        /*
10891         * @method
10892         * @name createMarketOrderWithCost
10893         * @description create a market order by providing the symbol, side and cost
10894         * @param {string} symbol unified symbol of the market to create an order in
10895         * @param {string} side 'buy' or 'sell'
10896         * @param {float} cost how much you want to trade in units of the quote currency
10897         * @param {object} [params] extra parameters specific to the exchange API endpoint
10898         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10899         */
10900        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)))) {
10901            return self.create_order(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
10902        }
10903        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCost() is not supported yet".into()))));
10904
10905    Value::Null
10906} }
10907
10908    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 {
10909        let mut params = get_arg(optional_args, 0, Value::Map({
10910    let mut m = indexmap::IndexMap::new();
10911    m
10912}));
10913        /*
10914         * @method
10915         * @name createMarketBuyOrderWithCost
10916         * @description create a market buy order by providing the symbol and cost
10917         * @param {string} symbol unified symbol of the market to create an order in
10918         * @param {float} cost how much you want to trade in units of the quote currency
10919         * @param {object} [params] extra parameters specific to the exchange API endpoint
10920         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10921         */
10922        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))) {
10923            return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Int(1), params]).await;
10924        }
10925        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() is not supported yet".into()))));
10926
10927    Value::Null
10928} }
10929
10930    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 {
10931        let mut params = get_arg(optional_args, 0, Value::Map({
10932    let mut m = indexmap::IndexMap::new();
10933    m
10934}));
10935        /*
10936         * @method
10937         * @name createMarketSellOrderWithCost
10938         * @description create a market sell order by providing the symbol and cost
10939         * @param {string} symbol unified symbol of the market to create an order in
10940         * @param {float} cost how much you want to trade in units of the quote currency
10941         * @param {object} [params] extra parameters specific to the exchange API endpoint
10942         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10943         */
10944        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))) {
10945            return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), cost, &[Value::Int(1), params]).await;
10946        }
10947        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketSellOrderWithCost() is not supported yet".into()))));
10948
10949    Value::Null
10950} }
10951
10952    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 {
10953        let mut price = get_arg(optional_args, 0, Value::Null);
10954        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10955        let mut params = get_arg(optional_args, 2, Value::Map({
10956    let mut m = indexmap::IndexMap::new();
10957    m
10958}));
10959        /*
10960         * @method
10961         * @name createTriggerOrder
10962         * @description create a trigger stop order (type 1)
10963         * @param {string} symbol unified symbol of the market to create an order in
10964         * @param {string} type 'market' or 'limit'
10965         * @param {string} side 'buy' or 'sell'
10966         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10967         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10968         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10969         * @param {object} [params] extra parameters specific to the exchange API endpoint
10970         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10971         */
10972        if (triggerPrice == Value::Null) {
10973            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() requires a triggerPrice argument".into()))));
10974        }
10975        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10976            let mut m = indexmap::IndexMap::new();
10977                m.insert("triggerPrice".to_string(), triggerPrice);
10978            m
10979        })]);
10980        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)) {
10981            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10982        }
10983        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() is not supported yet".into()))));
10984
10985    Value::Null
10986} }
10987
10988    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 {
10989        let mut price = get_arg(optional_args, 0, Value::Null);
10990        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10991        let mut params = get_arg(optional_args, 2, Value::Map({
10992    let mut m = indexmap::IndexMap::new();
10993    m
10994}));
10995        /*
10996         * @method
10997         * @name createStopLossOrder
10998         * @description create a trigger stop loss order (type 2)
10999         * @param {string} symbol unified symbol of the market to create an order in
11000         * @param {string} type 'market' or 'limit'
11001         * @param {string} side 'buy' or 'sell'
11002         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11003         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11004         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
11005         * @param {object} [params] extra parameters specific to the exchange API endpoint
11006         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11007         */
11008        if (stopLossPrice == Value::Null) {
11009            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() requires a stopLossPrice argument".into()))));
11010        }
11011        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11012            let mut m = indexmap::IndexMap::new();
11013                m.insert("stopLossPrice".to_string(), stopLossPrice);
11014            m
11015        })]);
11016        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)) {
11017            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11018        }
11019        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() is not supported yet".into()))));
11020
11021    Value::Null
11022} }
11023
11024    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 {
11025        let mut price = get_arg(optional_args, 0, Value::Null);
11026        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
11027        let mut params = get_arg(optional_args, 2, Value::Map({
11028    let mut m = indexmap::IndexMap::new();
11029    m
11030}));
11031        /*
11032         * @method
11033         * @name createTakeProfitOrder
11034         * @description create a trigger take profit order (type 2)
11035         * @param {string} symbol unified symbol of the market to create an order in
11036         * @param {string} type 'market' or 'limit'
11037         * @param {string} side 'buy' or 'sell'
11038         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11039         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11040         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
11041         * @param {object} [params] extra parameters specific to the exchange API endpoint
11042         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11043         */
11044        if (takeProfitPrice == Value::Null) {
11045            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".into()))));
11046        }
11047        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11048            let mut m = indexmap::IndexMap::new();
11049                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
11050            m
11051        })]);
11052        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)) {
11053            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11054        }
11055        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() is not supported yet".into()))));
11056
11057    Value::Null
11058} }
11059
11060    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 {
11061        let mut price = get_arg(optional_args, 0, Value::Null);
11062        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
11063        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
11064        let mut params = get_arg(optional_args, 3, Value::Map({
11065    let mut m = indexmap::IndexMap::new();
11066    m
11067}));
11068        /*
11069         * @method
11070         * @name createOrderWithTakeProfitAndStopLoss
11071         * @description create an order with a stop loss or take profit attached (type 3)
11072         * @param {string} symbol unified symbol of the market to create an order in
11073         * @param {string} type 'market' or 'limit'
11074         * @param {string} side 'buy' or 'sell'
11075         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11076         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11077         * @param {float} [takeProfit] the take profit price, in units of the quote currency
11078         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
11079         * @param {object} [params] extra parameters specific to the exchange API endpoint
11080         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
11081         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
11082         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
11083         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
11084         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
11085         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
11086         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
11087         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
11088         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11089         */
11090        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()]);
11091        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)) {
11092            return self.create_order(symbol, type_var, side, amount, &[price, paramsValue]).await;
11093        }
11094        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".into()))));
11095
11096    Value::Null
11097} }
11098
11099    fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11100        // async-virtual: try the derived exchange first
11101        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 {
11102            if !matches!(__v, crate::Value::Null) { return __v; }
11103        }
11104
11105        let mut params = get_arg(optional_args, 0, Value::Map({
11106    let mut m = indexmap::IndexMap::new();
11107    m
11108}));
11109        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrders() is not supported yet".into()))));
11110
11111    Value::Null
11112} }
11113
11114    fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11115        // async-virtual: try the derived exchange first
11116        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 {
11117            if !matches!(__v, crate::Value::Null) { return __v; }
11118        }
11119
11120        let mut symbol = get_arg(optional_args, 0, Value::Null);
11121        let mut params = get_arg(optional_args, 1, Value::Map({
11122    let mut m = indexmap::IndexMap::new();
11123    m
11124}));
11125        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() is not supported yet".into()))));
11126
11127    Value::Null
11128} }
11129
11130/*
11131 * @method
11132 * @name cancelOrderWithClientOrderId
11133 * @description create a market order by providing the symbol, side and cost
11134 * @param {string} clientOrderId client order Id
11135 * @param {string} symbol unified symbol of the market to create an order in
11136 * @param {object} [params] extra parameters specific to the exchange API endpoint
11137 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11138 */
11139    fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11140        let mut symbol = get_arg(optional_args, 0, Value::Null);
11141        let mut params = get_arg(optional_args, 1, Value::Map({
11142    let mut m = indexmap::IndexMap::new();
11143    m
11144}));
11145        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11146            let mut m = indexmap::IndexMap::new();
11147                m.insert("clientOrderId".to_string(), clientOrderId);
11148            m
11149        })]);
11150        return self.cancel_order(Value::Str("".into()), &[symbol, extendedParams]).await;
11151
11152    Value::Null
11153} }
11154
11155    fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11156        // async-virtual: try the derived exchange first
11157        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 {
11158            if !matches!(__v, crate::Value::Null) { return __v; }
11159        }
11160
11161        let mut symbol = get_arg(optional_args, 0, Value::Null);
11162        let mut params = get_arg(optional_args, 1, Value::Map({
11163    let mut m = indexmap::IndexMap::new();
11164    m
11165}));
11166        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() is not supported yet".into()))));
11167
11168    Value::Null
11169} }
11170
11171/*
11172 * @method
11173 * @name cancelOrdersWithClientOrderIds
11174 * @description create a market order by providing the symbol, side and cost
11175 * @param {string[]} clientOrderIds client order Ids
11176 * @param {string} symbol unified symbol of the market to create an order in
11177 * @param {object} [params] extra parameters specific to the exchange API endpoint
11178 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11179 */
11180    fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11181        let mut symbol = get_arg(optional_args, 0, Value::Null);
11182        let mut params = get_arg(optional_args, 1, Value::Map({
11183    let mut m = indexmap::IndexMap::new();
11184    m
11185}));
11186        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11187            let mut m = indexmap::IndexMap::new();
11188                m.insert("clientOrderIds".to_string(), clientOrderIds);
11189            m
11190        })]);
11191        return self.cancel_orders(Value::from(vec![]), &[symbol, extendedParams]).await;
11192
11193    Value::Null
11194} }
11195
11196    fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11197        // async-virtual: try the derived exchange first
11198        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 {
11199            if !matches!(__v, crate::Value::Null) { return __v; }
11200        }
11201
11202        let mut symbol = get_arg(optional_args, 0, Value::Null);
11203        let mut params = get_arg(optional_args, 1, Value::Map({
11204    let mut m = indexmap::IndexMap::new();
11205    m
11206}));
11207        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() is not supported yet".into()))));
11208
11209    Value::Null
11210} }
11211
11212    fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11213        let mut params = get_arg(optional_args, 0, Value::Map({
11214    let mut m = indexmap::IndexMap::new();
11215    m
11216}));
11217        return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11218
11219    Value::Null
11220} }
11221
11222    fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11223        // async-virtual: try the derived exchange first
11224        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 {
11225            if !matches!(__v, crate::Value::Null) { return __v; }
11226        }
11227
11228        let mut symbol = get_arg(optional_args, 0, Value::Null);
11229        let mut since = get_arg(optional_args, 1, Value::Null);
11230        let mut limit = get_arg(optional_args, 2, Value::Null);
11231        let mut params = get_arg(optional_args, 3, Value::Map({
11232    let mut m = indexmap::IndexMap::new();
11233    m
11234}));
11235        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))) {
11236            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".into()))));
11237        }
11238        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet".into()))));
11239
11240    Value::Null
11241} }
11242
11243    fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11244        let mut symbol = get_arg(optional_args, 0, Value::Null);
11245        let mut since = get_arg(optional_args, 1, Value::Null);
11246        let mut limit = get_arg(optional_args, 2, Value::Null);
11247        let mut params = get_arg(optional_args, 3, Value::Map({
11248    let mut m = indexmap::IndexMap::new();
11249    m
11250}));
11251        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderTrades() is not supported yet".into()))));
11252
11253    Value::Null
11254} }
11255
11256    fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11257        let mut symbol = get_arg(optional_args, 0, Value::Null);
11258        let mut since = get_arg(optional_args, 1, Value::Null);
11259        let mut limit = get_arg(optional_args, 2, Value::Null);
11260        let mut params = get_arg(optional_args, 3, Value::Map({
11261    let mut m = indexmap::IndexMap::new();
11262    m
11263}));
11264        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrders() is not supported yet".into()))));
11265
11266    Value::Null
11267} }
11268
11269    fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11270        // async-virtual: try the derived exchange first
11271        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 {
11272            if !matches!(__v, crate::Value::Null) { return __v; }
11273        }
11274
11275        let mut symbol = get_arg(optional_args, 0, Value::Null);
11276        let mut since = get_arg(optional_args, 1, Value::Null);
11277        let mut limit = get_arg(optional_args, 2, Value::Null);
11278        let mut params = get_arg(optional_args, 3, Value::Map({
11279    let mut m = indexmap::IndexMap::new();
11280    m
11281}));
11282        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)) {
11283            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11284            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
11285        }
11286        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() is not supported yet".into()))));
11287
11288    Value::Null
11289} }
11290
11291    fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11292        // async-virtual: try the derived exchange first
11293        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 {
11294            if !matches!(__v, crate::Value::Null) { return __v; }
11295        }
11296
11297        let mut symbol = get_arg(optional_args, 0, Value::Null);
11298        let mut since = get_arg(optional_args, 1, Value::Null);
11299        let mut limit = get_arg(optional_args, 2, Value::Null);
11300        let mut params = get_arg(optional_args, 3, Value::Map({
11301    let mut m = indexmap::IndexMap::new();
11302    m
11303}));
11304        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)) {
11305            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11306            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
11307        }
11308        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrders() is not supported yet".into()))));
11309
11310    Value::Null
11311} }
11312
11313    fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11314        let mut symbol = get_arg(optional_args, 0, Value::Null);
11315        let mut since = get_arg(optional_args, 1, Value::Null);
11316        let mut limit = get_arg(optional_args, 2, Value::Null);
11317        let mut params = get_arg(optional_args, 3, Value::Map({
11318    let mut m = indexmap::IndexMap::new();
11319    m
11320}));
11321        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledOrders() is not supported yet".into()))));
11322
11323    Value::Null
11324} }
11325
11326    fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11327        // async-virtual: try the derived exchange first
11328        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 {
11329            if !matches!(__v, crate::Value::Null) { return __v; }
11330        }
11331
11332        let mut symbol = get_arg(optional_args, 0, Value::Null);
11333        let mut since = get_arg(optional_args, 1, Value::Null);
11334        let mut limit = get_arg(optional_args, 2, Value::Null);
11335        let mut params = get_arg(optional_args, 3, Value::Map({
11336    let mut m = indexmap::IndexMap::new();
11337    m
11338}));
11339        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() is not supported yet".into()))));
11340
11341    Value::Null
11342} }
11343
11344    fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11345        let mut symbol = get_arg(optional_args, 0, Value::Null);
11346        let mut since = get_arg(optional_args, 1, Value::Null);
11347        let mut limit = get_arg(optional_args, 2, Value::Null);
11348        let mut params = get_arg(optional_args, 3, Value::Map({
11349    let mut m = indexmap::IndexMap::new();
11350    m
11351}));
11352        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTrades() is not supported yet".into()))));
11353
11354    Value::Null
11355} }
11356
11357    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 {
11358        let mut params = get_arg(optional_args, 0, Value::Map({
11359    let mut m = indexmap::IndexMap::new();
11360    m
11361}));
11362        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
11363
11364    Value::Null
11365} }
11366
11367    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 {
11368        let mut price = get_arg(optional_args, 0, Value::Null);
11369        let mut params = get_arg(optional_args, 1, Value::Map({
11370    let mut m = indexmap::IndexMap::new();
11371    m
11372}));
11373        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
11374
11375    Value::Null
11376} }
11377
11378    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 {
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("buy".into()), amount, &[price, params]).await;
11384
11385    Value::Null
11386} }
11387
11388    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 {
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("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
11394
11395    Value::Null
11396} }
11397
11398    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 {
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("buy".into()), amount, &[Value::Null, params]).await;
11404
11405    Value::Null
11406} }
11407
11408    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 {
11409        let mut params = get_arg(optional_args, 0, Value::Map({
11410    let mut m = indexmap::IndexMap::new();
11411    m
11412}));
11413        return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
11414
11415    Value::Null
11416} }
11417
11418    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 {
11419        let mut price = get_arg(optional_args, 0, Value::Null);
11420        let mut params = get_arg(optional_args, 1, Value::Map({
11421    let mut m = indexmap::IndexMap::new();
11422    m
11423}));
11424        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)) {
11425            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrder() is not supported yet".into()))));
11426        }
11427        let mut query: Value = self.extend(params, &[Value::Map({
11428            let mut m = indexmap::IndexMap::new();
11429                m.insert("postOnly".to_string(), Value::Bool(true));
11430            m
11431        })]);
11432        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11433
11434    Value::Null
11435} }
11436
11437    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 {
11438        let mut price = get_arg(optional_args, 0, Value::Null);
11439        let mut params = get_arg(optional_args, 1, Value::Map({
11440    let mut m = indexmap::IndexMap::new();
11441    m
11442}));
11443        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)) {
11444            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrder() is not supported yet".into()))));
11445        }
11446        let mut query: Value = self.extend(params, &[Value::Map({
11447            let mut m = indexmap::IndexMap::new();
11448                m.insert("reduceOnly".to_string(), Value::Bool(true));
11449            m
11450        })]);
11451        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11452
11453    Value::Null
11454} }
11455
11456    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 {
11457        let mut price = get_arg(optional_args, 0, Value::Null);
11458        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11459        let mut params = get_arg(optional_args, 2, Value::Map({
11460    let mut m = indexmap::IndexMap::new();
11461    m
11462}));
11463        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)) {
11464            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrder() is not supported yet".into()))));
11465        }
11466        if (triggerPrice == Value::Null) {
11467            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" create_stop_order() requires a stopPrice argument".into()))));
11468        }
11469        let mut query: Value = self.extend(params, &[Value::Map({
11470            let mut m = indexmap::IndexMap::new();
11471                m.insert("stopPrice".to_string(), triggerPrice);
11472            m
11473        })]);
11474        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11475
11476    Value::Null
11477} }
11478
11479    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 {
11480        let mut params = get_arg(optional_args, 0, Value::Map({
11481    let mut m = indexmap::IndexMap::new();
11482    m
11483}));
11484        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)) {
11485            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrder() is not supported yet".into()))));
11486        }
11487        let mut query: Value = self.extend(params, &[Value::Map({
11488            let mut m = indexmap::IndexMap::new();
11489                m.insert("stopPrice".to_string(), triggerPrice);
11490            m
11491        })]);
11492        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
11493
11494    Value::Null
11495} }
11496
11497    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 {
11498        let mut params = get_arg(optional_args, 0, Value::Map({
11499    let mut m = indexmap::IndexMap::new();
11500    m
11501}));
11502        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)) {
11503            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrder() is not supported yet".into()))));
11504        }
11505        let mut query: Value = self.extend(params, &[Value::Map({
11506            let mut m = indexmap::IndexMap::new();
11507                m.insert("stopPrice".to_string(), triggerPrice);
11508            m
11509        })]);
11510        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
11511
11512    Value::Null
11513} }
11514
11515    fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11516        // async-virtual: try the derived exchange first
11517        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 {
11518            if !matches!(__v, crate::Value::Null) { return __v; }
11519        }
11520
11521        let mut params = get_arg(optional_args, 0, Value::Map({
11522    let mut m = indexmap::IndexMap::new();
11523    m
11524}));
11525        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)) {
11526            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFee() is not supported yet".into()))));
11527        }
11528        let mut fees: Value = self.fetch_trading_fees(&[params]).await;
11529        let mut fee: Value = self.safe_dict(fees, symbol, &[]);
11530        return fee;
11531
11532    Value::Null
11533} }
11534    /// Base-method fall-through for a core's `call_dynamic`.
11535    fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11536        -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11537    {
11538        Box::pin(async move {
11539            match method {
11540            "account" => self.account(),
11541            "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)),
11542            "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,
11543            "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)),
11544            "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11545            "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())..]),
11546            "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,
11547            "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,
11548            "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,
11549            "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11550            "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())..]),
11551            "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())..]),
11552            "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())..]),
11553            "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11554            "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args[..]).await,
11555            "cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
11556            "cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11557            "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args[..]).await,
11558            "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args[..]).await,
11559            "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11560            "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11561            "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,
11562            "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11563            "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11564            "cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11565            "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,
11566            "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11567            "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11568            "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11569            "check_address" => self.check_address(&args[..]),
11570            "check_proxy_settings" => self.check_proxy_settings(&args[..]),
11571            "check_proxy_url_settings" => self.check_proxy_url_settings(&args[..]),
11572            "check_required_credentials" => self.check_required_credentials(&args[..]),
11573            "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11574            "close_all_positions" => self.close_all_positions(&args[..]).await,
11575            "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11576            "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11577            "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11578            "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11579            "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11580            "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())..]),
11581            "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())..]),
11582            "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11583            "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)),
11584            "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args[..]),
11585            "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11586            "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,
11587            "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11588            "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11589            "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,
11590            "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,
11591            "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,
11592            "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,
11593            "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,
11594            "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,
11595            "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,
11596            "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,
11597            "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,
11598            "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,
11599            "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,
11600            "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,
11601            "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,
11602            "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,
11603            "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,
11604            "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,
11605            "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)),
11606            "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,
11607            "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,
11608            "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,
11609            "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,
11610            "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11611            "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11612            "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,
11613            "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,
11614            "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,
11615            "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,
11616            "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11617            "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,
11618            "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,
11619            "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,
11620            "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,
11621            "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,
11622            "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,
11623            "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,
11624            "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,
11625            "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11626            "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,
11627            "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,
11628            "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,
11629            "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,
11630            "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,
11631            "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,
11632            "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,
11633            "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,
11634            "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,
11635            "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11636            "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11637            "currency_ids" => self.currency_ids(&args[..]),
11638            "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())..]),
11639            "default_network_code" => self.default_network_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11640            "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11641            "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,
11642            "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,
11643            "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,
11644            "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,
11645            "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,
11646            "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,
11647            "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11648            "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11649            "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())..]),
11650            "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())..]),
11651            "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)),
11652            "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11653            "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11654            "fetch_accounts" => self.fetch_accounts(&args[..]).await,
11655            "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11656            "fetch_all_greeks" => self.fetch_all_greeks(&args[..]).await,
11657            "fetch_balance" => self.fetch_balance(&args[..]).await,
11658            "fetch_balance_ws" => self.fetch_balance_ws(&args[..]).await,
11659            "fetch_bids_asks" => self.fetch_bids_asks(&args[..]).await,
11660            "fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
11661            "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,
11662            "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
11663            "fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
11664            "fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
11665            "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args[..]).await,
11666            "fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11667            "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11668            "fetch_contract_tickers" => self.fetch_contract_tickers(&args[..]).await,
11669            "fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
11670            "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,
11671            "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11672            "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
11673            "fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11674            "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args[..]).await,
11675            "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11676            "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args[..]).await,
11677            "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,
11678            "fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11679            "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
11680            "fetch_deposits" => self.fetch_deposits(&args[..]).await,
11681            "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
11682            "fetch_deposits_ws" => self.fetch_deposits_ws(&args[..]).await,
11683            "fetch_free_balance" => self.fetch_free_balance(&args[..]).await,
11684            "fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
11685            "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11686            "fetch_funding_intervals" => self.fetch_funding_intervals(&args[..]).await,
11687            "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11688            "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
11689            "fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
11690            "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11691            "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11692            "fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11693            "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args[..]).await,
11694            "fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11695            "fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11696            "fetch_last_prices" => self.fetch_last_prices(&args[..]).await,
11697            "fetch_ledger" => self.fetch_ledger(&args[..]).await,
11698            "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11699            "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11700            "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args[..]).await,
11701            "fetch_leverages" => self.fetch_leverages(&args[..]).await,
11702            "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11703            "fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11704            "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args[..]).await,
11705            "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args[..]).await,
11706            "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11707            "fetch_margin_modes" => self.fetch_margin_modes(&args[..]).await,
11708            "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11709            "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11710            "fetch_mark_prices" => self.fetch_mark_prices(&args[..]).await,
11711            "fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11712            "fetch_my_liquidations" => self.fetch_my_liquidations(&args[..]).await,
11713            "fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
11714            "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args[..]).await,
11715            "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11716            "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11717            "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11718            "fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11719            "fetch_open_interests" => self.fetch_open_interests(&args[..]).await,
11720            "fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
11721            "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args[..]).await,
11722            "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11723            "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11724            "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11725            "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11726            "fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11727            "fetch_order_books" => self.fetch_order_books(&args[..]).await,
11728            "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11729            "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11730            "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,
11731            "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11732            "fetch_orders" => self.fetch_orders(&args[..]).await,
11733            "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,
11734            "fetch_orders_ws" => self.fetch_orders_ws(&args[..]).await,
11735            "fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11736            "fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11737            "fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11738            "fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11739            "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11740            "fetch_payment_methods" => self.fetch_payment_methods(&args[..]).await,
11741            "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11742            "fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11743            "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11744            "fetch_position_mode" => self.fetch_position_mode(&args[..]).await,
11745            "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11746            "fetch_positions" => self.fetch_positions(&args[..]).await,
11747            "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args[..]).await,
11748            "fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11749            "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,
11750            "fetch_positions_history" => self.fetch_positions_history(&args[..]).await,
11751            "fetch_positions_risk" => self.fetch_positions_risk(&args[..]).await,
11752            "fetch_positions_ws" => self.fetch_positions_ws(&args[..]).await,
11753            "fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11754            "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,
11755            "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11756            "fetch_spot_tickers" => self.fetch_spot_tickers(&args[..]).await,
11757            "fetch_status" => self.fetch_status(&args[..]).await,
11758            "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11759            "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11760            "fetch_tickers" => self.fetch_tickers(&args[..]).await,
11761            "fetch_tickers_ws" => self.fetch_tickers_ws(&args[..]).await,
11762            "fetch_time" => self.fetch_time(&args[..]).await,
11763            "fetch_total_balance" => self.fetch_total_balance(&args[..]).await,
11764            "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11765            "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11766            "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11767            "fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
11768            "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args[..]).await,
11769            "fetch_trading_limits" => self.fetch_trading_limits(&args[..]).await,
11770            "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11771            "fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
11772            "fetch_transactions" => self.fetch_transactions(&args[..]).await,
11773            "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11774            "fetch_transfers" => self.fetch_transfers(&args[..]).await,
11775            "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11776            "fetch_used_balance" => self.fetch_used_balance(&args[..]).await,
11777            "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,
11778            "fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
11779            "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args[..]).await,
11780            "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())..]),
11781            "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())..]),
11782            "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())..]),
11783            "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())..]),
11784            "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())..]),
11785            "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())..]),
11786            "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11787            "filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11788            "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11789            "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())..]),
11790            "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())..]),
11791            "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())..]),
11792            "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())..]),
11793            "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)),
11794            "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)),
11795            "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)),
11796            "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11797            "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11798            "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)),
11799            "get_default_options" => self.get_default_options(),
11800            "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)),
11801            "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)),
11802            "get_market_from_symbols" => self.get_market_from_symbols(&args[..]),
11803            "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11804            "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args[..]),
11805            "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)),
11806            "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())..]),
11807            "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())..]),
11808            "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())..]),
11809            "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11810            "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())..]),
11811            "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())..]),
11812            "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())..]),
11813            "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())..]),
11814            "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())..]),
11815            "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())..]),
11816            "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())..]),
11817            "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())..]),
11818            "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())..]),
11819            "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())..]),
11820            "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())..]),
11821            "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())..]),
11822            "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())..]),
11823            "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())..]),
11824            "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())..]),
11825            "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())..]),
11826            "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())..]),
11827            "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())..]),
11828            "handle_time_in_force" => self.handle_time_in_force(&args[..]),
11829            "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11830            "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())..]),
11831            "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())..]),
11832            "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())..]),
11833            "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11834            "incrementing_nonce" => self.incrementing_nonce(),
11835            "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11836            "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11837            "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11838            "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11839            "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())..]),
11840            "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11841            "is_significant_precision" => self.is_significant_precision(),
11842            "is_tick_precision" => self.is_tick_precision(),
11843            "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11844            "is_uta_enabled" => self.is_uta_enabled(&args[..]).await,
11845            "load_accounts" => self.load_accounts(&args[..]).await,
11846            "load_markets" => self.load_markets(&args[..]).await,
11847            "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
11848            "load_time_difference" => self.load_time_difference(&args[..]).await,
11849            "load_trading_limits" => self.load_trading_limits(&args[..]).await,
11850            "market" => self.market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11851            "market_codes" => self.market_codes(&args[..]),
11852            "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11853            "market_ids" => self.market_ids(&args[..]),
11854            "market_or_null" => self.market_or_null(&args[..]),
11855            "market_symbols" => self.market_symbols(&args[..]),
11856            "markets_for_symbols" => self.markets_for_symbols(&args[..]),
11857            "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)),
11858            "network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11859            "network_id_to_code" => self.network_id_to_code(&args[..]),
11860            "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
11861            "oath" => self.oath(),
11862            "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11863            "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11864            "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11865            "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())..]),
11866            "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11867            "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11868            "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11869            "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())..]),
11870            "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11871            "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())..]),
11872            "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)),
11873            "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())..]),
11874            "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11875            "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11876            "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11877            "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())..]),
11878            "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11879            "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())..]),
11880            "parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11881            "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11882            "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())..]),
11883            "parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11884            "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())..]),
11885            "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11886            "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())..]),
11887            "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())..]),
11888            "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11889            "parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11890            "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11891            "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())..]),
11892            "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11893            "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11894            "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())..]),
11895            "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())..]),
11896            "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11897            "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11898            "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())..]),
11899            "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11900            "parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11901            "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())..]),
11902            "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())..]),
11903            "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11904            "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())..]),
11905            "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11906            "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11907            "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())..]),
11908            "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11909            "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11910            "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())..]),
11911            "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())..]),
11912            "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11913            "parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11914            "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11915            "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11916            "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())..]),
11917            "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())..]),
11918            "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())..]),
11919            "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())..]),
11920            "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11921            "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())..]),
11922            "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11923            "parse_precision" => self.parse_precision(&args[..]),
11924            "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())..]),
11925            "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11926            "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11927            "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11928            "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())..]),
11929            "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11930            "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())..]),
11931            "parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11932            "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())..]),
11933            "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11934            "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())..]),
11935            "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11936            "parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11937            "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11938            "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11939            "parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11940            "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11941            "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11942            "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11943            "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)),
11944            "prioritized_network_aliases" => self.prioritized_network_aliases(&args[..]),
11945            "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11946            "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,
11947            "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)),
11948            "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())..]),
11949            "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11950            "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,
11951            "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,
11952            "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,
11953            "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11954            "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11955            "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11956            "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11957            "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())..]),
11958            "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())..]),
11959            "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())..]),
11960            "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11961            "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11962            "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11963            "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11964            "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())..]),
11965            "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())..]),
11966            "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())..]),
11967            "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())..]),
11968            "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11969            "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11970            "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())..]),
11971            "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())..]),
11972            "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())..]),
11973            "safe_market" => self.safe_market(&args[..]),
11974            "safe_market_structure" => self.safe_market_structure(&args[..]),
11975            "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11976            "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())..]),
11977            "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())..]),
11978            "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())..]),
11979            "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())..]),
11980            "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11981            "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11982            "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11983            "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11984            "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11985            "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11986            "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)),
11987            "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)),
11988            "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())..]),
11989            "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11990            "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11991            "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,
11992            "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11993            "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11994            "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11995            "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11996            "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())..]),
11997            "sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11998            "sign_in" => self.sign_in(&args[..]).await,
11999            "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12000            "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12001            "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12002            "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12003            "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,
12004            "un_watch_bids_asks" => self.un_watch_bids_asks(&args[..]).await,
12005            "un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12006            "un_watch_funding_rates" => self.un_watch_funding_rates(&args[..]).await,
12007            "un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12008            "un_watch_mark_prices" => self.un_watch_mark_prices(&args[..]).await,
12009            "un_watch_my_trades" => self.un_watch_my_trades(&args[..]).await,
12010            "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12011            "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,
12012            "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12013            "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,
12014            "un_watch_orders" => self.un_watch_orders(&args[..]).await,
12015            "un_watch_positions" => self.un_watch_positions(&args[..]).await,
12016            "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12017            "un_watch_tickers" => self.un_watch_tickers(&args[..]).await,
12018            "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12019            "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,
12020            "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12021            "watch_balance" => self.watch_balance(&args[..]).await,
12022            "watch_bids_asks" => self.watch_bids_asks(&args[..]).await,
12023            "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12024            "watch_funding_rates" => self.watch_funding_rates(&args[..]).await,
12025            "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,
12026            "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12027            "watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12028            "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12029            "watch_mark_prices" => self.watch_mark_prices(&args[..]).await,
12030            "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12031            "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,
12032            "watch_my_trades" => self.watch_my_trades(&args[..]).await,
12033            "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,
12034            "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12035            "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12036            "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12037            "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,
12038            "watch_orders" => self.watch_orders(&args[..]).await,
12039            "watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12040            "watch_position" => self.watch_position(&args[..]).await,
12041            "watch_position_for_symbols" => self.watch_position_for_symbols(&args[..]).await,
12042            "watch_positions" => self.watch_positions(&args[..]).await,
12043            "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12044            "watch_tickers" => self.watch_tickers(&args[..]).await,
12045            "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12046            "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12047            "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,
12048            "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,
12049                // Implicit-API endpoints (`publicGetX`) exist only as inherent
12050                // methods on the venue's `<id>_api.rs`, which no name-based
12051                // dispatch arm covers — a static-request test named after one
12052                // (bingx's accountV1PrivateGetAccountApiRestrictions) otherwise
12053                // computes a null url. Route them the way those wrappers do.
12054                // Guarded on the api block so a genuinely unknown name still
12055                // returns Null rather than panicking inside call_method.
12056                //
12057                // Returning Null keeps an optional probe cheap, but a dynamic
12058                // re-entry (`fetchPaginatedCall*` / `fetchWebEndpoint`, which
12059                // reach here via `method_name_to_snake_case`) must not silently
12060                // see an empty page — so record the miss for
12061                // `crate::exchange::call_dynamic_required` to raise on.
12062                _ => {
12063                    if self.internals.implicit_api.is_empty() {
12064                        self.build_implicit_api();
12065                    }
12066                    if self.internals.implicit_api.contains_key(method) {
12067                        self.call_method(crate::Value::Str(method.to_string().into()), &args[..]).await
12068                    } else {
12069                        self.internals.dynamic_dispatch_miss = Some(method.to_string());
12070                        crate::Value::Null
12071                    }
12072                }
12073            }
12074        })
12075    }
12076}