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::Null);
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::Null);
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::Null);
117        m.insert("createMarketOrderWs".to_string(), Value::Null);
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::Null);
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::Null);
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::Null);
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::Null);
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::Str("emulated".into()));
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::Null);
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 self.is_dictionary(value.clone()).as_bool() == Some(true) {
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 self.is_dictionary(value.clone()).as_bool() == Some(true) {
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 self.is_dictionary(value.clone()).as_bool() == Some(true) {
599            return value;
600        }
601        let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
602        if self.is_dictionary(value2.clone()).as_bool() == Some(true) {
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 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_71 = false; i.as_f64().unwrap_or(f64::NAN) < ((deltas.len() as i64) as f64) } {
688            self.handle_delta(bookside.clone(), deltas.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));
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 { if let Value::Int(n) = &mut i { *n += 1; } } __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 { if let Value::Int(n) = &mut i { *n += 1; } } __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 { if let Value::Int(n) = &mut i { *n += 1; } } __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 { if let Value::Int(n) = &mut i { *n += 1; } } __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: Vec<Value> = Vec::new();
770        let mut proxyUrl: Value = Value::Null;
771        if (self.proxyUrl.clone() != Value::Null) {
772            usedProxies.push(Value::Str("proxyUrl".into()));
773            proxyUrl = self.proxyUrl.clone();
774        }
775        if (self.proxy_url.clone() != Value::Null) {
776            usedProxies.push(Value::Str("proxy_url".into()));
777            proxyUrl = self.proxy_url.clone();
778        }
779        if (self.proxyUrlCallback.clone() != Value::Null) {
780            usedProxies.push(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            usedProxies.push(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            usedProxies.push(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 = Value::Str(usedProxies.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(",").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: Vec<Value> = Vec::new();
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 isHttpProxyDefined.as_bool() == Some(true) || isHttp_proxy_defined.as_bool() == Some(true) {
828            usedProxies.push(Value::Str("httpProxy".into()));
829            httpProxy = (if isHttpProxyDefined.as_bool() == Some(true) { 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 ishttpProxyCallbackDefined.as_bool() == Some(true) || ishttp_proxy_callback_defined.as_bool() == Some(true) {
834            usedProxies.push(Value::Str("httpProxyCallback".into()));
835            httpProxy = (if ishttpProxyCallbackDefined.as_bool() == Some(true) { 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 isHttpsProxyDefined.as_bool() == Some(true) || isHttps_proxy_defined.as_bool() == Some(true) {
841            usedProxies.push(Value::Str("httpsProxy".into()));
842            httpsProxy = (if isHttpsProxyDefined.as_bool() == Some(true) { 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 ishttpsProxyCallbackDefined.as_bool() == Some(true) || ishttps_proxy_callback_defined.as_bool() == Some(true) {
847            usedProxies.push(Value::Str("httpsProxyCallback".into()));
848            httpsProxy = (if ishttpsProxyCallbackDefined.as_bool() == Some(true) { 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 isSocksProxyDefined.as_bool() == Some(true) || isSocks_proxy_defined.as_bool() == Some(true) {
854            usedProxies.push(Value::Str("socksProxy".into()));
855            socksProxy = (if isSocksProxyDefined.as_bool() == Some(true) { 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 issocksProxyCallbackDefined.as_bool() == Some(true) || issocks_proxy_callback_defined.as_bool() == Some(true) {
860            usedProxies.push(Value::Str("socksProxyCallback".into()));
861            socksProxy = (if issocksProxyCallbackDefined.as_bool() == Some(true) { 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 = Value::Str(usedProxies.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(",").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: Vec<Value> = Vec::new();
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 isWsProxyDefined.as_bool() == Some(true) || is_ws_proxy_defined.as_bool() == Some(true) {
883            usedProxies.push(Value::Str("wsProxy".into()));
884            wsProxy = (if isWsProxyDefined.as_bool() == Some(true) { 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 isWssProxyDefined.as_bool() == Some(true) || is_wss_proxy_defined.as_bool() == Some(true) {
890            usedProxies.push(Value::Str("wssProxy".into()));
891            wssProxy = (if isWssProxyDefined.as_bool() == Some(true) { 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 isWsSocksProxyDefined.as_bool() == Some(true) || is_ws_socks_proxy_defined.as_bool() == Some(true) {
897            usedProxies.push(Value::Str("wsSocksProxy".into()));
898            wsSocksProxy = (if isWsSocksProxyDefined.as_bool() == Some(true) { 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 = Value::Str(usedProxies.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(",").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()), Value::Str(format!("{}", self.minFundingAddressLength.clone()).into())).into()), Value::Str(" characters: \"".into())).into()), Value::Str(format!("{}", address).into())).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: Vec<Value> = Vec::new();
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 { if let Value::Int(n) = &mut i { *n += 1; } } __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 Value::Int(messageHash.as_str().zip(element.as_str()).and_then(|(__s, __n)| __s.find(__n)).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
954                result.push(messageHash);
955            }
956        }
957        }
958        return Value::from(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 = self.safe_float(array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), key.clone(), &[]);
973                    let mut last: Value = self.safe_float(array.as_array().and_then(|__arr| match &((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 })) { Value::Int(__n) if *__n >= 0 => __arr.get(*__n as usize), _ => None }).cloned().unwrap_or(Value::Null), key.clone(), &[]);
974                    if (first != Value::Null) && (last != Value::Null) {
975                        ascending = last.as_f64().unwrap_or(f64::NAN) >= first.as_f64().unwrap_or(f64::NAN); // 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(), (match &(limitResolved) { Value::Int(x) => Value::Int(-x), Value::Float(x) => Value::Float(-x), _ => Value::Null }), &[]);
984                }
985                if ascending {
986                    return self.array_slice(array.clone(), (match &(limit) { Value::Int(x) => Value::Int(-x), Value::Float(x) => Value::Float(-x), _ => Value::Null }), &[]);
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 sinceIsDefined.as_bool() == Some(true) {
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 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_77 = false; i.as_f64().unwrap_or(f64::NAN) < ((parsedArray.len() as i64) as f64) } {
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_integer(entry.clone(), key.clone(), &[]);
1016                if (value != Value::Null) && (value.as_f64() != Some(0.0)) && (value.as_f64().unwrap_or(f64::NAN) >= since.as_f64().unwrap_or(f64::NAN)) {
1017                    if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(entry); }
1018                }
1019            }
1020            }
1021        }
1022        if is_true(&tail) && (limit != Value::Null) {
1023            return self.array_slice(result.clone(), (match &(limit) { Value::Int(x) => Value::Int(-x), Value::Float(x) => Value::Float(-x), _ => Value::Null }), &[]);
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) && sinceIsDefined.as_bool() == Some(true));
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 valueIsDefined.as_bool() == Some(true) || sinceIsDefined.as_bool() == Some(true) {
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 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_78 = false; i.as_f64().unwrap_or(f64::NAN) < ((parsedArray.len() as i64) as f64) } {
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 valueIsDefined.as_bool() == Some(true) { entryFiledEqualValue } else { Value::Bool(true) });
1056                let mut entryKeyValue: Value = self.safe_integer(entry.clone(), key.clone(), &[]);
1057                let mut entryKeyGESince: Value = Value::Bool((entryKeyValue != Value::Null) && (entryKeyValue.as_f64() != Some(0.0)) && (since != Value::Null) && (entryKeyValue.as_f64().unwrap_or(f64::NAN) >= since.as_f64().unwrap_or(f64::NAN)));
1058                let mut secondCondition: Value = (if sinceIsDefined.as_bool() == Some(true) { entryKeyGESince } else { Value::Bool(true) });
1059                if is_true(&firstCondition) && is_true(&secondCondition) {
1060                    if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(entry); }
1061                }
1062            }
1063            }
1064        }
1065        if tail.as_bool() == Some(true) && (limit != Value::Null) {
1066            return self.array_slice(result.clone(), (match &(limit) { Value::Int(x) => Value::Int(-x), Value::Float(x) => Value::Float(-x), _ => Value::Null }), &[]);
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 self.isSandboxModeEnabled.as_bool() == Some(true) {
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::from(vec![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        return Value::Map({
1139    let mut m = indexmap::IndexMap::new();
1140        m.insert("url".to_string(), Value::Null);
1141        m.insert("method".to_string(), Value::Null);
1142        m.insert("headers".to_string(), Value::Null);
1143        m.insert("body".to_string(), Value::Null);
1144    m
1145});
1146
1147    Value::Null
1148}
1149
1150    fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1151        let mut params = get_arg(optional_args, 0, Value::Map({
1152    let mut m = indexmap::IndexMap::new();
1153    m
1154}));
1155        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAccounts() is not supported yet".into()))));
1156
1157    Value::Null
1158} }
1159
1160    fn watch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1161        let mut since = get_arg(optional_args, 0, Value::Null);
1162        let mut limit = get_arg(optional_args, 1, Value::Null);
1163        let mut params = get_arg(optional_args, 2, Value::Map({
1164    let mut m = indexmap::IndexMap::new();
1165    m
1166}));
1167        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)) {
1168            return self.watch_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1169        }
1170        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidations() is not supported yet".into()))));
1171
1172    Value::Null
1173} }
1174
1175    fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1176        let mut since = get_arg(optional_args, 0, Value::Null);
1177        let mut limit = get_arg(optional_args, 1, Value::Null);
1178        let mut params = get_arg(optional_args, 2, Value::Map({
1179    let mut m = indexmap::IndexMap::new();
1180    m
1181}));
1182        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidationsForSymbols() is not supported yet".into()))));
1183
1184    Value::Null
1185} }
1186
1187    fn watch_my_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1188        let mut since = get_arg(optional_args, 0, Value::Null);
1189        let mut limit = get_arg(optional_args, 1, Value::Null);
1190        let mut params = get_arg(optional_args, 2, Value::Map({
1191    let mut m = indexmap::IndexMap::new();
1192    m
1193}));
1194        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)) {
1195            return self.watch_my_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1196        }
1197        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidations() is not supported yet".into()))));
1198
1199    Value::Null
1200} }
1201
1202    fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1203        let mut since = get_arg(optional_args, 0, Value::Null);
1204        let mut limit = get_arg(optional_args, 1, Value::Null);
1205        let mut params = get_arg(optional_args, 2, Value::Map({
1206    let mut m = indexmap::IndexMap::new();
1207    m
1208}));
1209        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".into()))));
1210
1211    Value::Null
1212} }
1213
1214    fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1215        let mut symbol = get_arg(optional_args, 0, Value::Null);
1216        let mut params = get_arg(optional_args, 1, Value::Map({
1217    let mut m = indexmap::IndexMap::new();
1218    m
1219}));
1220        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrders() is not supported yet".into()))));
1221
1222    Value::Null
1223} }
1224
1225    fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1226        let mut params = get_arg(optional_args, 0, Value::Map({
1227    let mut m = indexmap::IndexMap::new();
1228    m
1229}));
1230        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTrades() is not supported yet".into()))));
1231
1232    Value::Null
1233} }
1234
1235    fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1236        let mut params = get_arg(optional_args, 0, Value::Map({
1237    let mut m = indexmap::IndexMap::new();
1238    m
1239}));
1240        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTradesForSymbols() is not supported yet".into()))));
1241
1242    Value::Null
1243} }
1244
1245    fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1246        let mut since = get_arg(optional_args, 0, Value::Null);
1247        let mut limit = get_arg(optional_args, 1, Value::Null);
1248        let mut params = get_arg(optional_args, 2, Value::Map({
1249    let mut m = indexmap::IndexMap::new();
1250    m
1251}));
1252        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCVForSymbols() is not supported yet".into()))));
1253
1254    Value::Null
1255} }
1256
1257    fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1258        let mut params = get_arg(optional_args, 0, Value::Map({
1259    let mut m = indexmap::IndexMap::new();
1260    m
1261}));
1262        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCVForSymbols() is not supported yet".into()))));
1263
1264    Value::Null
1265} }
1266
1267    fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1268        let mut params = get_arg(optional_args, 0, Value::Map({
1269    let mut m = indexmap::IndexMap::new();
1270    m
1271}));
1272        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBookForSymbols() is not supported yet".into()))));
1273
1274    Value::Null
1275} }
1276
1277    fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1278        let mut symbols = get_arg(optional_args, 0, Value::Null);
1279        let mut params = get_arg(optional_args, 1, Value::Map({
1280    let mut m = indexmap::IndexMap::new();
1281    m
1282}));
1283        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchPositions() is not supported yet".into()))));
1284
1285    Value::Null
1286} }
1287
1288    fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1289        let mut params = get_arg(optional_args, 0, Value::Map({
1290    let mut m = indexmap::IndexMap::new();
1291    m
1292}));
1293        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTicker() is not supported yet".into()))));
1294
1295    Value::Null
1296} }
1297
1298    fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1299        let mut params = get_arg(optional_args, 0, Value::Map({
1300    let mut m = indexmap::IndexMap::new();
1301    m
1302}));
1303        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrice() is not supported yet".into()))));
1304
1305    Value::Null
1306} }
1307
1308    fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1309        let mut symbols = get_arg(optional_args, 0, Value::Null);
1310        let mut params = get_arg(optional_args, 1, Value::Map({
1311    let mut m = indexmap::IndexMap::new();
1312    m
1313}));
1314        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrices() is not supported yet".into()))));
1315
1316    Value::Null
1317} }
1318
1319    fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1320        // async-virtual: try the derived exchange first
1321        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 {
1322            if !matches!(__v, crate::Value::Null) { return __v; }
1323        }
1324
1325        let mut codes = get_arg(optional_args, 0, Value::Null);
1326        let mut params = get_arg(optional_args, 1, Value::Map({
1327    let mut m = indexmap::IndexMap::new();
1328    m
1329}));
1330        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddresses() is not supported yet".into()))));
1331
1332    Value::Null
1333} }
1334
1335    fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1336        // async-virtual: try the derived exchange first
1337        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 {
1338            if !matches!(__v, crate::Value::Null) { return __v; }
1339        }
1340
1341        let mut params = get_arg(optional_args, 0, Value::Map({
1342    let mut m = indexmap::IndexMap::new();
1343    m
1344}));
1345        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)) {
1346            let mut marginModes: Value = self.fetch_margin_modes(&[Value::from(vec![symbol.clone()]), params]).await;
1347            let mut marginMode: Value = self.safe_dict(marginModes, symbol, &[]);
1348            return marginMode;
1349        }  else {
1350            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginMode() is not supported yet".into()))));
1351        }
1352
1353    Value::Null
1354} }
1355
1356    fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1357        // async-virtual: try the derived exchange first
1358        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 {
1359            if !matches!(__v, crate::Value::Null) { return __v; }
1360        }
1361
1362        let mut symbols = get_arg(optional_args, 0, Value::Null);
1363        let mut params = get_arg(optional_args, 1, Value::Map({
1364    let mut m = indexmap::IndexMap::new();
1365    m
1366}));
1367        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginModes () is not supported yet".into()))));
1368
1369    Value::Null
1370} }
1371
1372    fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1373        let mut params = get_arg(optional_args, 0, Value::Map({
1374    let mut m = indexmap::IndexMap::new();
1375    m
1376}));
1377        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBook() is not supported yet".into()))));
1378
1379    Value::Null
1380} }
1381
1382    fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1383        // async-virtual: try the derived exchange first
1384        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 {
1385            if !matches!(__v, crate::Value::Null) { return __v; }
1386        }
1387
1388        let mut params = get_arg(optional_args, 0, Value::Map({
1389    let mut m = indexmap::IndexMap::new();
1390    m
1391}));
1392        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTime() is not supported yet".into()))));
1393
1394    Value::Null
1395} }
1396
1397    fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1398        let mut symbols = get_arg(optional_args, 0, Value::Null);
1399        let mut params = get_arg(optional_args, 1, Value::Map({
1400    let mut m = indexmap::IndexMap::new();
1401    m
1402}));
1403        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingLimits() is not supported yet".into()))));
1404
1405    Value::Null
1406} }
1407
1408    fn parse_currency(&self, mut rawCurrency: Value) -> Value {
1409        // virtual-dispatch (static: DerivedExchange::parse_currency(self, ...))
1410        { let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency); if !matches!(__v, crate::Value::Null) { return __v; } }
1411
1412        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseCurrency() is not supported yet".into()))));
1413
1414    Value::Null
1415}
1416
1417    fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
1418        let mut result: Value = Value::Map({
1419            let mut m = indexmap::IndexMap::new();
1420            m
1421        });
1422        let mut arr: Value = self.to_array(rawCurrencies);
1423        {
1424                        let mut i: Value = Value::Int(0);
1425            let mut __for_first_79: bool = true;
1426            while { if !__for_first_79 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_79 = false; i.as_f64().unwrap_or(f64::NAN) < ((arr.len() as i64) as f64) } {
1427            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));
1428            if (parsed == Value::Null) {
1429                continue;
1430            }
1431            let mut code: Value = parsed.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
1432            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), parsed); }
1433        }
1434        }
1435        return result;
1436
1437    Value::Null
1438}
1439
1440    fn parse_market(&self, mut market: Value) -> Value {
1441        // virtual-dispatch (static: DerivedExchange::parse_market(self, ...))
1442        { let __v = crate::exchange::DerivedExchange::parse_market(self, market); if !matches!(__v, crate::Value::Null) { return __v; } }
1443
1444        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarket() is not supported yet".into()))));
1445
1446    Value::Null
1447}
1448
1449    fn parse_markets(&self, mut markets: Value) -> Value {
1450        let mut result: Vec<Value> = Vec::new();
1451        {
1452                        let mut i: Value = Value::Int(0);
1453            let mut __for_first_80: bool = true;
1454            while { if !__for_first_80 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_80 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
1455            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i));
1456            // parseMarket returns undefined for a market it cannot build (e.g. unknown base or quote)
1457            if (market != Value::Null) {
1458                result.push(market);
1459            }
1460        }
1461        }
1462        return Value::from(result);
1463
1464    Value::Null
1465}
1466
1467    fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
1468        // virtual-dispatch (static: DerivedExchange::parse_ticker(self, ...))
1469        { 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; } }
1470
1471        let mut market = get_arg(optional_args, 0, Value::Null);
1472        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTicker() is not supported yet".into()))));
1473
1474    Value::Null
1475}
1476
1477    fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
1478        // virtual-dispatch (static: DerivedExchange::parse_deposit_address(self, ...))
1479        { 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; } }
1480
1481        let mut currency = get_arg(optional_args, 0, Value::Null);
1482        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositAddress() is not supported yet".into()))));
1483
1484    Value::Null
1485}
1486
1487    fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1488        // virtual-dispatch (static: DerivedExchange::parse_trade(self, ...))
1489        { 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; } }
1490
1491        let mut market = get_arg(optional_args, 0, Value::Null);
1492        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTrade() is not supported yet".into()))));
1493
1494    Value::Null
1495}
1496
1497    fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
1498        // virtual-dispatch (static: DerivedExchange::parse_transaction(self, ...))
1499        { 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; } }
1500
1501        let mut currency = get_arg(optional_args, 0, Value::Null);
1502        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransaction() is not supported yet".into()))));
1503
1504    Value::Null
1505}
1506
1507    fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
1508        // virtual-dispatch (static: DerivedExchange::parse_transfer(self, ...))
1509        { 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; } }
1510
1511        let mut currency = get_arg(optional_args, 0, Value::Null);
1512        if (transfer == Value::Null) {
1513            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1514        }
1515        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1516
1517    Value::Null
1518}
1519
1520    fn parse_account(&self, mut account: Value) -> Value {
1521        // virtual-dispatch (static: DerivedExchange::parse_account(self, ...))
1522        { let __v = crate::exchange::DerivedExchange::parse_account(self, account); if !matches!(__v, crate::Value::Null) { return __v; } }
1523
1524        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseAccount() is not supported yet".into()))));
1525
1526    Value::Null
1527}
1528
1529    fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
1530        // virtual-dispatch (static: DerivedExchange::parse_ledger_entry(self, ...))
1531        { 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; } }
1532
1533        let mut currency = get_arg(optional_args, 0, Value::Null);
1534        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLedgerEntry() is not supported yet".into()))));
1535
1536    Value::Null
1537}
1538
1539    fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1540        // virtual-dispatch (static: DerivedExchange::parse_order(self, ...))
1541        { 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; } }
1542
1543        let mut market = get_arg(optional_args, 0, Value::Null);
1544        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOrder() is not supported yet".into()))));
1545
1546    Value::Null
1547}
1548
1549    fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1550        let mut params = get_arg(optional_args, 0, Value::Map({
1551    let mut m = indexmap::IndexMap::new();
1552    m
1553}));
1554        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRates() is not supported yet".into()))));
1555
1556    Value::Null
1557} }
1558
1559    fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1560        let mut params = get_arg(optional_args, 0, Value::Map({
1561    let mut m = indexmap::IndexMap::new();
1562    m
1563}));
1564        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRates() is not supported yet".into()))));
1565
1566    Value::Null
1567} }
1568
1569    fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
1570        // virtual-dispatch (static: DerivedExchange::parse_market_leverage_tiers(self, ...))
1571        { 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; } }
1572
1573        let mut market = get_arg(optional_args, 0, Value::Null);
1574        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarketLeverageTiers() is not supported yet".into()))));
1575
1576    Value::Null
1577}
1578
1579    fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1580        // async-virtual: try the derived exchange first
1581        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 {
1582            if !matches!(__v, crate::Value::Null) { return __v; }
1583        }
1584
1585        let mut symbols = get_arg(optional_args, 0, Value::Null);
1586        let mut params = get_arg(optional_args, 1, Value::Map({
1587    let mut m = indexmap::IndexMap::new();
1588    m
1589}));
1590        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverageTiers() is not supported yet".into()))));
1591
1592    Value::Null
1593} }
1594
1595    fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
1596        // virtual-dispatch (static: DerivedExchange::parse_position(self, ...))
1597        { 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; } }
1598
1599        let mut market = get_arg(optional_args, 0, Value::Null);
1600        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parsePosition() is not supported yet".into()))));
1601
1602    Value::Null
1603}
1604
1605    fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
1606        // virtual-dispatch (static: DerivedExchange::parse_funding_rate_history(self, ...))
1607        { 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; } }
1608
1609        let mut market = get_arg(optional_args, 0, Value::Null);
1610        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRateHistory() is not supported yet".into()))));
1611
1612    Value::Null
1613}
1614
1615    fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
1616        // virtual-dispatch (static: DerivedExchange::parse_borrow_interest(self, ...))
1617        { 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; } }
1618
1619        let mut market = get_arg(optional_args, 0, Value::Null);
1620        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowInterest() is not supported yet".into()))));
1621
1622    Value::Null
1623}
1624
1625    fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
1626        let mut market = get_arg(optional_args, 0, Value::Null);
1627        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIsolatedBorrowRate() is not supported yet".into()))));
1628
1629    Value::Null
1630}
1631
1632    fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1633        let mut market = get_arg(optional_args, 0, Value::Null);
1634        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsTrade() is not supported yet".into()))));
1635
1636    Value::Null
1637}
1638
1639    fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1640        let mut market = get_arg(optional_args, 0, Value::Null);
1641        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrder() is not supported yet".into()))));
1642
1643    Value::Null
1644}
1645
1646    fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1647        let mut market = get_arg(optional_args, 0, Value::Null);
1648        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrderTrade() is not supported yet".into()))));
1649
1650    Value::Null
1651}
1652
1653    fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
1654        let mut market = get_arg(optional_args, 0, Value::Null);
1655        return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv, &[market]);
1656
1657    Value::Null
1658}
1659
1660    fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1661        // async-virtual: try the derived exchange first
1662        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 {
1663            if !matches!(__v, crate::Value::Null) { return __v; }
1664        }
1665
1666        let mut symbols = get_arg(optional_args, 0, Value::Null);
1667        let mut params = get_arg(optional_args, 1, Value::Map({
1668    let mut m = indexmap::IndexMap::new();
1669    m
1670}));
1671        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRates() is not supported yet".into()))));
1672
1673    Value::Null
1674} }
1675
1676    fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1677        // async-virtual: try the derived exchange first
1678        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 {
1679            if !matches!(__v, crate::Value::Null) { return __v; }
1680        }
1681
1682        let mut symbols = get_arg(optional_args, 0, Value::Null);
1683        let mut params = get_arg(optional_args, 1, Value::Map({
1684    let mut m = indexmap::IndexMap::new();
1685    m
1686}));
1687        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingIntervals() is not supported yet".into()))));
1688
1689    Value::Null
1690} }
1691
1692    fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1693        let mut params = get_arg(optional_args, 0, Value::Map({
1694    let mut m = indexmap::IndexMap::new();
1695    m
1696}));
1697        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRate() is not supported yet".into()))));
1698
1699    Value::Null
1700} }
1701
1702    fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1703        let mut symbols = get_arg(optional_args, 0, Value::Null);
1704        let mut params = get_arg(optional_args, 1, Value::Map({
1705    let mut m = indexmap::IndexMap::new();
1706    m
1707}));
1708        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRates() is not supported yet".into()))));
1709
1710    Value::Null
1711} }
1712
1713    fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1714        let mut symbols = get_arg(optional_args, 0, Value::Null);
1715        let mut params = get_arg(optional_args, 1, Value::Map({
1716    let mut m = indexmap::IndexMap::new();
1717    m
1718}));
1719        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRates() is not supported yet".into()))));
1720
1721    Value::Null
1722} }
1723
1724    fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1725        let mut params = get_arg(optional_args, 0, Value::Map({
1726    let mut m = indexmap::IndexMap::new();
1727    m
1728}));
1729        return self.watch_funding_rates(&[symbols, params]).await;
1730
1731    Value::Null
1732} }
1733
1734    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 {
1735        // async-virtual: try the derived exchange first
1736        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 {
1737            if !matches!(__v, crate::Value::Null) { return __v; }
1738        }
1739
1740        let mut params = get_arg(optional_args, 0, Value::Map({
1741    let mut m = indexmap::IndexMap::new();
1742    m
1743}));
1744        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" transfer() is not supported yet".into()))));
1745
1746    Value::Null
1747} }
1748
1749    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 {
1750        // async-virtual: try the derived exchange first
1751        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 {
1752            if !matches!(__v, crate::Value::Null) { return __v; }
1753        }
1754
1755        let mut params = get_arg(optional_args, 0, Value::Map({
1756    let mut m = indexmap::IndexMap::new();
1757    m
1758}));
1759        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdraw() is not supported yet".into()))));
1760
1761    Value::Null
1762} }
1763
1764    fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1765        let mut params = get_arg(optional_args, 0, Value::Map({
1766    let mut m = indexmap::IndexMap::new();
1767    m
1768}));
1769        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createDepositAddress() is not supported yet".into()))));
1770
1771    Value::Null
1772} }
1773
1774    fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1775        // async-virtual: try the derived exchange first
1776        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 {
1777            if !matches!(__v, crate::Value::Null) { return __v; }
1778        }
1779
1780        let mut symbol = get_arg(optional_args, 0, Value::Null);
1781        let mut params = get_arg(optional_args, 1, Value::Map({
1782    let mut m = indexmap::IndexMap::new();
1783    m
1784}));
1785        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() is not supported yet".into()))));
1786
1787    Value::Null
1788} }
1789
1790    fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1791        // async-virtual: try the derived exchange first
1792        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 {
1793            if !matches!(__v, crate::Value::Null) { return __v; }
1794        }
1795
1796        let mut params = get_arg(optional_args, 0, Value::Map({
1797    let mut m = indexmap::IndexMap::new();
1798    m
1799}));
1800        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)) {
1801            let mut leverages: Value = self.fetch_leverages(&[Value::from(vec![symbol.clone()]), params]).await;
1802            let mut leverage: Value = self.safe_dict(leverages, symbol, &[]);
1803            return leverage;
1804        }  else {
1805            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverage() is not supported yet".into()))));
1806        }
1807
1808    Value::Null
1809} }
1810
1811    fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1812        // async-virtual: try the derived exchange first
1813        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 {
1814            if !matches!(__v, crate::Value::Null) { return __v; }
1815        }
1816
1817        let mut symbols = get_arg(optional_args, 0, Value::Null);
1818        let mut params = get_arg(optional_args, 1, Value::Map({
1819    let mut m = indexmap::IndexMap::new();
1820    m
1821}));
1822        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverages() is not supported yet".into()))));
1823
1824    Value::Null
1825} }
1826
1827    fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1828        // async-virtual: try the derived exchange first
1829        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 {
1830            if !matches!(__v, crate::Value::Null) { return __v; }
1831        }
1832
1833        let mut symbol = get_arg(optional_args, 0, Value::Null);
1834        let mut params = get_arg(optional_args, 1, Value::Map({
1835    let mut m = indexmap::IndexMap::new();
1836    m
1837}));
1838        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setPositionMode() is not supported yet".into()))));
1839
1840    Value::Null
1841} }
1842
1843    fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1844        // async-virtual: try the derived exchange first
1845        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 {
1846            if !matches!(__v, crate::Value::Null) { return __v; }
1847        }
1848
1849        let mut params = get_arg(optional_args, 0, Value::Map({
1850    let mut m = indexmap::IndexMap::new();
1851    m
1852}));
1853        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" addMargin() is not supported yet".into()))));
1854
1855    Value::Null
1856} }
1857
1858    fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1859        // async-virtual: try the derived exchange first
1860        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 {
1861            if !matches!(__v, crate::Value::Null) { return __v; }
1862        }
1863
1864        let mut params = get_arg(optional_args, 0, Value::Map({
1865    let mut m = indexmap::IndexMap::new();
1866    m
1867}));
1868        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" reduceMargin() is not supported yet".into()))));
1869
1870    Value::Null
1871} }
1872
1873    fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1874        let mut params = get_arg(optional_args, 0, Value::Map({
1875    let mut m = indexmap::IndexMap::new();
1876    m
1877}));
1878        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMargin() is not supported yet".into()))));
1879
1880    Value::Null
1881} }
1882
1883    fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1884        let mut timeframe = get_arg(optional_args, 0, Value::Null);
1885        let mut params = get_arg(optional_args, 1, Value::Map({
1886    let mut m = indexmap::IndexMap::new();
1887    m
1888}));
1889        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatio() is not supported yet".into()))));
1890
1891    Value::Null
1892} }
1893
1894    fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1895        let mut symbol = get_arg(optional_args, 0, Value::Null);
1896        let mut timeframe = get_arg(optional_args, 1, Value::Null);
1897        let mut since = get_arg(optional_args, 2, Value::Null);
1898        let mut limit = get_arg(optional_args, 3, Value::Null);
1899        let mut params = get_arg(optional_args, 4, Value::Map({
1900    let mut m = indexmap::IndexMap::new();
1901    m
1902}));
1903        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatioHistory() is not supported yet".into()))));
1904
1905    Value::Null
1906} }
1907
1908    fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1909        let mut symbol = get_arg(optional_args, 0, Value::Null);
1910        let mut type_var = get_arg(optional_args, 1, Value::Null);
1911        let mut since = get_arg(optional_args, 2, Value::Null);
1912        let mut limit = get_arg(optional_args, 3, Value::Null);
1913        let mut params = get_arg(optional_args, 4, Value::Map({
1914    let mut m = indexmap::IndexMap::new();
1915    m
1916}));
1917        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".into()))));
1918
1919    Value::Null
1920} }
1921
1922    fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1923        // async-virtual: try the derived exchange first
1924        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 {
1925            if !matches!(__v, crate::Value::Null) { return __v; }
1926        }
1927
1928        let mut symbol = get_arg(optional_args, 0, Value::Null);
1929        let mut params = get_arg(optional_args, 1, Value::Map({
1930    let mut m = indexmap::IndexMap::new();
1931    m
1932}));
1933        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMarginMode() is not supported yet".into()))));
1934
1935    Value::Null
1936} }
1937
1938    fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1939        // async-virtual: try the derived exchange first
1940        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 {
1941            if !matches!(__v, crate::Value::Null) { return __v; }
1942        }
1943
1944        let mut params = get_arg(optional_args, 0, Value::Map({
1945    let mut m = indexmap::IndexMap::new();
1946    m
1947}));
1948        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".into()))));
1949
1950    Value::Null
1951} }
1952
1953    fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1954        let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".into()));
1955        let mut since = get_arg(optional_args, 1, Value::Null);
1956        let mut limit = get_arg(optional_args, 2, Value::Null);
1957        let mut params = get_arg(optional_args, 3, Value::Map({
1958    let mut m = indexmap::IndexMap::new();
1959    m
1960}));
1961        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterestHistory() is not supported yet".into()))));
1962
1963    Value::Null
1964} }
1965
1966    fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1967        // async-virtual: try the derived exchange first
1968        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 {
1969            if !matches!(__v, crate::Value::Null) { return __v; }
1970        }
1971
1972        let mut symbols = get_arg(optional_args, 0, Value::Null);
1973        let mut params = get_arg(optional_args, 1, Value::Map({
1974    let mut m = indexmap::IndexMap::new();
1975    m
1976}));
1977        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterests() is not supported yet".into()))));
1978
1979    Value::Null
1980} }
1981
1982    fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1983        // async-virtual: try the derived exchange first
1984        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 {
1985            if !matches!(__v, crate::Value::Null) { return __v; }
1986        }
1987
1988        let mut params = get_arg(optional_args, 0, Value::Map({
1989    let mut m = indexmap::IndexMap::new();
1990    m
1991}));
1992        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" signIn() is not supported yet".into()))));
1993
1994    Value::Null
1995} }
1996
1997    fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1998        let mut params = get_arg(optional_args, 0, Value::Map({
1999    let mut m = indexmap::IndexMap::new();
2000    m
2001}));
2002        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPaymentMethods() is not supported yet".into()))));
2003
2004    Value::Null
2005} }
2006
2007    fn parse_to_int(&self, mut number: Value) -> Value {
2008        // Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
2009        // using a number as parameter which is not valid in ts
2010        // numberToString is typed as nullable under strictNullChecks; cast to string
2011        // the cast is erased at transpile-time, so output matches every target language, rather than
2012        // branching to a bare `NaN` literal, which has no symbol in Go/Java/C#
2013        let mut stringifiedNumber: Value = self.number_to_string(number);
2014        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 });
2015        return crate::runtime::parse_int(&convertedNumber);
2016
2017    Value::Null
2018}
2019
2020    fn parse_to_numeric(&self, mut number: Value) -> Value {
2021        let mut stringVersion: Value = self.number_to_string(number); // this will convert 1.0 and 1 to "1" and 1.1 to "1.1"
2022        // keep this in mind:
2023        // in JS:     1 === 1.0 is true
2024        // in Python: 1 == 1.0 is true
2025        // in PHP:    1 == 1.0 is true, but 1 === 1.0 is false.
2026        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) {
2027            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 });
2028        }
2029        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 });
2030
2031    Value::Null
2032}
2033
2034    fn is_round_number(&self, mut value: Value) -> Value {
2035        // this method is similar to isInteger, but this is more loyal and does not check for types.
2036        // i.e. isRoundNumber(1.000) returns true, while isInteger(1.000) returns false
2037        let mut res: Value = self.parse_to_numeric(((match (&(value), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null })));
2038        return Value::Bool(res.as_f64() == Some(0.0));
2039
2040    Value::Null
2041}
2042
2043    fn is_empty_string(&self, mut value: Value) -> Value {
2044        return Value::Bool(!(self.value_is_defined(value.clone()).as_bool() == Some(true)) || (value.as_str() == Some("")));
2045
2046    Value::Null
2047}
2048
2049    fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2050        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2051        let mut value: Value = self.safe_string(obj, key, &[]);
2052        let mut final_val: Value = self.parse_number(self.omit_zero(value), &[]);
2053        return (if (final_val == Value::Null) { defaultValue } else { final_val });
2054
2055    Value::Null
2056}
2057
2058    fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2059        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2060        let mut timestamp: Value = self.safe_integer(obj, key, &[defaultValue]);
2061        if (timestamp == Value::Null) || (timestamp.as_f64() == Some(0.0)) {
2062            return Value::Null;
2063        }
2064        return timestamp;
2065
2066    Value::Null
2067}
2068
2069    fn after_construct(&mut self, optional_args: &[Value]) {
2070        let mut userConfig = get_arg(optional_args, 0, Value::Map({
2071    let mut m = indexmap::IndexMap::new();
2072    m
2073}));
2074        let __userConfig_empty = indexmap::IndexMap::new();
2075        let userConfig = userConfig.as_map().unwrap_or(&__userConfig_empty);
2076        // networksById: inverse of options.networks, explicit options.networksById entries win
2077        let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2078            let mut m = indexmap::IndexMap::new();
2079            m
2080        })]));
2081        { let __be_tmp = self.extend(networkIdsToCodesGenerated, &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2082    let mut m = indexmap::IndexMap::new();
2083    m
2084})])]); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("networksById".into(), __be_tmp); } }
2085        self.features_generator();
2086        self.has_autocorrect();
2087        // init predefined markets if any
2088        if (self.markets.clone() != Value::Null) {
2089            self.set_markets(self.markets.clone(), &[]);
2090        }
2091        // init the request rate limiter
2092        self.init_rest_rate_limiter();
2093        // sanbox mode
2094        let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".into()), Value::Str("testnet".into()), &[Value::Bool(false)]);
2095        if isSandbox.as_bool() == Some(true) {
2096            self.set_sandbox_mode(isSandbox);
2097        }
2098        // compatibility for sandbox/testnet options in userConfig
2099        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)) {
2100            self.set_sandbox_mode(Value::Bool(true));
2101        }
2102}
2103
2104    fn has_autocorrect(&self) {
2105        let mut fallbacks: Value = Value::Map({
2106            let mut m = indexmap::IndexMap::new();
2107                m.insert("fetchL2OrderBook".to_string(), Value::Str("fetchOrderBook".into()));
2108                m.insert("createLimitOrder".to_string(), Value::Str("createOrder".into()));
2109                m.insert("createMarketOrder".to_string(), Value::Str("createOrder".into()));
2110                m.insert("createLimitOrderWs".to_string(), Value::Str("createOrderWs".into()));
2111                m.insert("createMarketOrderWs".to_string(), Value::Str("createOrderWs".into()));
2112            m
2113        });
2114        let mut targets: Value = Value::Array(fallbacks.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
2115        {
2116                        let mut i: Value = Value::Int(0);
2117            let mut __for_first_81: bool = true;
2118            while { if !__for_first_81 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_81 = false; i.as_f64().unwrap_or(f64::NAN) < ((targets.len() as i64) as f64) } {
2119            let mut target: Value = targets.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);
2120            let mut source: Value = fallbacks.as_map().and_then(|__m| target.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2121            let mut sourceDefined: bool = (matches!((&self.has, &source), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) && (get_value(&self.has, &source) != Value::Null);
2122            let mut targetDefined: bool = (matches!((&self.has, &target), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) && (self.has.as_map().and_then(|__m| target.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null) != Value::Null);
2123            if sourceDefined && !targetDefined {
2124                { let __be_tmp = get_value(&self.has, &source); if let Value::Dict(__d) = &mut self.has.clone() { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&target), __be_tmp); } }
2125            }
2126        }
2127        }
2128}
2129
2130    fn init_rest_rate_limiter(&mut self) {
2131        if (self.rateLimit.clone() == Value::Null) || ((self.id.clone() != Value::Null) && (self.rateLimit.as_f64() == Value::Int(-1).as_f64())) {
2132            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(".rateLimit property is not configured".into()))));
2133        }
2134        let mut refillRate: Value = self.MAX_VALUE.clone();
2135        if self.rateLimit.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2136            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 });
2137        }
2138        let mut useLeaky: bool = (self.rollingWindowSize.as_f64() == Some(0.0)) || (self.rateLimiterAlgorithm.as_str() == Some("leakyBucket"));
2139        let mut algorithm: Value = (if useLeaky { Value::Str("leakyBucket".into()) } else { Value::Str("rollingWindow".into()) });
2140        let mut defaultBucket: Value = Value::Map({
2141            let mut m = indexmap::IndexMap::new();
2142                m.insert("delay".to_string(), Value::Float(0.001));
2143                m.insert("capacity".to_string(), Value::Int(1));
2144                m.insert("cost".to_string(), Value::Int(1));
2145                m.insert("refillRate".to_string(), refillRate);
2146                m.insert("algorithm".to_string(), algorithm);
2147                m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2148                m.insert("rateLimit".to_string(), self.rateLimit.clone());
2149            m
2150        });
2151        let mut existingBucket: Value = (if (self.tokenBucket.clone() == Value::Null) { Value::Map({
2152    let mut m = indexmap::IndexMap::new();
2153    m
2154}) } else { self.tokenBucket.clone() });
2155        { let __t = self.extend(defaultBucket, &[existingBucket]); self.tokenBucket = __t; }
2156        self.init_throttler();
2157}
2158
2159    fn features_generator(&mut self) {
2160        //
2161        // in the exchange-specific features can be something like this, where we support 'string' aliases too:
2162        //
2163        //     {
2164        //         'my' : {
2165        //             'createOrder' : {...},
2166        //         },
2167        //         'swap': {
2168        //             'linear': {
2169        //                 'extends': my',
2170        //             },
2171        //         },
2172        //     }
2173        //
2174        if (self.features.clone() == Value::Null) {
2175            return;
2176        }
2177        // reconstruct
2178        let mut initialFeatures: Value = self.features.clone();
2179        self.features = Value::Map({
2180            let mut m = indexmap::IndexMap::new();
2181            m
2182        });
2183        let mut unifiedMarketTypes: Value = Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into()), Value::Str("future".into()), Value::Str("option".into())]);
2184        let mut subTypes: Value = Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into())]);
2185        {
2186                        let mut i: Value = Value::Int(0);
2187            let mut __for_first_83: bool = true;
2188            while { if !__for_first_83 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_83 = false; i.as_f64().unwrap_or(f64::NAN) < ((unifiedMarketTypes.len() as i64) as f64) } {
2189            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);
2190            // if marketType is not filled for this exchange, don't add that in `features`
2191            if !(matches!((&initialFeatures, &marketType), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
2192                if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Null); }
2193            }  else {
2194                if (marketType.as_str() == Some("spot")) {
2195                    { 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); } }
2196                }  else {
2197                    if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Map({
2198    let mut m = indexmap::IndexMap::new();
2199    m
2200})); }
2201                    {
2202                                                let mut j: Value = Value::Int(0);
2203                        let mut __for_first_82: bool = true;
2204                        while { if !__for_first_82 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_82 = false; j.as_f64().unwrap_or(f64::NAN) < ((subTypes.len() as i64) as f64) } {
2205                        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);
2206                        { 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); };
2207                    }
2208                    }
2209                }
2210            }
2211        }
2212        }
2213}
2214
2215    fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2216        let mut subType = get_arg(optional_args, 0, Value::Null);
2217        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) });
2218        // if exchange does not have that market-type (eg. future>inverse)
2219        if (featuresObj == Value::Null) {
2220            return Value::Null;
2221        }
2222        let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
2223        if (extendsStr != Value::Null) {
2224            featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".into()), &[]);
2225            let mut extendObj: Value = self.features_mapper(initialFeatures, extendsStr, &[]);
2226            featuresObj = self.deep_extend(extendObj, &[featuresObj.clone()]);
2227        }
2228        //
2229        // ### corrections ###
2230        //
2231        // createOrder
2232        if (in_op(&featuresObj, &Value::Str("createOrder".into()))) {
2233            let mut value: Value = self.safe_dict_k(crate::value::get_value_k(&featuresObj, "createOrder"), "attachedStopLossTakeProfit", &[]);
2234            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("stopLoss".into()), value.clone());
2235            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("takeProfit".into()), value.clone());
2236            if (marketType.as_str() == Some("spot")) {
2237                // default 'hedged': false
2238                add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("hedged".into()), Value::Bool(false));
2239                // default 'leverage': false
2240                if !(in_op(&crate::value::get_value_k(&featuresObj, "createOrder"), &Value::Str("leverage".into()))) {
2241                    add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("leverage".into()), Value::Bool(false));
2242                }
2243            }
2244            // default 'GTC' to true
2245            if (self.safe_bool(crate::value::get_value_k(&crate::value::get_value_k(&featuresObj, "createOrder"), "timeInForce"), Value::Str("GTC".into()), &[]) == Value::Null) {
2246                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));
2247            }
2248        }
2249        // other methods
2250        let mut keys: Value = object_keys(&featuresObj);
2251        {
2252                        let mut i: Value = Value::Int(0);
2253            let mut __for_first_84: bool = true;
2254            while { if !__for_first_84 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_84 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
2255            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);
2256            let mut featureBlock: Value = get_value(&featuresObj, &key);
2257            let mut featureBlock: Value = get_value(&featuresObj, &key);
2258            if !(self.in_array(key.clone(), Value::from(vec![Value::Str("sandbox".into())])).as_bool() == Some(true)) && (featureBlock != Value::Null) {
2259                // default "symbolRequired" to false to all methods (except `createOrder`)
2260                if !(in_op(&featureBlock, &Value::Str("symbolRequired".into()))) {
2261                    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())])));
2262                }
2263            }
2264        }
2265        }
2266        return featuresObj;
2267
2268    Value::Null
2269}
2270
2271    fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
2272        let mut methodName = get_arg(optional_args, 0, Value::Null);
2273        let mut paramName = get_arg(optional_args, 1, Value::Null);
2274        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2275        /*
2276         * @method
2277         * @name exchange#featureValue
2278         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2279         * @param {string} [symbol] unified symbol
2280         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2281         * @param {string} [paramName] unified param value, like: `triggerPrice`, `stopLoss.triggerPrice` (check docs for supported param names)
2282         * @param {object} [defaultValue] return default value if no result found
2283         * @returns {object} returns feature value
2284         */
2285        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
2286        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]);
2287
2288    Value::Null
2289}
2290
2291    fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2292        let mut methodName = get_arg(optional_args, 0, Value::Null);
2293        let mut paramName = get_arg(optional_args, 1, Value::Null);
2294        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2295        /*
2296         * @method
2297         * @name exchange#featureValueByType
2298         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2299         * @param {string} [marketType] supported only: "spot", "swap", "future"
2300         * @param {string} [subType] supported only: "linear", "inverse"
2301         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2302         * @param {string} [paramName] unified param value (check docs for supported param names)
2303         * @param {object} [defaultValue] return default value if no result found
2304         * @returns {object} returns feature value
2305         */
2306        // if exchange does not yet have features manually implemented
2307        if (self.features.clone() == Value::Null) {
2308            return defaultValue;
2309        }
2310        if (marketType == Value::Null) {
2311            return defaultValue;
2312        }
2313        // if marketType (e.g. 'option') does not exist in features
2314        if !(matches!((&self.features, &marketType), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
2315            return defaultValue;
2316        }
2317        // if marketType dict undefined
2318        if (self.features.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null) == Value::Null) {
2319            return defaultValue;
2320        }
2321        let mut methodsContainer: Value = self.features.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2322        if (subType == Value::Null) {
2323            if (marketType.as_str() != Some("spot")) {
2324                return defaultValue;
2325            }
2326        }  else {
2327            if !(in_op(&self.features.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &subType)) {
2328                return defaultValue;
2329            }
2330            // if subType dict undefined
2331            if (self.features.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| subType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null) == Value::Null) {
2332                return defaultValue;
2333            }
2334            methodsContainer = self.features.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| subType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2335        }
2336        // if user wanted only marketType and didn't provide methodName, eg: featureIsSupported('spot')
2337        if (methodName == Value::Null) {
2338            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodsContainer.clone() });
2339        }
2340        if !(matches!((&methodsContainer, &methodName), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
2341            return defaultValue;
2342        }
2343        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2344        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2345        if (methodDict == Value::Null) {
2346            return defaultValue;
2347        }
2348        // if user wanted only method and didn't provide `paramName`, eg: featureIsSupported('swap', 'linear', 'createOrder')
2349        if (paramName == Value::Null) {
2350            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodDict.clone() });
2351        }
2352        let mut splited: Value = Value::Array(paramName.as_str().map(|__s| __s.split(".").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default()); // can be only parent key (`stopLoss`) or with child (`stopLoss.triggerPrice`)
2353        let mut parentKey: Value = splited.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
2354        let mut subKey: Value = self.safe_string(splited, Value::Int(1), &[]);
2355        if !(in_op(&methodDict, &parentKey)) {
2356            return defaultValue;
2357        }
2358        let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2359        if (dictionary == Value::Null) {
2360            return get_value(&methodDict, &parentKey);
2361        }  else {
2362            // return as is, when calling without subKey eg: featureValueByType('spot', undefined, 'createOrder', 'stopLoss')
2363            if (subKey == Value::Null) {
2364                return get_value(&methodDict, &parentKey);
2365            }
2366            // throw an exception for unsupported subKey
2367            if !(in_op(&get_value(&methodDict, &parentKey), &subKey)) {
2368                return defaultValue;
2369            }
2370            return get_value(&get_value(&methodDict, &parentKey), &subKey);
2371        }
2372
2373    Value::Null
2374}
2375
2376    fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2377        if (symbol == Value::Null) {
2378            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" orderbookChecksumMessage() requires a symbol argument".into()))));
2379        }
2380        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());
2381
2382    Value::Null
2383}
2384
2385    fn get_default_options(&self) -> Value {
2386        return Value::Map({
2387    let mut m = indexmap::IndexMap::new();
2388        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())]));
2389    m
2390});
2391
2392    Value::Null
2393}
2394
2395    fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2396        let mut currency = get_arg(optional_args, 0, Value::Null);
2397        let mut currencyResolved: Value = self.safe_currency(Value::Null, &[currency]);
2398        let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2399        let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2400        let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2401        let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
2402        if (amount != Value::Null) {
2403            if (before == Value::Null) && (after != Value::Null) {
2404                before = crate::precise::Precise::stringSub(&after, &amount);
2405            }  else if (before != Value::Null) && (after == Value::Null) {
2406                after = crate::precise::Precise::stringAdd(&before, &amount);
2407            }
2408        }
2409        if (before != Value::Null) && (after != Value::Null) {
2410            if (direction == Value::Null) {
2411                if crate::precise::Precise::stringGt(&before, &after).as_bool() == Some(true) {
2412                    direction = Value::Str("out".into());
2413                }
2414                if crate::precise::Precise::stringGt(&after, &before).as_bool() == Some(true) {
2415                    direction = Value::Str("in".into());
2416                }
2417            }
2418        }
2419        let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2420        if (fee != Value::Null) {
2421            { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); };
2422        }
2423        let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
2424        let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2425    let mut m = indexmap::IndexMap::new();
2426    m
2427})]);
2428        return Value::Map({
2429    let mut m = indexmap::IndexMap::new();
2430        m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2431        m.insert("timestamp".to_string(), timestamp.clone());
2432        m.insert("datetime".to_string(), self.iso8601(timestamp));
2433        m.insert("direction".to_string(), direction);
2434        m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2435        m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2436        m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2437        m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2438        m.insert("currency".to_string(), currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null));
2439        m.insert("amount".to_string(), self.parse_number(amount, &[]));
2440        m.insert("before".to_string(), self.parse_number(before, &[]));
2441        m.insert("after".to_string(), self.parse_number(after, &[]));
2442        m.insert("status".to_string(), self.safe_string_k(entry, "status", &[]));
2443        m.insert("fee".to_string(), fee);
2444        m.insert("info".to_string(), info);
2445    m
2446});
2447
2448    Value::Null
2449}
2450
2451    fn safe_currency_structure(&self, mut currency: Value) -> Value {
2452        // derive data from networks: deposit, withdraw, active, fee, limits, precision
2453        let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2454    let mut m = indexmap::IndexMap::new();
2455    m
2456})]);
2457        let mut keys: Value = Value::Array(networks.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
2458        let mut length: f64 = ((keys.len() as i64) as f64);
2459        if (length != 0.0) {
2460            {
2461                                let mut i: Value = Value::Int(0);
2462                let mut __for_first_85: bool = true;
2463                while { if !__for_first_85 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_85 = false; i.as_f64().unwrap_or(f64::NAN) < length } {
2464                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);
2465                let mut network: Value = networks.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2466                let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
2467                let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
2468                if (currencyDeposit == Value::Null) || (deposit.as_bool() == Some(true)) {
2469                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("deposit".into(), deposit); }
2470                }
2471                let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
2472                let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
2473                if (currencyWithdraw == Value::Null) || (withdraw.as_bool() == Some(true)) {
2474                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("withdraw".into(), withdraw); }
2475                }
2476                // find lowest fee (which is more desired)
2477                let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
2478                let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
2479                if (feeMain == Value::Null) || crate::precise::Precise::stringLt(&fee, &feeMain).as_bool() == Some(true) {
2480                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("fee".into(), self.parse_number(fee.clone(), &[])); }
2481                }
2482                // find lowest precision (which is more desired)
2483                let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
2484                let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
2485                if (precisionMain == Value::Null) || crate::precise::Precise::stringGt(&precision, &precisionMain).as_bool() == Some(true) {
2486                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("precision".into(), self.parse_number(precision.clone(), &[])); }
2487                }
2488                // limits
2489                let mut limits: Value = self.safe_dict_k(network, "limits", &[]);
2490                let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
2491                if (limitsMain == Value::Null) {
2492                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("limits".into(), Value::Map({
2493    let mut m = indexmap::IndexMap::new();
2494    m
2495})); }
2496                }
2497                // deposits
2498                let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2499                let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
2500                if (limitsDepositMain == Value::Null) {
2501                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into()), Value::Map({
2502    let mut m = indexmap::IndexMap::new();
2503    m
2504}));
2505                }
2506                let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
2507                let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit, "max", &[]);
2508                let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
2509                let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain, "max", &[]);
2510                // find min
2511                if (limitsDepositMinMain == Value::Null) || crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain).as_bool() == Some(true) {
2512                    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, &[]));
2513                }
2514                // find max
2515                if (limitsDepositMaxMain == Value::Null) || crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain).as_bool() == Some(true) {
2516                    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, &[]));
2517                }
2518                // withdrawals
2519                let mut limitsWithdraw: Value = self.safe_dict_k(limits, "withdraw", &[]);
2520                let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain, "withdraw", &[]);
2521                if (limitsWithdrawMain == Value::Null) {
2522                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into()), Value::Map({
2523    let mut m = indexmap::IndexMap::new();
2524    m
2525}));
2526                }
2527                let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
2528                let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw, "max", &[]);
2529                let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
2530                let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain, "max", &[]);
2531                // find min
2532                if (limitsWithdrawMinMain == Value::Null) || crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain).as_bool() == Some(true) {
2533                    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, &[]));
2534                }
2535                // find max
2536                if (limitsWithdrawMaxMain == Value::Null) || crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain).as_bool() == Some(true) {
2537                    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, &[]));
2538                }
2539            }
2540            }
2541        }
2542        return self.extend(Value::Map({
2543    let mut m = indexmap::IndexMap::new();
2544        m.insert("info".to_string(), Value::Null);
2545        m.insert("id".to_string(), Value::Null);
2546        m.insert("numericId".to_string(), Value::Null);
2547        m.insert("code".to_string(), Value::Null);
2548        m.insert("precision".to_string(), Value::Null);
2549        m.insert("type".to_string(), Value::Null);
2550        m.insert("name".to_string(), Value::Null);
2551        m.insert("active".to_string(), Value::Null);
2552        m.insert("deposit".to_string(), Value::Null);
2553        m.insert("withdraw".to_string(), Value::Null);
2554        m.insert("fee".to_string(), Value::Null);
2555        m.insert("fees".to_string(), Value::Map({
2556    let mut m = indexmap::IndexMap::new();
2557    m
2558}));
2559        m.insert("networks".to_string(), Value::Map({
2560    let mut m = indexmap::IndexMap::new();
2561    m
2562}));
2563        m.insert("limits".to_string(), Value::Map({
2564    let mut m = indexmap::IndexMap::new();
2565        m.insert("deposit".to_string(), Value::Map({
2566    let mut m = indexmap::IndexMap::new();
2567        m.insert("min".to_string(), Value::Null);
2568        m.insert("max".to_string(), Value::Null);
2569    m
2570}));
2571        m.insert("withdraw".to_string(), Value::Map({
2572    let mut m = indexmap::IndexMap::new();
2573        m.insert("min".to_string(), Value::Null);
2574        m.insert("max".to_string(), Value::Null);
2575    m
2576}));
2577    m
2578}));
2579    m
2580}), &[currency]);
2581
2582    Value::Null
2583}
2584
2585    fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2586        let mut market = get_arg(optional_args, 0, Value::Null);
2587        let mut cleanStructure: Value = Value::Map({
2588            let mut m = indexmap::IndexMap::new();
2589                m.insert("id".to_string(), Value::Null);
2590                m.insert("lowercaseId".to_string(), Value::Null);
2591                m.insert("symbol".to_string(), Value::Null);
2592                m.insert("base".to_string(), Value::Null);
2593                m.insert("quote".to_string(), Value::Null);
2594                m.insert("settle".to_string(), Value::Null);
2595                m.insert("baseId".to_string(), Value::Null);
2596                m.insert("quoteId".to_string(), Value::Null);
2597                m.insert("settleId".to_string(), Value::Null);
2598                m.insert("type".to_string(), Value::Null);
2599                m.insert("spot".to_string(), Value::Null);
2600                m.insert("margin".to_string(), Value::Null);
2601                m.insert("swap".to_string(), Value::Null);
2602                m.insert("future".to_string(), Value::Null);
2603                m.insert("option".to_string(), Value::Null);
2604                m.insert("index".to_string(), Value::Null);
2605                m.insert("active".to_string(), Value::Null);
2606                m.insert("contract".to_string(), Value::Null);
2607                m.insert("linear".to_string(), Value::Null);
2608                m.insert("inverse".to_string(), Value::Null);
2609                m.insert("subType".to_string(), Value::Null);
2610                m.insert("taker".to_string(), Value::Null);
2611                m.insert("maker".to_string(), Value::Null);
2612                m.insert("contractSize".to_string(), Value::Null);
2613                m.insert("expiry".to_string(), Value::Null);
2614                m.insert("expiryDatetime".to_string(), Value::Null);
2615                m.insert("strike".to_string(), Value::Null);
2616                m.insert("optionType".to_string(), Value::Null);
2617                m.insert("precision".to_string(), Value::Map({
2618    let mut m = indexmap::IndexMap::new();
2619        m.insert("amount".to_string(), Value::Null);
2620        m.insert("price".to_string(), Value::Null);
2621        m.insert("cost".to_string(), Value::Null);
2622        m.insert("base".to_string(), Value::Null);
2623        m.insert("quote".to_string(), Value::Null);
2624    m
2625}));
2626                m.insert("limits".to_string(), Value::Map({
2627    let mut m = indexmap::IndexMap::new();
2628        m.insert("leverage".to_string(), Value::Map({
2629    let mut m = indexmap::IndexMap::new();
2630        m.insert("min".to_string(), Value::Null);
2631        m.insert("max".to_string(), Value::Null);
2632    m
2633}));
2634        m.insert("amount".to_string(), Value::Map({
2635    let mut m = indexmap::IndexMap::new();
2636        m.insert("min".to_string(), Value::Null);
2637        m.insert("max".to_string(), Value::Null);
2638    m
2639}));
2640        m.insert("price".to_string(), Value::Map({
2641    let mut m = indexmap::IndexMap::new();
2642        m.insert("min".to_string(), Value::Null);
2643        m.insert("max".to_string(), Value::Null);
2644    m
2645}));
2646        m.insert("cost".to_string(), Value::Map({
2647    let mut m = indexmap::IndexMap::new();
2648        m.insert("min".to_string(), Value::Null);
2649        m.insert("max".to_string(), Value::Null);
2650    m
2651}));
2652    m
2653}));
2654                m.insert("marginModes".to_string(), Value::Map({
2655    let mut m = indexmap::IndexMap::new();
2656        m.insert("cross".to_string(), Value::Null);
2657        m.insert("isolated".to_string(), Value::Null);
2658    m
2659}));
2660                m.insert("created".to_string(), Value::Null);
2661                m.insert("info".to_string(), Value::Null);
2662            m
2663        });
2664        if (market != Value::Null) {
2665            let mut result: Value = self.extend(cleanStructure.clone(), &[market]);
2666            // set undefined swap/future/etc
2667            if (match &(result.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
2668                if (result.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null) == Value::Null) {
2669                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("contract".into(), Value::Bool(false)); }
2670                }
2671                if (result.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null) == Value::Null) {
2672                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("swap".into(), Value::Bool(false)); }
2673                }
2674                if (result.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null) == Value::Null) {
2675                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("future".into(), Value::Bool(false)); }
2676                }
2677                if (result.as_map().and_then(|__m| __m.get("option")).cloned().unwrap_or(Value::Null) == Value::Null) {
2678                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("option".into(), Value::Bool(false)); }
2679                }
2680                if (result.as_map().and_then(|__m| __m.get("index")).cloned().unwrap_or(Value::Null) == Value::Null) {
2681                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("index".into(), Value::Bool(false)); }
2682                }
2683            }
2684            return result;
2685        }
2686        return self.extend(cleanStructure, &[]);
2687
2688    Value::Null
2689}
2690
2691    fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2692        let mut currencies = get_arg(optional_args, 0, Value::Null);
2693        let mut values: Vec<Value> = Vec::new();
2694        // build the id index locally and publish it in one swap, so ws handlers never see a half-built table
2695        let mut marketsById: Value = Value::Map({
2696            let mut m = indexmap::IndexMap::new();
2697            m
2698        });
2699        // handle marketId conflicts
2700        // we insert spot markets first
2701        let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".into()), &[Value::Bool(true), Value::Bool(true)]);
2702        {
2703                        let mut i: Value = Value::Int(0);
2704            let mut __for_first_87: bool = true;
2705            while { if !__for_first_87 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_87 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketValues.len() as i64) as f64) } {
2706            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);
2707            if (in_op(&marketsById, &crate::value::get_value_k(&value, "id"))) {
2708                let mut marketsByIdArray: Value = get_value(&marketsById, &crate::value::get_value_k(&value, "id"));
2709                append_to_array(&mut marketsByIdArray, value.clone());
2710                add_element_to_object(&mut marketsById, &crate::value::get_value_k(&value, "id"), marketsByIdArray);
2711            }  else {
2712                add_element_to_object(&mut marketsById, &crate::value::get_value_k(&value, "id"), Value::from(vec![value.clone()]));
2713            }
2714            // strip undefined-valued keys from the parsed market before deepExtend,
2715            // otherwise an explicit `taker: undefined` (from safeMarketStructure)
2716            // would clobber the fee defaults from this.fees['trading'] in the merge
2717            let mut valueDefined: Value = Value::Map({
2718                let mut m = indexmap::IndexMap::new();
2719                m
2720            });
2721            let mut valueKeys: Value = object_keys(&value);
2722            {
2723                                let mut j: Value = Value::Int(0);
2724                let mut __for_first_86: bool = true;
2725                while { if !__for_first_86 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_86 = false; j.as_f64().unwrap_or(f64::NAN) < ((valueKeys.len() as i64) as f64) } {
2726                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);
2727                if (get_value(&value, &valueKey) != Value::Null) {
2728                    if let Value::Dict(__d) = &mut valueDefined { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&valueKey), get_value(&value, &valueKey)); }
2729                }
2730            }
2731            }
2732            let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2733                let mut m = indexmap::IndexMap::new();
2734                    m.insert("precision".to_string(), self.precision.clone());
2735                    m.insert("limits".to_string(), self.limits.clone());
2736                m
2737            }), self.fees.as_map().and_then(|__m| __m.get("trading")).cloned().unwrap_or(Value::Null), valueDefined]);
2738            if (match &(market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
2739                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("linear".into()));
2740            }  else if (match &(market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
2741                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("inverse".into()));
2742            }  else {
2743                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Null);
2744            }
2745            values.push(market.clone());
2746        }
2747        }
2748        { let __t = self.map_to_safe_map(self.index_by(Value::from(values.clone()), Value::Str("symbol".into()))); self.markets = __t; }
2749        { let __t = self.map_to_safe_map(marketsById); self.markets_by_id = __t; }
2750        let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
2751        let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
2752        self.symbols = object_keys(&marketsSortedBySymbol);
2753        self.ids = object_keys(&marketsSortedById);
2754        let mut numCurrencies: Value = Value::Int(0);
2755        if (currencies != Value::Null) {
2756            let mut keys: Value = object_keys(&currencies);
2757            numCurrencies = Value::Int(keys.len() as i64);
2758        }
2759        if numCurrencies.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2760            // currencies is always undefined when called in constructor but not when called from loadMarkets
2761            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2762        }  else {
2763            let mut baseCurrencies: Value = Value::from(vec![]);
2764            let mut quoteCurrencies: Value = Value::from(vec![]);
2765            {
2766                                let mut i: Value = Value::Int(0);
2767                let mut __for_first_88: bool = true;
2768                while { if !__for_first_88 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_88 = false; i.as_f64().unwrap_or(f64::NAN) < ((values.len() as i64) as f64) } {
2769                let mut market: Value = values.get((i).as_i64().map_or(usize::MAX, |__n| __n as usize)).cloned().unwrap_or(Value::Null);
2770                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()), &[]) });
2771                let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2772    let mut m = indexmap::IndexMap::new();
2773    m
2774})]);
2775                if (matches!(&market, Value::Dict(__d) if __d.contains_key("base"))) {
2776                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2777                        let mut m = indexmap::IndexMap::new();
2778                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".into()), Value::Str("base".into()), &[]));
2779                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2780                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2781                            m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".into()), Value::Str("amount".into()), &[defaultCurrencyPrecision.clone()]));
2782                        m
2783                    }));
2784                    if let Value::Arr(__a) = &mut baseCurrencies { std::sync::Arc::make_mut(__a).push(currency.clone()); }
2785                }
2786                if (matches!(&market, Value::Dict(__d) if __d.contains_key("quote"))) {
2787                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2788                        let mut m = indexmap::IndexMap::new();
2789                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".into()), Value::Str("quote".into()), &[]));
2790                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2791                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2792                            m.insert("precision".to_string(), self.safe_value2(marketPrecision, Value::Str("quote".into()), Value::Str("price".into()), &[defaultCurrencyPrecision]));
2793                        m
2794                    }));
2795                    if let Value::Arr(__a) = &mut quoteCurrencies { std::sync::Arc::make_mut(__a).push(currency); }
2796                }
2797            }
2798            }
2799            baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2800            quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2801            { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".into()))); self.baseCurrencies = __t; }
2802            { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".into()))); self.quoteCurrencies = __t; }
2803            let mut allCurrencies: Value = self.array_concat(baseCurrencies, quoteCurrencies);
2804            let mut groupedCurrencies: Value = self.group_by(allCurrencies, Value::Str("code".into()), &[]);
2805            let mut codes: Value = object_keys(&groupedCurrencies);
2806            let mut resultingCurrencies: Vec<Value> = Vec::new();
2807            {
2808                                let mut i: Value = Value::Int(0);
2809                let mut __for_first_90: bool = true;
2810                while { if !__for_first_90 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_90 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2811                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);
2812                let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code, &[Value::from(vec![])]);
2813                let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2814                {
2815                                        let mut j: Value = Value::Int(1);
2816                    let mut __for_first_89: bool = true;
2817                    while { if !__for_first_89 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_89 = false; j.as_f64().unwrap_or(f64::NAN) < ((groupedCurrenciesCode.len() as i64) as f64) } {
2818                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2819                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2820                    let mut currentPrecision: Value = self.safe_number_k(currentCurrency.clone(), "precision", &[]);
2821                    let mut highestPrecision: Value = self.safe_number_k(highestPrecisionCurrency.clone(), "precision", &[]);
2822                    if (currentPrecision == Value::Null) || (highestPrecision == Value::Null) {
2823                        continue;
2824                    }
2825                    if (self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64()) {
2826                        if highestPrecision.as_f64().unwrap_or(f64::NAN) > currentPrecision.as_f64().unwrap_or(f64::NAN) {
2827                            highestPrecisionCurrency = currentCurrency.clone();
2828                        }
2829                    }  else if currentPrecision.as_f64().unwrap_or(f64::NAN) > highestPrecision.as_f64().unwrap_or(f64::NAN) {
2830                        highestPrecisionCurrency = currentCurrency;
2831                    }
2832                }
2833                }
2834                resultingCurrencies.push(highestPrecisionCurrency);
2835            }
2836            }
2837            let mut sortedCurrencies: Value = self.sort_by(Value::from(resultingCurrencies), Value::Str("code".into()), &[]);
2838            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(sortedCurrencies, Value::Str("code".into()))])); self.currencies = __t; }
2839        }
2840        { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".into())); self.currencies_by_id = __t; }
2841        let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
2842        self.codes = object_keys(&currenciesSortedByCode);
2843        if (self.markets.clone() == Value::Null) {
2844            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" setMarkets() markets not set".into()))));
2845        }
2846        return self.markets.clone();
2847
2848    Value::Null
2849}
2850
2851    fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2852        // Validate that both exchanges are of the same type
2853        if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".into()))) {
2854            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", 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")).into()), Value::Str(")".into()))));
2855        }
2856        // Validate that source exchange has loaded markets
2857        if (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) || (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) {
2858            panic!("{}", crate::exchange_errors::exchange_error("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function"));
2859        }
2860        // Set all market-related data
2861        self.markets = get_value(&sourceExchange, &Value::Str("markets".into()));
2862        self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".into()));
2863        self.symbols = get_value(&sourceExchange, &Value::Str("symbols".into()));
2864        self.ids = get_value(&sourceExchange, &Value::Str("ids".into()));
2865        self.currencies = get_value(&sourceExchange, &Value::Str("currencies".into()));
2866        self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".into()));
2867        self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".into()));
2868        self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".into()));
2869        self.codes = get_value(&sourceExchange, &Value::Str("codes".into()));
2870        // check marketHelperProps
2871        let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".into())), Value::Str("marketHelperProps".into()), &[Value::from(vec![])]);
2872        {
2873                        let mut i: Value = Value::Int(0);
2874            let mut __for_first_91: bool = true;
2875            while { if !__for_first_91 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_91 = false; i.as_f64().unwrap_or(f64::NAN) < ((sourceExchangeHelpers.len() as i64) as f64) } {
2876            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2877            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2878            if (get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper) != Value::Null) {
2879                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)); }
2880            }
2881        }
2882        }
2883        return Value::Null;
2884
2885    Value::Null
2886}
2887
2888    fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2889        let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2890        let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe, &[wsBaseDescribe]);
2891        return superWithRestDescribe;
2892
2893    Value::Null
2894}
2895
2896    fn safe_balance(&self, mut balance: Value) -> Value {
2897        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())]), &[]);
2898        let mut codes: Value = object_keys(&balances);
2899        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("free".into(), Value::Map({
2900    let mut m = indexmap::IndexMap::new();
2901    m
2902})); }
2903        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("used".into(), Value::Map({
2904    let mut m = indexmap::IndexMap::new();
2905    m
2906})); }
2907        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("total".into(), Value::Map({
2908    let mut m = indexmap::IndexMap::new();
2909    m
2910})); }
2911        let mut debtBalance: Value = Value::Map({
2912            let mut m = indexmap::IndexMap::new();
2913            m
2914        });
2915        {
2916                        let mut i: Value = Value::Int(0);
2917            let mut __for_first_92: bool = true;
2918            while { if !__for_first_92 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_92 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2919            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);
2920            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()), &[]);
2921            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()), &[]);
2922            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()), &[]);
2923            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()), &[]);
2924            if (total == Value::Null) && (free != Value::Null) && (used != Value::Null) {
2925                total = crate::precise::Precise::stringAdd(&free, &used);
2926            }
2927            if (free == Value::Null) && (total != Value::Null) && (used != Value::Null) {
2928                free = crate::precise::Precise::stringSub(&total, &used);
2929            }
2930            if (used == Value::Null) && (total != Value::Null) && (free != Value::Null) {
2931                used = crate::precise::Precise::stringSub(&total, &free);
2932            }
2933            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".into()), self.parse_number(free, &[]));
2934            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".into()), self.parse_number(used, &[]));
2935            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".into()), self.parse_number(total, &[]));
2936            { 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); };
2937            { 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); };
2938            { 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); };
2939            if (debt != Value::Null) {
2940                add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".into()), self.parse_number(debt, &[]));
2941                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")); }
2942            }
2943        }
2944        }
2945        let mut debtBalanceArray: Value = Value::Array(debtBalance.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
2946        let mut length: Value = Value::Int(debtBalanceArray.len() as i64);
2947        if (length != Value::Null) && (length.as_f64() != Some(0.0)) {
2948            if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("debt".into(), debtBalance); }
2949        }
2950        return balance;
2951
2952    Value::Null
2953}
2954
2955    fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2956        let mut market = get_arg(optional_args, 0, Value::Null);
2957        // parses numbers as strings
2958        // * it is important pass the trades as unparsed rawTrades
2959        let mut orderDict: Value = order.clone();
2960        if (order == Value::Null) {
2961            orderDict = Value::Map({
2962                let mut m = indexmap::IndexMap::new();
2963                m
2964            });
2965        }
2966        let mut amount: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "amount", &[]));
2967        let mut remaining: Value = self.safe_string_k(orderDict.clone(), "remaining", &[]);
2968        let mut filled: Value = self.safe_string_k(orderDict.clone(), "filled", &[]);
2969        let mut cost: Value = self.safe_string_k(orderDict.clone(), "cost", &[]);
2970        let mut average: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "average", &[]));
2971        let mut price: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "price", &[]));
2972        let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastTradeTimestamp", &[]);
2973        let mut symbol: Value = self.safe_string_k(orderDict.clone(), "symbol", &[]);
2974        let mut side: Value = self.safe_string_k(orderDict.clone(), "side", &[]);
2975        let mut status: Value = self.safe_string_k(orderDict.clone(), "status", &[]);
2976        let mut parseFilled: bool = filled == Value::Null;
2977        let mut parseCost: bool = cost == Value::Null;
2978        let mut parseLastTradeTimeTimestamp: bool = lastTradeTimeTimestamp == Value::Null;
2979        let mut fee: Value = self.safe_value_k(orderDict.clone(), "fee", &[]);
2980        let mut parseFee: bool = fee == Value::Null;
2981        let mut parseFees: bool = self.safe_value_k(orderDict.clone(), "fees", &[]) == Value::Null;
2982        let mut parseSymbol: bool = symbol == Value::Null;
2983        let mut parseSide: bool = side == Value::Null;
2984        let mut shouldParseFees: bool = parseFee || parseFees;
2985        let mut fees: Value = self.safe_list_k(orderDict.clone(), "fees", &[Value::from(vec![])]);
2986        let mut trades: Value = Value::from(vec![]);
2987        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);
2988        if parseFilled || parseCost || shouldParseFees {
2989            let mut rawTrades: Value = self.safe_value_k(orderDict.clone(), "trades", &[trades.clone()]);
2990            // const oldNumber = this.number;
2991            // we parse trades as strings here!
2992            // i don't think this is needed anymore
2993            // (this as any).number = String;
2994            let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
2995            // parse trades if they haven't already been parsed
2996            let mut tradesAreParsed: bool = (firstTrade != Value::Null) && (in_op(&firstTrade, &Value::Str("info".into()))) && (in_op(&firstTrade, &Value::Str("id".into())));
2997            if !tradesAreParsed {
2998                trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
2999            }  else {
3000                trades = rawTrades;
3001            }
3002            // this.number = oldNumber; why parse trades as strings if you read the value using `safeString` ?
3003            let mut tradesLength: Value = Value::Int(0);
3004            let mut isArray: bool = matches!(&trades, Value::Arr(_));
3005            if isArray {
3006                tradesLength = Value::Int(trades.len() as i64);
3007            }
3008            if isArray && (tradesLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) {
3009                // move properties that are defined in trades up into the order
3010                if (orderDict.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) == Value::Null) {
3011                    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"));
3012                }
3013                if (orderDict.as_map().and_then(|__m| __m.get("side")).cloned().unwrap_or(Value::Null) == Value::Null) {
3014                    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"));
3015                }
3016                if (orderDict.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null) == Value::Null) {
3017                    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"));
3018                }
3019                if (orderDict.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null) == Value::Null) {
3020                    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"));
3021                }
3022                if parseFilled {
3023                    filled = Value::Str("0".into());
3024                }
3025                if parseCost {
3026                    cost = Value::Str("0".into());
3027                }
3028                {
3029                                        let mut i: Value = Value::Int(0);
3030                    let mut __for_first_94: bool = true;
3031                    while { if !__for_first_94 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_94 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3032                    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);
3033                    let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3034                    if parseFilled && (tradeAmount != Value::Null) {
3035                        filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
3036                    }
3037                    let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3038                    if parseCost && (tradeCost != Value::Null) {
3039                        cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
3040                    }
3041                    if parseSymbol {
3042                        symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
3043                    }
3044                    if parseSide {
3045                        side = self.safe_string_k(trade.clone(), "side", &[]);
3046                    }
3047                    let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
3048                    if parseLastTradeTimeTimestamp && (tradeTimestamp != Value::Null) {
3049                        if (lastTradeTimeTimestamp == Value::Null) {
3050                            lastTradeTimeTimestamp = tradeTimestamp.clone();
3051                        }  else {
3052                            lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
3053                        }
3054                    }
3055                    if shouldParseFees {
3056                        let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
3057                        if (tradeFees != Value::Null) {
3058                            {
3059                                                                let mut j: Value = Value::Int(0);
3060                                let mut __for_first_93: bool = true;
3061                                while { if !__for_first_93 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_93 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&tradeFees).as_f64().unwrap_or(f64::NAN) } {
3062                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3063                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3064                                if let Value::Arr(__a) = &mut fees { std::sync::Arc::make_mut(__a).push(self.extend(Value::Map({
3065                                    let mut m = indexmap::IndexMap::new();
3066                                    m
3067                                }), &[tradeFee.clone()])); }
3068                            }
3069                            }
3070                        }  else {
3071                            let mut tradeFee: Value = self.safe_value_k(trade, "fee", &[]);
3072                            if (tradeFee != Value::Null) {
3073                                if let Value::Arr(__a) = &mut fees { std::sync::Arc::make_mut(__a).push(self.extend(Value::Map({
3074                                    let mut m = indexmap::IndexMap::new();
3075                                    m
3076                                }), &[tradeFee.clone()])); }
3077                            }
3078                        }
3079                    }
3080                }
3081                }
3082            }
3083        }
3084        if shouldParseFees {
3085            let mut reducedFees: Value = fees.clone();
3086            if self.reduceFees.as_bool() == Some(true) {
3087                reducedFees = self.reduce_fees_by_currency(fees);
3088            }
3089            if (reducedFees == Value::Null) {
3090                reducedFees = Value::from(vec![]);
3091            }
3092            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3093            {
3094                                let mut i: Value = Value::Int(0);
3095                let mut __for_first_95: bool = true;
3096                while { if !__for_first_95 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_95 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3097                { 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); };
3098                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()))) {
3099                    { 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); };
3100                }
3101            }
3102            }
3103            if !parseFee && (reducedLength == 0.0) {
3104                // copy fee to avoid modification by reference
3105                let mut feeCopy: Value = self.deep_extend(fee, &[]);
3106                { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".into()), __be_tmp); };
3107                if (in_op(&feeCopy, &Value::Str("rate".into()))) {
3108                    { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".into()), __be_tmp); };
3109                }
3110                append_to_array(&mut reducedFees, feeCopy);
3111            }
3112            add_element_to_object(&mut orderDict, &Value::Str("fees".into()), reducedFees.clone());
3113            if parseFee && (reducedLength == 1.0) {
3114                add_element_to_object(&mut orderDict, &Value::Str("fee".into()), reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
3115            }
3116        }
3117        if (amount == Value::Null) {
3118            // ensure amount = filled + remaining
3119            if (filled != Value::Null) && (remaining != Value::Null) {
3120                amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3121            }  else if (status.as_str() == Some("closed")) {
3122                amount = filled.clone();
3123            }
3124        }
3125        if (filled == Value::Null) {
3126            if (amount != Value::Null) && (remaining != Value::Null) {
3127                filled = crate::precise::Precise::stringSub(&amount, &remaining);
3128            }  else if (status.as_str() == Some("closed")) && (amount != Value::Null) {
3129                filled = amount.clone();
3130            }
3131        }
3132        if (remaining == Value::Null) {
3133            if (amount != Value::Null) && (filled != Value::Null) {
3134                remaining = crate::precise::Precise::stringSub(&amount, &filled);
3135            }  else if (status.as_str() == Some("closed")) {
3136                remaining = Value::Str("0".into());
3137            }
3138        }
3139        // ensure that the average field is calculated correctly
3140        let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3141        let mut contractSize: Value = self.number_to_string(self.safe_value_k(market, "contractSize", &[Value::Int(1)]));
3142        // inverse
3143        // price = filled * contract size / cost
3144        //
3145        // linear
3146        // price = cost / (filled * contract size)
3147        if (average == Value::Null) {
3148            if (filled != Value::Null) && (cost != Value::Null) && crate::precise::Precise::stringGt(&filled, &Value::Str("0".into())).as_bool() == Some(true) {
3149                let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3150                if inverse.as_bool() == Some(true) {
3151                    average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3152                }  else {
3153                    average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3154                }
3155            }
3156        }
3157        // similarly
3158        // inverse
3159        // cost = filled * contract size / price
3160        //
3161        // linear
3162        // cost = filled * contract size * price
3163        let mut costPriceExists: bool = (average != Value::Null) || (price != Value::Null);
3164        if parseCost && (filled != Value::Null) && costPriceExists {
3165            let mut multiplyPrice: Value = Value::Null;
3166            if (average == Value::Null) {
3167                multiplyPrice = price.clone();
3168            }  else {
3169                multiplyPrice = average.clone();
3170            }
3171            // contract trading
3172            let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3173            if inverse.as_bool() == Some(true) {
3174                cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3175            }  else {
3176                cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3177            }
3178        }
3179        // support for market orders
3180        let mut orderType: Value = self.safe_value_k(orderDict.clone(), "type", &[]);
3181        let mut emptyPrice: bool = (price == Value::Null) || crate::precise::Precise::stringEquals(&price, &Value::Str("0".into())).as_bool() == Some(true);
3182        if emptyPrice && (orderType.as_str() == Some("market")) {
3183            price = average.clone();
3184        }
3185        {
3186                        let mut i: Value = Value::Int(0);
3187            let mut __for_first_97: bool = true;
3188            while { if !__for_first_97 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_97 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3189            let mut entry: Value = get_value(&trades, &i);
3190            let mut entry: Value = get_value(&trades, &i);
3191            { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".into()), __be_tmp); };
3192            { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".into()), __be_tmp); };
3193            { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".into()), __be_tmp); };
3194            let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3195    let mut m = indexmap::IndexMap::new();
3196    m
3197})]);
3198            { 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); } }
3199            if (matches!(&tradeFee, Value::Dict(__d) if __d.contains_key("rate"))) {
3200                { 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); } }
3201            }
3202            let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::from(vec![])]);
3203            {
3204                                let mut j: Value = Value::Int(0);
3205                let mut __for_first_96: bool = true;
3206                while { if !__for_first_96 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_96 = false; j.as_f64().unwrap_or(f64::NAN) < ((entryFees.len() as i64) as f64) } {
3207                { 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); };
3208            }
3209            }
3210            add_element_to_object(&mut entry, &Value::Str("fees".into()), entryFees);
3211            add_element_to_object(&mut entry, &Value::Str("fee".into()), tradeFee);
3212        }
3213        }
3214        let mut timeInForce: Value = self.safe_string_k(orderDict.clone(), "timeInForce", &[]);
3215        let mut postOnly: Value = self.safe_value_k(orderDict.clone(), "postOnly", &[]);
3216        // timeInForceHandling
3217        if (timeInForce == Value::Null) {
3218            if !isTriggerOrSLTpOrder && (self.safe_string_k(orderDict.clone(), "type", &[]).as_str() == Some("market")) {
3219                timeInForce = Value::Str("IOC".into());
3220            }
3221            // allow postOnly override
3222            if (match &(postOnly) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
3223                timeInForce = Value::Str("PO".into());
3224            }
3225        }  else if (postOnly == Value::Null) {
3226            // timeInForce is not undefined here
3227            postOnly = Value::Bool(timeInForce.as_str() == Some("PO"));
3228        }
3229        let mut timestamp: Value = self.safe_integer_k(orderDict.clone(), "timestamp", &[]);
3230        let mut lastUpdateTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastUpdateTimestamp", &[]);
3231        let mut datetime: Value = self.safe_string_k(orderDict.clone(), "datetime", &[]);
3232        if (datetime == Value::Null) {
3233            datetime = self.iso8601(timestamp.clone());
3234        }
3235        let mut triggerPrice: Value = self.parse_number(self.safe_string2(orderDict.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]), &[]);
3236        let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "takeProfitPrice", &[]), &[]);
3237        let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "stopLossPrice", &[]), &[]);
3238        return self.extend(orderDict.clone(), &[Value::Map({
3239    let mut m = indexmap::IndexMap::new();
3240        m.insert("id".to_string(), self.safe_string_k(orderDict.clone(), "id", &[]));
3241        m.insert("clientOrderId".to_string(), self.safe_string_k(orderDict.clone(), "clientOrderId", &[]));
3242        m.insert("timestamp".to_string(), timestamp);
3243        m.insert("datetime".to_string(), datetime);
3244        m.insert("symbol".to_string(), symbol);
3245        m.insert("type".to_string(), self.safe_string_k(orderDict.clone(), "type", &[]));
3246        m.insert("side".to_string(), side);
3247        m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp);
3248        m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp);
3249        m.insert("price".to_string(), self.parse_number(price, &[]));
3250        m.insert("amount".to_string(), self.parse_number(amount, &[]));
3251        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3252        m.insert("average".to_string(), self.parse_number(average, &[]));
3253        m.insert("filled".to_string(), self.parse_number(filled, &[]));
3254        m.insert("remaining".to_string(), self.parse_number(remaining, &[]));
3255        m.insert("timeInForce".to_string(), timeInForce);
3256        m.insert("postOnly".to_string(), postOnly);
3257        m.insert("trades".to_string(), trades);
3258        m.insert("reduceOnly".to_string(), self.safe_value_k(orderDict.clone(), "reduceOnly", &[]));
3259        m.insert("stopPrice".to_string(), triggerPrice.clone());
3260        m.insert("triggerPrice".to_string(), triggerPrice);
3261        m.insert("takeProfitPrice".to_string(), takeProfitPrice);
3262        m.insert("stopLossPrice".to_string(), stopLossPrice);
3263        m.insert("status".to_string(), status);
3264        m.insert("fee".to_string(), self.safe_value_k(orderDict, "fee", &[]));
3265    m
3266})]);
3267
3268    Value::Null
3269}
3270
3271    fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3272        let mut market = get_arg(optional_args, 0, Value::Null);
3273        let mut since = get_arg(optional_args, 1, Value::Null);
3274        let mut limit = get_arg(optional_args, 2, Value::Null);
3275        let mut params = get_arg(optional_args, 3, Value::Map({
3276    let mut m = indexmap::IndexMap::new();
3277    m
3278}));
3279        //
3280        // the value of orders is either a dict or a list
3281        //
3282        // dict
3283        //
3284        //     {
3285        //         'id1': { ... },
3286        //         'id2': { ... },
3287        //         'id3': { ... },
3288        //         ...
3289        //     }
3290        //
3291        // list
3292        //
3293        //     [
3294        //         { 'id': 'id1', ... },
3295        //         { 'id': 'id2', ... },
3296        //         { 'id': 'id3', ... },
3297        //         ...
3298        //     ]
3299        //
3300        if (orders == Value::Null) {
3301            return Value::from(vec![]);
3302        }
3303        let mut results: Value = Value::from(vec![]);
3304        if (matches!(&orders, Value::Arr(_))) {
3305            {
3306                                let mut i: Value = Value::Int(0);
3307                let mut __for_first_98: bool = true;
3308                while { if !__for_first_98 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_98 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
3309                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, get_value(&orders, &i), &[market.clone()]); // don't inline this call
3310                let mut order: Value = self.extend(parsed, &[params.clone()]);
3311                if let Value::Arr(__a) = &mut results { std::sync::Arc::make_mut(__a).push(order.clone()); }
3312            }
3313            }
3314        }  else {
3315            let mut ids: Value = object_keys(&orders);
3316            {
3317                                let mut i: Value = Value::Int(0);
3318                let mut __for_first_99: bool = true;
3319                while { if !__for_first_99 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_99 = false; i.as_f64().unwrap_or(f64::NAN) < ((ids.len() as i64) as f64) } {
3320                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);
3321                let mut idExtended: Value = self.extend(Value::Map({
3322                    let mut m = indexmap::IndexMap::new();
3323                        m.insert("id".to_string(), id.clone());
3324                    m
3325                }), &[get_value(&orders, &id)]);
3326                let mut parsedOrder: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, idExtended, &[market.clone()]); // don't  inline these calls
3327                let mut order: Value = self.extend(parsedOrder, &[params.clone()]);
3328                if let Value::Arr(__a) = &mut results { std::sync::Arc::make_mut(__a).push(order); }
3329            }
3330            }
3331        }
3332        results = self.sort_by(results.clone(), Value::Str("timestamp".into()), &[]);
3333        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
3334        return self.filter_by_symbol_since_limit(results, &[symbol, since, limit]);
3335
3336    Value::Null
3337}
3338
3339    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 {
3340        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3341        let mut feeRate = get_arg(optional_args, 1, Value::Null);
3342        let mut params = get_arg(optional_args, 2, Value::Map({
3343    let mut m = indexmap::IndexMap::new();
3344    m
3345}));
3346        if (type_var.as_str() == Some("market")) && (takerOrMaker.as_str() == Some("maker")) {
3347            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()))));
3348        }
3349        let mut markets: Value = self.markets.clone();
3350        if (markets == Value::Null) {
3351            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
3352        }
3353        let mut market: Value = get_value(&markets, &symbol);
3354        let mut market: Value = get_value(&markets, &symbol);
3355        let mut feeSide: Option<String> = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".into())]).as_str().map(str::to_owned);
3356        let mut useQuote: Value = Value::Null;
3357        if (feeSide.as_deref() == Some("get")) {
3358            // the fee is always in the currency you get
3359            useQuote = Value::Bool(side.as_str() == Some("sell"));
3360        }  else if (feeSide.as_deref() == Some("give")) {
3361            // the fee is always in the currency you give
3362            useQuote = Value::Bool(side.as_str() == Some("buy"));
3363        }  else {
3364            // the fee is always in feeSide currency
3365            useQuote = Value::Bool(feeSide.as_deref() == Some("quote"));
3366        }
3367        let mut cost: Value = self.number_to_string(amount);
3368        let mut key: Value = Value::Null;
3369        if useQuote.as_bool() == Some(true) {
3370            let mut priceString: Value = self.number_to_string(price);
3371            cost = crate::precise::Precise::stringMul(&cost, &priceString);
3372            key = Value::Str("quote".into());
3373        }  else {
3374            key = Value::Str("base".into());
3375        }
3376        // for derivatives, the fee is in 'settle' currency
3377        if !(match &(crate::value::get_value_k(&market, "spot")) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
3378            key = Value::Str("settle".into());
3379        }
3380        // even if `takerOrMaker` argument was set to 'maker', for 'market' orders we should forcefully override it to 'taker'
3381        let mut takerOrMakerResolved: Value = (if (type_var.as_str() == Some("market")) { Value::Str("taker".into()) } else { takerOrMaker });
3382        let mut rate: Value = (if (feeRate != Value::Null) { self.number_to_string(feeRate) } else { self.safe_string(market.clone(), takerOrMakerResolved.clone(), &[]) });
3383        cost = crate::precise::Precise::stringMul(&cost, &rate);
3384        return Value::Map({
3385    let mut m = indexmap::IndexMap::new();
3386        m.insert("type".to_string(), takerOrMakerResolved);
3387        m.insert("currency".to_string(), get_value(&market, &key));
3388        m.insert("rate".to_string(), self.parse_number(rate, &[]));
3389        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3390    m
3391});
3392
3393    Value::Null
3394}
3395
3396    fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3397        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3398        let mut params = get_arg(optional_args, 1, Value::Map({
3399    let mut m = indexmap::IndexMap::new();
3400    m
3401}));
3402        return self.calculate_fee_with_rate(symbol, type_var, side, amount, price, &[takerOrMaker, Value::Null, params]);
3403
3404    Value::Null
3405}
3406
3407    fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3408        let mut market = get_arg(optional_args, 0, Value::Null);
3409        let __market_empty = indexmap::IndexMap::new();
3410        let market = market.as_map().unwrap_or(&__market_empty);
3411        let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
3412        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 });
3413        let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
3414        let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3415        let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3416        if (baseValue == Value::Null) && (contracts != Value::Null) && (contractSize != Value::Null) && (price != Value::Null) {
3417            baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
3418        }
3419        if (quoteValue == Value::Null) && (baseValue != Value::Null) && (price != Value::Null) {
3420            quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
3421        }
3422        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(contracts, &[])); }
3423        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(contractSize, &[])); }
3424        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3425        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("baseValue".into(), self.parse_number(baseValue, &[])); }
3426        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("quoteValue".into(), self.parse_number(quoteValue, &[])); }
3427        return liquidation;
3428
3429    Value::Null
3430}
3431
3432    fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3433        let mut market = get_arg(optional_args, 0, Value::Null);
3434        let __market_empty = indexmap::IndexMap::new();
3435        let market = market.as_map().unwrap_or(&__market_empty);
3436        let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3437        let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
3438        let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3439        if (cost == Value::Null) {
3440            // contract trading
3441            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 });
3442            let mut multiplyPrice: Value = price.clone();
3443            if (contractSize != Value::Null) {
3444                let mut inverse: Value = (match market.get("inverse") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) });
3445                if inverse.as_bool() == Some(true) {
3446                    multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &price);
3447                }
3448                multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3449            }
3450            cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
3451        }
3452        let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
3453        let mut resultFee: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3454        let mut resultFees: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
3455        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fee".into(), resultFee); }
3456        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fees".into(), resultFees); }
3457        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("amount".into(), self.parse_number(amount, &[])); }
3458        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3459        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("cost".into(), self.parse_number(cost, &[])); }
3460        return trade;
3461
3462    Value::Null
3463}
3464
3465    fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3466        let mut timestamp = get_arg(optional_args, 0, Value::Null);
3467        let mut side = get_arg(optional_args, 1, Value::Null);
3468        let mut amount = get_arg(optional_args, 2, Value::Null);
3469        let mut price = get_arg(optional_args, 3, Value::Null);
3470        let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3471        // this approach is being used by multiple exchanges (mexc, woo, coinsbit, dydx, ...)
3472        let mut id: Value = Value::Null;
3473        if (timestamp != Value::Null) {
3474            id = self.number_to_string(timestamp);
3475            if (side != Value::Null) {
3476                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), side).into())).into());
3477            }
3478            if (amount != Value::Null) {
3479                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(amount)).into())).into());
3480            }
3481            if (price != Value::Null) {
3482                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(price)).into())).into());
3483            }
3484            if (takerOrMaker != Value::Null) {
3485                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), takerOrMaker).into())).into());
3486            }
3487        }
3488        return id;
3489
3490    Value::Null
3491}
3492
3493    fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3494        let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3495        let mut fees: Value = self.safe_list_k(container, "fees", &[]);
3496        let mut feeDefined: bool = fee != Value::Null;
3497        let mut feesDefined: bool = fees != Value::Null;
3498        // parsing only if at least one of them is defined
3499        let mut shouldParseFees: bool = feeDefined || feesDefined;
3500        if shouldParseFees {
3501            if feeDefined {
3502                fee = self.parse_fee_numeric(fee.clone());
3503            }
3504            if !feesDefined {
3505                // just set it directly, no further processing needed.
3506                fees = Value::from(vec![fee.clone()]);
3507            }
3508            // 'fees' were set, so reparse them
3509            let mut reducedFees: Value = fees.clone();
3510            if self.reduceFees.as_bool() == Some(true) {
3511                reducedFees = self.reduce_fees_by_currency(fees.clone());
3512            }
3513            if (reducedFees == Value::Null) {
3514                reducedFees = Value::from(vec![]);
3515            }
3516            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3517            {
3518                                let mut i: Value = Value::Int(0);
3519                let mut __for_first_100: bool = true;
3520                while { if !__for_first_100 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_100 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3521                { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3522            }
3523            }
3524            fees = reducedFees.clone();
3525            if (reducedLength == 1.0) {
3526                fee = reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3527            }  else if (reducedLength == 0.0) {
3528                fee = Value::Null;
3529            }
3530        }
3531        // in case `fee & fees` are undefined, set `fees` as empty array
3532        if (fee == Value::Null) {
3533            fee = Value::Map({
3534                let mut m = indexmap::IndexMap::new();
3535                    m.insert("cost".to_string(), Value::Null);
3536                    m.insert("currency".to_string(), Value::Null);
3537                m
3538            });
3539        }
3540        if (fees == Value::Null) {
3541            fees = Value::from(vec![]);
3542        }
3543        return Value::from(vec![fee, fees]);
3544
3545    Value::Null
3546}
3547
3548    fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3549        { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); }; // ensure numeric
3550        if (in_op(&fee, &Value::Str("rate".into()))) {
3551            { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".into()), __be_tmp); };
3552        }
3553        return fee;
3554
3555    Value::Null
3556}
3557
3558    fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3559        //  i.e. findNearestCeiling ([ 10, 30, 50],  23) returns 30
3560        let mut length: Value = Value::Int(arr.len() as i64);
3561        {
3562                        let mut i: Value = Value::Int(0);
3563            let mut __for_first_101: bool = true;
3564            while { if !__for_first_101 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_101 = false; i.as_f64().unwrap_or(f64::NAN) < length.as_f64().unwrap_or(f64::NAN) } {
3565            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);
3566            if providedValue.as_f64().unwrap_or(f64::NAN) <= current.as_f64().unwrap_or(f64::NAN) {
3567                return current;
3568            }
3569        }
3570        }
3571        return arr.as_array().and_then(|__arr| match &((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 })) { Value::Int(__n) if *__n >= 0 => __arr.get(*__n as usize), _ => None }).cloned().unwrap_or(Value::Null);
3572
3573    Value::Null
3574}
3575
3576    fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3577        let mut result: Vec<Value> = Vec::new();
3578        let mut keys: Value = object_keys(&obj);
3579        {
3580                        let mut i: Value = Value::Int(0);
3581            let mut __for_first_102: bool = true;
3582            while { if !__for_first_102 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_102 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
3583            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);
3584            let mut item: Value = get_value(&obj, &key);
3585            let mut item: Value = get_value(&obj, &key);
3586            if (item == Value::Null) {
3587                continue;
3588            }
3589            let mut itemWithKey: Value = self.extend(Value::Map({
3590                let mut m = indexmap::IndexMap::new();
3591                m
3592            }), &[item]);
3593            if let Value::Dict(__d) = &mut itemWithKey { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&keyName), key); }
3594            result.push(itemWithKey);
3595        }
3596        }
3597        return Value::from(result);
3598
3599    Value::Null
3600}
3601
3602    fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3603        let mut reversed: Value = Value::Map({
3604            let mut m = indexmap::IndexMap::new();
3605            m
3606        });
3607        let mut keys: Value = object_keys(&dict);
3608        {
3609                        let mut i: Value = Value::Int(0);
3610            let mut __for_first_103: bool = true;
3611            while { if !__for_first_103 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_103 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
3612            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);
3613            let mut value: Value = get_value(&dict, &key);
3614            let mut value: Value = get_value(&dict, &key);
3615            if matches!(&value, Value::Str(_)) {
3616                if let Value::Dict(__d) = &mut reversed { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&value), key); }
3617            }
3618        }
3619        }
3620        return reversed;
3621
3622    Value::Null
3623}
3624
3625    fn string_to_base16(&self, mut str_val: Value) -> Value {
3626        return Value::Str(format!("{}{}", Value::Str("0x".into()), self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val, &[]), &[]), &[])).into());
3627
3628    Value::Null
3629}
3630
3631    fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3632        //
3633        // this function takes a list of fee structures having the following format
3634        //
3635        //     string = true
3636        //
3637        //     [
3638        //         { 'currency': 'BTC', 'cost': '0.1' },
3639        //         { 'currency': 'BTC', 'cost': '0.2'  },
3640        //         { 'currency': 'BTC', 'cost': '0.2', 'rate': '0.00123' },
3641        //         { 'currency': 'BTC', 'cost': '0.4', 'rate': '0.00123' },
3642        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3643        //         { 'currency': 'USDT', 'cost': '12.3456' },
3644        //     ]
3645        //
3646        //     string = false
3647        //
3648        //     [
3649        //         { 'currency': 'BTC', 'cost': 0.1 },
3650        //         { 'currency': 'BTC', 'cost': 0.2 },
3651        //         { 'currency': 'BTC', 'cost': 0.2, 'rate': 0.00123 },
3652        //         { 'currency': 'BTC', 'cost': 0.4, 'rate': 0.00123 },
3653        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3654        //         { 'currency': 'USDT', 'cost': 12.3456 },
3655        //     ]
3656        //
3657        // and returns a reduced fee list, where fees are summed per currency and rate (if any)
3658        //
3659        //     string = true
3660        //
3661        //     [
3662        //         { 'currency': 'BTC', 'cost': '0.4'  },
3663        //         { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
3664        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3665        //         { 'currency': 'USDT', 'cost': '12.3456' },
3666        //     ]
3667        //
3668        //     string  = false
3669        //
3670        //     [
3671        //         { 'currency': 'BTC', 'cost': 0.3  },
3672        //         { 'currency': 'BTC', 'cost': 0.6, 'rate': 0.00123 },
3673        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3674        //         { 'currency': 'USDT', 'cost': 12.3456 },
3675        //     ]
3676        //
3677        let mut reduced: Value = Value::Map({
3678            let mut m = indexmap::IndexMap::new();
3679            m
3680        });
3681        {
3682                        let mut i: Value = Value::Int(0);
3683            let mut __for_first_104: bool = true;
3684            while { if !__for_first_104 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_104 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&fees).as_f64().unwrap_or(f64::NAN) } {
3685            let mut fee: Value = get_value(&fees, &i);
3686            let mut fee: Value = get_value(&fees, &i);
3687            let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3688            let mut feeCurrencyCode: Value = (if (code != Value::Null) { code.clone() } else { Value::Str(format!("{}", i).into()) });
3689            if (feeCurrencyCode != Value::Null) {
3690                let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3691                let mut cost: Value = self.safe_string_k(fee, "cost", &[]);
3692                if (cost == Value::Null) {
3693                    continue;
3694                }
3695                if !(matches!((&reduced, &feeCurrencyCode), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
3696                    if let Value::Dict(__d) = &mut reduced { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&feeCurrencyCode), Value::Map({
3697    let mut m = indexmap::IndexMap::new();
3698    m
3699})); }
3700                }
3701                let mut rateKey: Value = (if (rate == Value::Null) { Value::Str("".into()) } else { rate.clone() });
3702                if (in_op(&reduced.as_map().and_then(|__m| feeCurrencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &rateKey)) {
3703                    { 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); };
3704                }  else {
3705                    add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
3706    let mut m = indexmap::IndexMap::new();
3707        m.insert("currency".to_string(), code);
3708        m.insert("cost".to_string(), cost);
3709    m
3710}));
3711                    if (rate != Value::Null) {
3712                        add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".into()), rate);
3713                    }
3714                }
3715            }
3716        }
3717        }
3718        let mut result: Value = Value::from(vec![]);
3719        let mut feeValues: Value = Value::Array(reduced.as_map().map(|__m| __m.values().cloned().collect()).unwrap_or_default());
3720        {
3721                        let mut i: Value = Value::Int(0);
3722            let mut __for_first_105: bool = true;
3723            while { if !__for_first_105 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_105 = false; i.as_f64().unwrap_or(f64::NAN) < ((feeValues.len() as i64) as f64) } {
3724            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));
3725            result = self.array_concat(result.clone(), reducedFeeValues);
3726        }
3727        }
3728        return result;
3729
3730    Value::Null
3731}
3732
3733    fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3734        let mut market = get_arg(optional_args, 0, Value::Null);
3735        let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3736        let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".into()), Value::Str("last".into()), &[]));
3737        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
3738        let mut percentage: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "percentage", &[]));
3739        let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3740        let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3741        let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
3742        let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
3743        if (vwap == Value::Null) {
3744            vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
3745        }
3746        // calculate open
3747        if (change != Value::Null) {
3748            if (close == Value::Null) && (average != Value::Null) {
3749                close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".into())));
3750            }
3751            if (open == Value::Null) && (close != Value::Null) {
3752                open = crate::precise::Precise::stringSub(&close, &change);
3753            }
3754        }  else if (percentage != Value::Null) {
3755            if (close == Value::Null) && (average != Value::Null) {
3756                let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".into()));
3757                // openAddClose = open * (1 + (100 + percentage)/100)
3758                let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3759                let mut calcOpen: Value = (if (open != Value::Null) { open.clone() } else { crate::precise::Precise::stringDiv(&openAddClose, &denominator) });
3760                close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3761            }
3762            if (open == Value::Null) && (close != Value::Null) {
3763                open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3764            }
3765        }
3766        // change
3767        if (change == Value::Null) {
3768            if (close != Value::Null) && (open != Value::Null) {
3769                change = crate::precise::Precise::stringSub(&close, &open);
3770            }  else if (close != Value::Null) && (percentage != Value::Null) {
3771                change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".into())));
3772            }  else if (open != Value::Null) && (percentage != Value::Null) {
3773                change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3774            }
3775        }
3776        // calculate things according to "open" (similar can be done with "close")
3777        if (open != Value::Null) {
3778            // percentage (using change)
3779            if (percentage == Value::Null) && (change != Value::Null) {
3780                percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".into()));
3781            }
3782            // close (using change)
3783            if (close == Value::Null) && (change != Value::Null) {
3784                close = crate::precise::Precise::stringAdd(&open, &change);
3785            }
3786            // close (using average)
3787            if (close == Value::Null) && (average != Value::Null) {
3788                // average is the midpoint of open and close, so twice it is their sum
3789                close = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&average, &Value::Str("2".into())), &open);
3790            }
3791            // average
3792            if (average == Value::Null) && (close != Value::Null) {
3793                let mut precision: Value = Value::Int(18);
3794                if (market != Value::Null) && self.is_tick_precision().as_bool() == Some(true) {
3795                    let mut marketPrecision: Value = self.safe_dict_k(market, "precision", &[]);
3796                    let mut precisionPrice: Value = self.safe_string_k(marketPrecision, "price", &[]);
3797                    if (precisionPrice != Value::Null) {
3798                        precision = self.precision_from_string(precisionPrice);
3799                    }
3800                }
3801                average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".into()), &precision);
3802            }
3803        }
3804        // timestamp and symbol operations don't belong in safeTicker
3805        // they should be done in the derived classes
3806        let mut closeParsed: Value = self.parse_number(self.omit_zero(close), &[]);
3807        return self.extend(ticker.clone(), &[Value::Map({
3808    let mut m = indexmap::IndexMap::new();
3809        m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3810        m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3811        m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3812        m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3813        m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3814        m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3815        m.insert("open".to_string(), self.parse_number(self.omit_zero(open), &[]));
3816        m.insert("close".to_string(), closeParsed.clone());
3817        m.insert("last".to_string(), closeParsed);
3818        m.insert("change".to_string(), self.parse_number(change, &[]));
3819        m.insert("percentage".to_string(), self.parse_number(percentage, &[]));
3820        m.insert("average".to_string(), self.parse_number(average, &[]));
3821        m.insert("vwap".to_string(), self.parse_number(vwap, &[]));
3822        m.insert("baseVolume".to_string(), self.parse_number(baseVolume, &[]));
3823        m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume, &[]));
3824        m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3825        m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3826        m.insert("markPrice".to_string(), self.safe_number_k(ticker, "markPrice", &[]));
3827    m
3828})]);
3829
3830    Value::Null
3831}
3832
3833    fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3834        let mut params = get_arg(optional_args, 0, Value::Map({
3835    let mut m = indexmap::IndexMap::new();
3836    m
3837}));
3838        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".into()))));
3839
3840    Value::Null
3841} }
3842
3843    fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3844        // async-virtual: try the derived exchange first
3845        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 {
3846            if !matches!(__v, crate::Value::Null) { return __v; }
3847        }
3848
3849        let mut params = get_arg(optional_args, 0, Value::Map({
3850    let mut m = indexmap::IndexMap::new();
3851    m
3852}));
3853        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayCrossMargin is not support yet".into()))));
3854
3855    Value::Null
3856} }
3857
3858    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 {
3859        // async-virtual: try the derived exchange first
3860        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 {
3861            if !matches!(__v, crate::Value::Null) { return __v; }
3862        }
3863
3864        let mut params = get_arg(optional_args, 0, Value::Map({
3865    let mut m = indexmap::IndexMap::new();
3866    m
3867}));
3868        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayIsolatedMargin is not support yet".into()))));
3869
3870    Value::Null
3871} }
3872
3873    fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3874        // async-virtual: try the derived exchange first
3875        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 {
3876            if !matches!(__v, crate::Value::Null) { return __v; }
3877        }
3878
3879        let mut params = get_arg(optional_args, 0, Value::Map({
3880    let mut m = indexmap::IndexMap::new();
3881    m
3882}));
3883        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowCrossMargin is not support yet".into()))));
3884
3885    Value::Null
3886} }
3887
3888    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 {
3889        // async-virtual: try the derived exchange first
3890        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 {
3891            if !matches!(__v, crate::Value::Null) { return __v; }
3892        }
3893
3894        let mut params = get_arg(optional_args, 0, Value::Map({
3895    let mut m = indexmap::IndexMap::new();
3896    m
3897}));
3898        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowIsolatedMargin is not support yet".into()))));
3899
3900    Value::Null
3901} }
3902
3903    fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3904        let mut symbol = get_arg(optional_args, 0, Value::Null);
3905        let mut params = get_arg(optional_args, 1, Value::Map({
3906    let mut m = indexmap::IndexMap::new();
3907    m
3908}));
3909        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".into()))));
3910
3911    Value::Null
3912} }
3913
3914    fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3915        let mut symbol = get_arg(optional_args, 0, Value::Null);
3916        let mut params = get_arg(optional_args, 1, Value::Map({
3917    let mut m = indexmap::IndexMap::new();
3918    m
3919}));
3920        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".into()))));
3921
3922    Value::Null
3923} }
3924
3925    fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3926        // async-virtual: try the derived exchange first
3927        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 {
3928            if !matches!(__v, crate::Value::Null) { return __v; }
3929        }
3930
3931        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3932        let mut since = get_arg(optional_args, 1, Value::Null);
3933        let mut limit = get_arg(optional_args, 2, Value::Null);
3934        let mut params = get_arg(optional_args, 3, Value::Map({
3935    let mut m = indexmap::IndexMap::new();
3936    m
3937}));
3938        let mut message: Value = Value::Str("".into());
3939        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)) {
3940            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());
3941        }
3942        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() is not supported yet".into())).into()), message)));
3943
3944    Value::Null
3945} }
3946
3947    fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3948        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3949        let mut since = get_arg(optional_args, 1, Value::Null);
3950        let mut limit = get_arg(optional_args, 2, Value::Null);
3951        let mut params = get_arg(optional_args, 3, Value::Map({
3952    let mut m = indexmap::IndexMap::new();
3953    m
3954}));
3955        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotOHLCV() is not supported yet".into()))));
3956
3957    Value::Null
3958} }
3959
3960    fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3961        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3962        let mut since = get_arg(optional_args, 1, Value::Null);
3963        let mut limit = get_arg(optional_args, 2, Value::Null);
3964        let mut params = get_arg(optional_args, 3, Value::Map({
3965    let mut m = indexmap::IndexMap::new();
3966    m
3967}));
3968        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractOHLCV() is not supported yet".into()))));
3969
3970    Value::Null
3971} }
3972
3973    fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3974        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3975        let mut since = get_arg(optional_args, 1, Value::Null);
3976        let mut limit = get_arg(optional_args, 2, Value::Null);
3977        let mut params = get_arg(optional_args, 3, Value::Map({
3978    let mut m = indexmap::IndexMap::new();
3979    m
3980}));
3981        let mut message: Value = Value::Str("".into());
3982        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)) {
3983            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());
3984        }
3985        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)));
3986
3987    Value::Null
3988} }
3989
3990    fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3991        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3992        let mut since = get_arg(optional_args, 1, Value::Null);
3993        let mut limit = get_arg(optional_args, 2, Value::Null);
3994        let mut params = get_arg(optional_args, 3, Value::Map({
3995    let mut m = indexmap::IndexMap::new();
3996    m
3997}));
3998        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCV() is not supported yet".into()))));
3999
4000    Value::Null
4001} }
4002
4003    fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4004        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4005        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4006        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4007        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4008        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4009        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4010        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4011        let mut result: Vec<Value> = Vec::new();
4012        let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp, &[Value::from(vec![])]);
4013        let mut opens: Value = self.safe_list(ohlcvs.clone(), open, &[Value::from(vec![])]);
4014        let mut highs: Value = self.safe_list(ohlcvs.clone(), high, &[Value::from(vec![])]);
4015        let mut lows: Value = self.safe_list(ohlcvs.clone(), low, &[Value::from(vec![])]);
4016        let mut closes: Value = self.safe_list(ohlcvs.clone(), close, &[Value::from(vec![])]);
4017        let mut volumes: Value = self.safe_list(ohlcvs, volume, &[Value::from(vec![])]);
4018        {
4019                        let mut i: Value = Value::Int(0);
4020            let mut __for_first_106: bool = true;
4021            while { if !__for_first_106 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_106 = false; i.as_f64().unwrap_or(f64::NAN) < ((timestamps.len() as i64) as f64) } {
4022            result.push(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(), &[])]));
4023        }
4024        }
4025        return Value::from(result);
4026
4027    Value::Null
4028}
4029
4030    fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4031        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4032        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4033        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4034        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4035        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4036        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4037        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4038        let mut result: Value = Value::Map({
4039            let mut m = indexmap::IndexMap::new();
4040            m
4041        });
4042        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&timestamp), Value::from(vec![])); }
4043        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&open), Value::from(vec![])); }
4044        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&high), Value::from(vec![])); }
4045        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&low), Value::from(vec![])); }
4046        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&close), Value::from(vec![])); }
4047        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&volume), Value::from(vec![])); }
4048        {
4049                        let mut i: Value = Value::Int(0);
4050            let mut __for_first_107: bool = true;
4051            while { if !__for_first_107 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_107 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4052            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 })) });
4053            let mut resultTimestamp: Value = get_value(&result, &timestamp);
4054            append_to_array(&mut resultTimestamp, ts);
4055            crate::set_value(&mut result, &timestamp, resultTimestamp);
4056            let mut resultOpen: Value = get_value(&result, &open);
4057            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));
4058            crate::set_value(&mut result, &open, resultOpen);
4059            let mut resultHigh: Value = get_value(&result, &high);
4060            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));
4061            crate::set_value(&mut result, &high, resultHigh);
4062            let mut resultLow: Value = get_value(&result, &low);
4063            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));
4064            crate::set_value(&mut result, &low, resultLow);
4065            let mut resultClose: Value = get_value(&result, &close);
4066            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));
4067            crate::set_value(&mut result, &close, resultClose);
4068            let mut resultVolume: Value = get_value(&result, &volume);
4069            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));
4070            crate::set_value(&mut result, &volume, resultVolume);
4071        }
4072        }
4073        return result;
4074
4075    Value::Null
4076}
4077
4078    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 {
4079        let mut startRegex = get_arg(optional_args, 0, Value::Null);
4080        let mut endRegex = get_arg(optional_args, 1, Value::Null);
4081        let mut errorMessage: Value = Value::Str("".into());
4082        let mut options: Value = self.safe_value(self.options.clone(), method, &[Value::Map({
4083            let mut m = indexmap::IndexMap::new();
4084            m
4085        })]);
4086        let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4087        {
4088            // if it was not explicitly disabled, then don't fetch
4089            if !matches!(self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)]), Value::Bool(true)) {
4090                return Value::Null;
4091            }
4092            let mut maxRetries: Value = self.safe_integer_k(options, "webApiRetries", &[Value::Int(10)]);
4093            let mut response: Value = Value::Null;
4094            let mut retry: f64 = ((0i64) as f64);
4095            let mut shouldBreak: bool = false;
4096            while retry < maxRetries.as_f64().unwrap_or(f64::NAN) {
4097                {
4098                    response = self.call_dynamic_checked(endpointMethod.clone(), vec![(Value::Map({
4099                        let mut m = indexmap::IndexMap::new();
4100                        m
4101                    })).clone()]).await;
4102                    shouldBreak = true;
4103                    break;
4104                }
4105                if shouldBreak {
4106                    break;
4107                }
4108            }
4109            let mut content: Value = response;
4110            if (content == Value::Null) {
4111                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4112            }
4113            if (startRegex != Value::Null) {
4114                let mut splitted_by_start: Value = split(&content, &startRegex);
4115                content = get_value(&splitted_by_start, &Value::Int(1)); // we need second part after start
4116            }
4117            if (content == Value::Null) {
4118                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4119            }
4120            if (endRegex != Value::Null) {
4121                let mut splitted_by_end: Value = split(&content, &endRegex);
4122                content = get_value(&splitted_by_end, &Value::Int(0)); // we need first part after start
4123            }
4124            if ((match &(returnAsJson) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) })) && (matches!(&content, Value::Str(_))) {
4125                let mut jsoned: Value = self.parse_json_value(content.as_str().map(|__s| Value::Str(__s.trim().to_string().into())).unwrap_or(Value::Null)); // content should be trimmed before json parsing
4126                if (jsoned != Value::Null) && (jsoned != Value::Null) {
4127                    return jsoned;
4128                }  else {
4129                    panic!("{}", crate::exchange_errors::bad_response("could not parse the response into json"));
4130                }
4131            }  else {
4132                return content;
4133            }
4134        }
4135        if muteOnFailure.as_bool() == Some(true) {
4136            return Value::Null;
4137        }  else {
4138            panic!("{}", crate::exchange_errors::bad_response(errorMessage));
4139        }
4140} }
4141
4142    fn market_ids(&self, optional_args: &[Value]) -> Value {
4143        let mut symbols = get_arg(optional_args, 0, Value::Null);
4144        /*
4145         * @param {string[]|undefined} symbols list of unified symbols
4146         * @returns {string[]|undefined} list of exchange-specific market ids
4147         * Overloads: non-null `string[]` input yields `string[]`; optional input yields `Strings`.
4148         */
4149        if (symbols == Value::Null) {
4150            return symbols;
4151        }
4152        let mut result: Vec<Value> = Vec::new();
4153        {
4154                        let mut i: Value = Value::Int(0);
4155            let mut __for_first_108: bool = true;
4156            while { if !__for_first_108 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_108 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4157            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));
4158            if (id != Value::Null) {
4159                result.push(id);
4160            }
4161        }
4162        }
4163        return Value::from(result);
4164
4165    Value::Null
4166}
4167
4168    fn currency_ids(&self, optional_args: &[Value]) -> Value {
4169        let mut codes = get_arg(optional_args, 0, Value::Null);
4170        if (codes == Value::Null) {
4171            return codes;
4172        }
4173        let mut result: Vec<Value> = Vec::new();
4174        {
4175                        let mut i: Value = Value::Int(0);
4176            let mut __for_first_109: bool = true;
4177            while { if !__for_first_109 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_109 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
4178            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));
4179            if (id != Value::Null) {
4180                result.push(id);
4181            }
4182        }
4183        }
4184        return Value::from(result);
4185
4186    Value::Null
4187}
4188
4189    fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4190        let mut symbols = get_arg(optional_args, 0, Value::Null);
4191        if (symbols == Value::Null) {
4192            return Value::Null;
4193        }
4194        let mut result: Vec<Value> = Vec::new();
4195        {
4196                        let mut i: Value = Value::Int(0);
4197            let mut __for_first_110: bool = true;
4198            while { if !__for_first_110 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_110 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4199            result.push(<Self as crate::exchange_generated::ExchangeBase>::market(self, 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)));
4200        }
4201        }
4202        return Value::from(result);
4203
4204    Value::Null
4205}
4206
4207// allowEmpty: false always returns string[] (throws on empty/undefined at runtime)
4208    fn market_symbols(&self, optional_args: &[Value]) -> Value {
4209        let mut symbols = get_arg(optional_args, 0, Value::Null);
4210        let mut type_var = get_arg(optional_args, 1, Value::Null);
4211        let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4212        let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4213        let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4214        /*
4215         * @param {string[]|undefined} symbols list of unified symbols
4216         * @param {string|undefined} type filter by market type
4217         * @param {boolean} allowEmpty whether empty/undefined symbols is allowed
4218         * @param {boolean} sameTypeOnly require all markets to share type
4219         * @param {boolean} sameSubTypeOnly require all markets to share linear/inverse subType
4220         * @returns {string[]|undefined} validated unified symbols
4221         * Overloads: `allowEmpty: false` or non-null `string[]` input yields `string[]`; permissive form yields `Strings`.
4222         */
4223        if (symbols == Value::Null) {
4224            if !(allowEmpty.as_bool() == Some(true)) {
4225                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4226            }
4227            return symbols;
4228        }
4229        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
4230        if (symbolsLength == 0.0) {
4231            if !(allowEmpty.as_bool() == Some(true)) {
4232                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4233            }
4234            return symbols;
4235        }
4236        let mut result: Vec<Value> = Vec::new();
4237        let mut marketType: Value = Value::Null;
4238        let mut isLinearSubType: Value = Value::Null;
4239        {
4240                        let mut i: Value = Value::Int(0);
4241            let mut __for_first_111: bool = true;
4242            while { if !__for_first_111 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_111 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4243            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, 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));
4244            if sameTypeOnly.as_bool() == Some(true) && (marketType != Value::Null) {
4245                if (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != marketType.as_str()) {
4246                    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()))));
4247                }
4248            }
4249            if sameSubTypeOnly.as_bool() == Some(true) && (isLinearSubType != Value::Null) {
4250                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() != isLinearSubType.as_bool()) {
4251                    panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same subType, either linear or inverse.".into()))));
4252                }
4253            }
4254            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()) {
4255                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()))));
4256            }
4257            marketType = self.safe_string_k(market.clone(), "type", &[]);
4258            if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
4259                isLinearSubType = self.safe_bool_k(market.clone(), "linear", &[]);
4260            }
4261            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)]);
4262            result.push(symbol);
4263        }
4264        }
4265        return Value::from(result);
4266
4267    Value::Null
4268}
4269
4270    fn market_codes(&self, optional_args: &[Value]) -> Value {
4271        let mut codes = get_arg(optional_args, 0, Value::Null);
4272        if (codes == Value::Null) {
4273            return codes;
4274        }
4275        let mut result: Vec<Value> = Vec::new();
4276        {
4277                        let mut i: Value = Value::Int(0);
4278            let mut __for_first_112: bool = true;
4279            while { if !__for_first_112 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_112 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
4280            result.push(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)));
4281        }
4282        }
4283        return Value::from(result);
4284
4285    Value::Null
4286}
4287
4288    fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4289        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4290        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4291        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4292        let mut bidasksValue: Value = self.to_array(bidasks);
4293        let mut result: Vec<Value> = Vec::new();
4294        {
4295                        let mut i: Value = Value::Int(0);
4296            let mut __for_first_113: bool = true;
4297            while { if !__for_first_113 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_113 = false; i.as_f64().unwrap_or(f64::NAN) < ((bidasksValue.len() as i64) as f64) } {
4298            result.push(self.parse_order_book_bid_ask(get_value(&bidasksValue, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4299        }
4300        }
4301        return Value::from(result);
4302
4303    Value::Null
4304}
4305
4306    fn parse_order_book_bids_asks_l3(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4307        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4308        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4309        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4310        let mut bidasksValue: Value = self.to_array(bidasks);
4311        let mut result: Vec<Value> = Vec::new();
4312        {
4313                        let mut i: Value = Value::Int(0);
4314            let mut __for_first_114: bool = true;
4315            while { if !__for_first_114 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_114 = false; i.as_f64().unwrap_or(f64::NAN) < ((bidasksValue.len() as i64) as f64) } {
4316            result.push(self.parse_order_book_bid_ask_l3(get_value(&bidasksValue, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4317        }
4318        }
4319        return Value::from(result);
4320
4321    Value::Null
4322}
4323
4324    fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4325        let mut value = get_arg(optional_args, 0, Value::Null);
4326        if (value == Value::Null) {
4327            return objects;
4328        }
4329        let mut result: Vec<Value> = Vec::new();
4330        {
4331                        let mut i: Value = Value::Int(0);
4332            let mut __for_first_115: bool = true;
4333            while { if !__for_first_115 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_115 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objects).as_f64().unwrap_or(f64::NAN) } {
4334            let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
4335            if (objectValue.as_str() == value.as_str()) {
4336                result.push(get_value(&objects, &i));
4337            }
4338        }
4339        }
4340        return Value::from(result);
4341
4342    Value::Null
4343}
4344
4345    fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4346        let mut symbol = get_arg(optional_args, 0, Value::Null);
4347        return self.filter_by_key(objects, Value::Str("symbol".into()), &[symbol]);
4348
4349    Value::Null
4350}
4351
4352    fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4353        // virtual-dispatch (static: DerivedExchange::parse_ohlcv(self, ...))
4354        { 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; } }
4355
4356        let mut market = get_arg(optional_args, 0, Value::Null);
4357        if (matches!(&ohlcv, Value::Arr(_))) {
4358            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), &[])]);
4359        }
4360        return ohlcv;
4361
4362    Value::Null
4363}
4364
4365    fn safe_network(&self, mut network: Value) -> Value {
4366        let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
4367        let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
4368        let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
4369        let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4370        let mut deposit: Value = self.safe_dict_k(limits, "deposit", &[]);
4371        let mut isEnabled: Value = withdrawEnabled.clone();
4372        if (withdrawEnabled.as_bool() == Some(true)) {
4373            isEnabled = depositEnabled.clone();
4374        }
4375        return Value::Map({
4376    let mut m = indexmap::IndexMap::new();
4377        m.insert("info".to_string(), crate::value::get_value_k(&network, "info"));
4378        m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
4379        m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
4380        m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
4381        m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled]));
4382        m.insert("deposit".to_string(), depositEnabled);
4383        m.insert("withdraw".to_string(), withdrawEnabled);
4384        m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
4385        m.insert("precision".to_string(), self.safe_number_k(network, "precision", &[]));
4386        m.insert("limits".to_string(), Value::Map({
4387    let mut m = indexmap::IndexMap::new();
4388        m.insert("withdraw".to_string(), Value::Map({
4389    let mut m = indexmap::IndexMap::new();
4390        m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4391        m.insert("max".to_string(), self.safe_number_k(withdraw, "max", &[]));
4392    m
4393}));
4394        m.insert("deposit".to_string(), Value::Map({
4395    let mut m = indexmap::IndexMap::new();
4396        m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4397        m.insert("max".to_string(), self.safe_number_k(deposit, "max", &[]));
4398    m
4399}));
4400    m
4401}));
4402    m
4403});
4404
4405    Value::Null
4406}
4407
4408    fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4409        let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4410        /*
4411         * @ignore
4412         * @method
4413         * @name exchange#networkCodeToId
4414         * @description tries to convert the provided networkCode (a unified network code or one of its aliases) to a network id. In order to achieve this, derived class needs to have 'options->networks' defined.
4415         * @param {string} networkCode unified network code
4416         * @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
4417         * @returns {string|undefined} exchange-specific network id
4418         */
4419        if (networkCode == Value::Null) {
4420            return Value::Null;
4421        }
4422        let mut unifiedCode: Value = self.safe_string(self.networkAliases.clone(), networkCode.clone(), &[networkCode.clone()]);
4423        let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4424    let mut m = indexmap::IndexMap::new();
4425    m
4426})]);
4427        let mut networkId: Value = self.safe_string(networkIdsByCodes.clone(), unifiedCode.clone(), &[]);
4428        if (networkId != Value::Null) {
4429            return networkId;
4430        }
4431        // options.networks may still be keyed by an alias of the unified code
4432        let mut aliases: Value = self.networkAliases.clone();
4433        let mut aliasKeys: Value = object_keys(&aliases);
4434        {
4435                        let mut i: Value = Value::Int(0);
4436            let mut __for_first_116: bool = true;
4437            while { if !__for_first_116 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_116 = false; i.as_f64().unwrap_or(f64::NAN) < ((aliasKeys.len() as i64) as f64) } {
4438            let mut alias: Value = aliasKeys.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);
4439            if (aliases.as_map().and_then(|__m| alias.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null).as_str() == unifiedCode.as_str()) && (matches!((&networkIdsByCodes, &alias), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
4440                return networkIdsByCodes.as_map().and_then(|__m| alias.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4441            }
4442        }
4443        }
4444        // fall back to scanning loaded currencies
4445        let mut currenciesToCheck: Value = Value::from(vec![]);
4446        if (currencyCode == Value::Null) {
4447            currenciesToCheck = Value::Array(self.currencies.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
4448        }  else {
4449            currenciesToCheck = Value::from(vec![self.safe_dict(self.currencies.clone(), currencyCode, &[])]);
4450        }
4451        {
4452                        let mut i: Value = Value::Int(0);
4453            let mut __for_first_117: bool = true;
4454            while { if !__for_first_117 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_117 = false; i.as_f64().unwrap_or(f64::NAN) < ((currenciesToCheck.len() as i64) as f64) } {
4455            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({
4456    let mut m = indexmap::IndexMap::new();
4457    m
4458})]);
4459            if (matches!((&networks, &unifiedCode), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
4460                return self.safe_string(networks.as_map().and_then(|__m| unifiedCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("id".into()), &[]);
4461            }
4462        }
4463        }
4464        return networkCode;
4465
4466    Value::Null
4467}
4468
4469    fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4470        let mut networkId = get_arg(optional_args, 0, Value::Null);
4471        let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4472        /*
4473         * @ignore
4474         * @method
4475         * @name exchange#networkIdToCode
4476         * @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.
4477         * @param {string} networkId exchange specific network id/title, like: TRON, Trc-20, usdt-erc20, etc
4478         * @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
4479         * @returns {string|undefined} unified network code
4480         */
4481        if (networkId == Value::Null) {
4482            return Value::Null;
4483        }
4484        let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4485    let mut m = indexmap::IndexMap::new();
4486    m
4487})]);
4488        let mut mappedCode: Value = self.safe_string(networkCodesByIds, networkId.clone(), &[]);
4489        let mut networkCode: Value = (if (mappedCode == Value::Null) { networkId } else { mappedCode });
4490        return self.safe_string(self.networkAliases.clone(), networkCode.clone(), &[networkCode.clone()]);
4491
4492    Value::Null
4493}
4494
4495    fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4496        let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".into()), Value::Str("network".into()), &[]);
4497        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 });
4498        return Value::from(vec![networkCodeInParams, paramsOmitted]);
4499
4500    Value::Null
4501}
4502
4503    fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4504        let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4505        // this method is used against raw & unparse network entries, which are just indexed by network id
4506        let mut chosenNetworkId: Value = Value::Null;
4507        let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4508        let mut responseNetworksLength: f64 = ((availableNetworkIds.len() as i64) as f64);
4509        if (networkCode != Value::Null) {
4510            if (responseNetworksLength == 0.0) {
4511                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)));
4512            }  else {
4513                // if networkCode was provided by user, we should check it after response, as the referenced exchange doesn't support network-code during request
4514                let mut networkIdOrCode: Value = (if isIndexedByUnifiedNetworkCode.as_bool() == Some(true) { networkCode.clone() } else { self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]) });
4515                if (networkIdOrCode == Value::Null) {
4516                    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)));
4517                }
4518                if (in_op(&indexedNetworkEntries, &networkIdOrCode)) {
4519                    chosenNetworkId = networkIdOrCode.clone();
4520                }  else {
4521                    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()), Value::Str(availableNetworkIds.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(", ")).unwrap_or_default().into()))));
4522                }
4523            }
4524        }  else {
4525            if (responseNetworksLength == 0.0) {
4526                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - no networks were returned for ".into())).into()), currencyCode)));
4527            }  else {
4528                // 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
4529                let mut defaultNetworkCode: Value = self.safe_string(self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4530    let mut m = indexmap::IndexMap::new();
4531    m
4532})]), currencyCode.clone(), &[self.safe_string_k(self.options.clone(), "defaultNetwork", &[])]);
4533                let mut defaultNetworkId: Value = (if isIndexedByUnifiedNetworkCode.as_bool() == Some(true) { defaultNetworkCode.clone() } else { self.network_code_to_id(defaultNetworkCode, &[currencyCode]) });
4534                if (defaultNetworkId == Value::Null) {
4535                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".into()))));
4536                }
4537                if (in_op(&indexedNetworkEntries, &defaultNetworkId)) {
4538                    return defaultNetworkId;
4539                }
4540                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()), Value::Str(availableNetworkIds.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(", ")).unwrap_or_default().into()))));
4541            }
4542        }
4543        return chosenNetworkId;
4544
4545    Value::Null
4546}
4547
4548    fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4549        let mut d = get_arg(optional_args, 0, Value::Null);
4550        let mut value: Value = self.safe_string2(dictionary, key1, key2, &[]);
4551        return self.parse_number(value, &[d]);
4552
4553    Value::Null
4554}
4555
4556    fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4557        // virtual-dispatch (static: DerivedExchange::parse_order_book(self, ...))
4558        { 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; } }
4559
4560        let mut timestamp = get_arg(optional_args, 0, Value::Null);
4561        let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4562        let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4563        let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4564        let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4565        let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4566        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()]);
4567        let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4568        return Value::Map({
4569    let mut m = indexmap::IndexMap::new();
4570        m.insert("symbol".to_string(), symbol);
4571        m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4572        m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4573        m.insert("timestamp".to_string(), timestamp.clone());
4574        m.insert("datetime".to_string(), self.iso8601(timestamp));
4575        m.insert("nonce".to_string(), Value::Null);
4576    m
4577});
4578
4579    Value::Null
4580}
4581
4582    fn parse_order_book_l3(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4583        let mut timestamp = get_arg(optional_args, 0, Value::Null);
4584        let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4585        let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4586        let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4587        let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4588        let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4589        let mut bids: Value = self.parse_order_book_bids_asks_l3(self.safe_value(orderbook.clone(), bidsKey, &[Value::from(vec![])]), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
4590        let mut asks: Value = self.parse_order_book_bids_asks_l3(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4591        return Value::Map({
4592    let mut m = indexmap::IndexMap::new();
4593        m.insert("symbol".to_string(), symbol);
4594        m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4595        m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4596        m.insert("timestamp".to_string(), timestamp.clone());
4597        m.insert("datetime".to_string(), self.iso8601(timestamp));
4598        m.insert("nonce".to_string(), Value::Null);
4599    m
4600});
4601
4602    Value::Null
4603}
4604
4605    fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4606        let mut market = get_arg(optional_args, 0, Value::Null);
4607        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
4608        let mut since = get_arg(optional_args, 2, Value::Null);
4609        let mut limit = get_arg(optional_args, 3, Value::Null);
4610        let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4611        if (ohlcvs == Value::Null) {
4612            return Value::from(vec![]);
4613        }
4614        let mut results: Vec<Value> = Vec::new();
4615        {
4616                        let mut i: Value = Value::Int(0);
4617            let mut __for_first_118: bool = true;
4618            while { if !__for_first_118 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_118 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4619            results.push(<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()]));
4620        }
4621        }
4622        let mut sorted: Value = self.sort_by(Value::from(results), Value::Int(0), &[]);
4623        return self.filter_by_since_limit(sorted, &[since, limit, Value::Int(0), tail]);
4624
4625    Value::Null
4626}
4627
4628    fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4629        let mut symbols = get_arg(optional_args, 0, Value::Null);
4630        let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4631        // marketIdKey should only be undefined when response is a dictionary.
4632        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4633        let mut tiers: Value = Value::Map({
4634            let mut m = indexmap::IndexMap::new();
4635            m
4636        });
4637        let mut symbolsLength: Value = Value::Int(0);
4638        if (symbolsNormalized != Value::Null) {
4639            symbolsLength = Value::Int(symbolsNormalized.len() as i64);
4640        }
4641        let mut noSymbols: bool = (symbolsNormalized == Value::Null) || (symbolsLength.as_f64() == Some(0.0));
4642        if (matches!(&response, Value::Arr(_))) {
4643            {
4644                                let mut i: Value = Value::Int(0);
4645                let mut __for_first_119: bool = true;
4646                while { if !__for_first_119 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_119 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
4647                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);
4648                let mut id: Value = (if (marketIdKey == Value::Null) { Value::Null } else { self.safe_string(item.clone(), marketIdKey.clone(), &[]) });
4649                let mut market: Value = self.safe_market(&[id, Value::Null, Value::Null, Value::Str("swap".into())]);
4650                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4651                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4652                if contract.as_bool() == Some(true) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4653                    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()])); }
4654                }
4655            }
4656            }
4657        }  else {
4658            let mut keys: Value = object_keys(&response);
4659            {
4660                                let mut i: Value = Value::Int(0);
4661                let mut __for_first_120: bool = true;
4662                while { if !__for_first_120 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_120 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
4663                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);
4664                let mut item: Value = get_value(&response, &marketId);
4665                let mut item: Value = get_value(&response, &marketId);
4666                let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("swap".into())]);
4667                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4668                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4669                if contract.as_bool() == Some(true) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4670                    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])); }
4671                }
4672            }
4673            }
4674        }
4675        return tiers;
4676
4677    Value::Null
4678}
4679
4680    fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4681        let mut symbols = get_arg(optional_args, 0, Value::Null);
4682        let mut reload = get_arg(optional_args, 1, Value::Bool(false));
4683        let mut params = get_arg(optional_args, 2, Value::Map({
4684    let mut m = indexmap::IndexMap::new();
4685    m
4686}));
4687        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)) {
4688            if reload.as_bool() == Some(true) || !(matches!(&self.options, Value::Dict(__d) if __d.contains_key("limitsLoaded"))) {
4689                let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4690                let mut symbolsArray: Value = self.require_value(symbols, &[Value::Str("loadTradingLimits() requires a symbols argument".into())]);
4691                let mut markets: Value = self.markets.clone();
4692                if (markets == Value::Null) {
4693                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
4694                }
4695                {
4696                                        let mut i: Value = Value::Int(0);
4697                    let mut __for_first_121: bool = true;
4698                    while { if !__for_first_121 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_121 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&symbolsArray).as_f64().unwrap_or(f64::NAN) } {
4699                    let mut symbol: Value = get_value(&symbolsArray, &i);
4700                    let mut symbol: Value = get_value(&symbolsArray, &i);
4701                    { let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
4702                }
4703                }
4704                { let __be_tmp = self.milliseconds(); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("limitsLoaded".into(), __be_tmp); } }
4705            }
4706        }
4707        return self.markets.clone();
4708
4709    Value::Null
4710} }
4711
4712    fn safe_position(&self, mut position: Value) -> Value {
4713        // simplified version of: /pull/12765/
4714        // if contractSize is undefined get from market
4715        let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
4716        let mut symbol: Value = self.safe_string_k(position.clone(), "symbol", &[]);
4717        let mut market: Value = Value::Null;
4718        if (symbol != Value::Null) {
4719            market = self.safe_value(self.markets.clone(), symbol, &[]);
4720        }
4721        if (contractSize == Value::Null) && (market != Value::Null) {
4722            contractSize = self.safe_number_k(market.clone(), "contractSize", &[]);
4723            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), contractSize); }
4724        }
4725        let mut isInverse: bool = (market != Value::Null) && self.safe_bool_k(market, "inverse", &[Value::Bool(false)]).as_bool() == Some(true);
4726        let mut side: Option<String> = self.safe_string_k(position.clone(), "side", &[]).as_str().map(str::to_owned);
4727        let mut marginMode: Option<String> = self.safe_string_k(position.clone(), "marginMode", &[]).as_str().map(str::to_owned);
4728        let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
4729        let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
4730        let mut maintenanceMarginString: Value = self.safe_string_k(position.clone(), "maintenanceMargin", &[]);
4731        let mut collateralString: Value = self.safe_string_k(position.clone(), "collateral", &[]);
4732        let mut entryPriceString: Value = self.safe_string_k(position.clone(), "entryPrice", &[]);
4733        let mut liquidationPriceString: Value = self.safe_string_k(position.clone(), "liquidationPrice", &[]);
4734        let mut contractsString: Value = self.safe_string_k(position.clone(), "contracts", &[]);
4735        let mut contractSizeString: Value = self.safe_string_k(position.clone(), "contractSize", &[]);
4736        // margin is the amount held in the position (excludes unrealized pnl), collateral = margin + unrealizedPnl
4737        let mut marginString: Value = self.safe_string_k(position.clone(), "positionMargin", &[]);
4738        if (marginString == Value::Null) && (marginMode.as_deref() == Some("isolated")) && (collateralString != Value::Null) {
4739            let mut derivedMargin: Value = collateralString.clone();
4740            if (unrealizedPnlString != Value::Null) && !(crate::precise::Precise::stringEq(&collateralString, &initialMarginString).as_bool() == Some(true)) {
4741                derivedMargin = crate::precise::Precise::stringSub(&collateralString, &unrealizedPnlString);
4742            }
4743            if crate::precise::Precise::stringGt(&derivedMargin, &Value::Str("0".into())).as_bool() == Some(true) {
4744                marginString = derivedMargin.clone();
4745                if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), self.parse_number(derivedMargin, &[])); }
4746            }
4747        }
4748        if (marginString == Value::Null) {
4749            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), Value::Null); }; // keep the unified key present across all exchanges
4750        }
4751        if (collateralString == Value::Null) && (marginString != Value::Null) && (unrealizedPnlString != Value::Null) {
4752            collateralString = crate::precise::Precise::stringAdd(&marginString, &unrealizedPnlString);
4753            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("collateral".into(), self.parse_number(collateralString.clone(), &[])); }
4754        }
4755        if (marginMode.as_deref() == Some("isolated")) {
4756            let mut entryMarginString: Value = marginString.clone();
4757            if (entryMarginString == Value::Null) && (collateralString == Value::Null) {
4758                entryMarginString = initialMarginString.clone();
4759            }
4760            let mut hasEntryMargin: bool = (entryMarginString != Value::Null) && crate::precise::Precise::stringGt(&entryMarginString, &Value::Str("0".into())).as_bool() == Some(true);
4761            let mut hasEntryPrice: bool = (entryPriceString != Value::Null) && crate::precise::Precise::stringGt(&entryPriceString, &Value::Str("0".into())).as_bool() == Some(true);
4762            let mut hasLiqPrice: bool = (liquidationPriceString != Value::Null) && crate::precise::Precise::stringGt(&liquidationPriceString, &Value::Str("0".into())).as_bool() == Some(true);
4763            let mut hasContracts: bool = (contractsString != Value::Null) && crate::precise::Precise::stringGt(&contractsString, &Value::Str("0".into())).as_bool() == Some(true);
4764            let mut hasContractSize: bool = (contractSizeString != Value::Null) && crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into())).as_bool() == Some(true);
4765            let mut hasMm: bool = (maintenanceMarginString != Value::Null) && crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into())).as_bool() == Some(true);
4766            let mut priceDiff: Value = Value::Null;
4767            if hasEntryPrice && hasLiqPrice {
4768                if isInverse {
4769                    let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4770                    let mut invLiq: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &liquidationPriceString);
4771                    if (side.as_deref() == Some("long")) {
4772                        priceDiff = crate::precise::Precise::stringSub(&invLiq, &invEntry);
4773                    }  else if (side.as_deref() == Some("short")) {
4774                        priceDiff = crate::precise::Precise::stringSub(&invEntry, &invLiq);
4775                    }  else {
4776                        priceDiff = crate::precise::Precise::stringAbs(&crate::precise::Precise::stringSub(&invEntry, &invLiq));
4777                    }
4778                }  else {
4779                    if (side.as_deref() == Some("long")) {
4780                        priceDiff = crate::precise::Precise::stringSub(&entryPriceString, &liquidationPriceString);
4781                    }  else if (side.as_deref() == Some("short")) {
4782                        priceDiff = crate::precise::Precise::stringSub(&liquidationPriceString, &entryPriceString);
4783                    }  else {
4784                        priceDiff = crate::precise::Precise::stringAbs(&crate::precise::Precise::stringSub(&entryPriceString, &liquidationPriceString));
4785                    }
4786                }
4787            }
4788            let mut hasPriceDiff: bool = (priceDiff != Value::Null) && crate::precise::Precise::stringGt(&priceDiff, &Value::Str("0".into())).as_bool() == Some(true);
4789            if (maintenanceMarginString == Value::Null) && hasEntryMargin && hasPriceDiff && hasContracts && hasContractSize {
4790                let mut lossFromEntry: Value = crate::precise::Precise::stringMul(&priceDiff, &crate::precise::Precise::stringMul(&contractsString, &contractSizeString));
4791                let mut derivedMm: Value = crate::precise::Precise::stringSub(&entryMarginString, &lossFromEntry);
4792                if crate::precise::Precise::stringGt(&derivedMm, &Value::Str("0".into())).as_bool() == Some(true) {
4793                    maintenanceMarginString = derivedMm.clone();
4794                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMargin".into(), self.parse_number(derivedMm.clone(), &[])); }
4795                }
4796            }  else if (collateralString == Value::Null) && (initialMarginString == Value::Null) && hasMm && hasPriceDiff && hasContracts && hasContractSize {
4797                let mut lossFromEntry: Value = crate::precise::Precise::stringMul(&priceDiff, &crate::precise::Precise::stringMul(&contractsString, &contractSizeString));
4798                let mut derivedEntryMargin: Value = crate::precise::Precise::stringAdd(&maintenanceMarginString, &lossFromEntry);
4799                if crate::precise::Precise::stringGt(&derivedEntryMargin, &Value::Str("0".into())).as_bool() == Some(true) {
4800                    initialMarginString = derivedEntryMargin.clone();
4801                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMargin".into(), self.parse_number(derivedEntryMargin.clone(), &[])); }
4802                    marginString = derivedEntryMargin.clone();
4803                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), self.parse_number(derivedEntryMargin.clone(), &[])); }
4804                    let mut derivedCollateral: Value = derivedEntryMargin.clone();
4805                    if (unrealizedPnlString != Value::Null) {
4806                        derivedCollateral = crate::precise::Precise::stringAdd(&derivedEntryMargin, &unrealizedPnlString);
4807                    }
4808                    if crate::precise::Precise::stringGt(&derivedCollateral, &Value::Str("0".into())).as_bool() == Some(true) {
4809                        collateralString = derivedCollateral.clone();
4810                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("collateral".into(), self.parse_number(derivedCollateral, &[])); }
4811                    }
4812                }
4813            }  else if (liquidationPriceString == Value::Null) && hasEntryMargin && hasMm && hasEntryPrice && hasContracts && hasContractSize && ((side.as_deref() == Some("long")) || (side.as_deref() == Some("short"))) {
4814                let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4815                let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4816                if crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&totalSize, &Value::Str("0".into())).as_bool() == Some(true) {
4817                    let mut bufferPerUnit: Value = crate::precise::Precise::stringDiv(&marginBuffer, &totalSize);
4818                    let mut derivedLp: Value = crate::precise::Precise::stringAdd(&entryPriceString, &bufferPerUnit);
4819                    if (side.as_deref() == Some("long")) {
4820                        derivedLp = crate::precise::Precise::stringSub(&entryPriceString, &bufferPerUnit);
4821                    }
4822                    if isInverse {
4823                        let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4824                        let mut invDerivedLp: Value = crate::precise::Precise::stringSub(&invEntry, &bufferPerUnit);
4825                        if (side.as_deref() == Some("long")) {
4826                            invDerivedLp = crate::precise::Precise::stringAdd(&invEntry, &bufferPerUnit);
4827                        }
4828                        // 1 / invDerivedLp keeps its sign (undefined at 0), so the > 0 guard below
4829                        // rejects exactly the values a separate invDerivedLp > 0 check would
4830                        derivedLp = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &invDerivedLp);
4831                    }
4832                    if (derivedLp != Value::Null) && crate::precise::Precise::stringGt(&derivedLp, &Value::Str("0".into())).as_bool() == Some(true) {
4833                        liquidationPriceString = derivedLp.clone();
4834                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("liquidationPrice".into(), self.parse_number(derivedLp, &[])); }
4835                    }
4836                }
4837            }  else if (entryPriceString == Value::Null) && hasEntryMargin && hasMm && hasLiqPrice && hasContracts && hasContractSize && ((side.as_deref() == Some("long")) || (side.as_deref() == Some("short"))) {
4838                let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4839                let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4840                if crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&totalSize, &Value::Str("0".into())).as_bool() == Some(true) {
4841                    let mut bufferPerUnit: Value = crate::precise::Precise::stringDiv(&marginBuffer, &totalSize);
4842                    let mut derivedEp: Value = crate::precise::Precise::stringSub(&liquidationPriceString, &bufferPerUnit);
4843                    if (side.as_deref() == Some("long")) {
4844                        derivedEp = crate::precise::Precise::stringAdd(&liquidationPriceString, &bufferPerUnit);
4845                    }
4846                    if isInverse {
4847                        let mut invLp: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &liquidationPriceString);
4848                        let mut invEp: Value = crate::precise::Precise::stringAdd(&invLp, &bufferPerUnit);
4849                        if (side.as_deref() == Some("long")) {
4850                            invEp = crate::precise::Precise::stringSub(&invLp, &bufferPerUnit);
4851                        }
4852                        // 1 / invEp keeps its sign (undefined at 0), so the > 0 guard below
4853                        // rejects exactly the values a separate invEp > 0 check would
4854                        derivedEp = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &invEp);
4855                    }
4856                    if (derivedEp != Value::Null) && crate::precise::Precise::stringGt(&derivedEp, &Value::Str("0".into())).as_bool() == Some(true) {
4857                        entryPriceString = derivedEp.clone();
4858                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("entryPrice".into(), self.parse_number(derivedEp, &[])); }
4859                    }
4860                }
4861            }  else if (contractsString == Value::Null) && hasEntryMargin && hasMm && hasPriceDiff && hasContractSize {
4862                let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4863                let mut denom: Value = crate::precise::Precise::stringMul(&priceDiff, &contractSizeString);
4864                if crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&denom, &Value::Str("0".into())).as_bool() == Some(true) {
4865                    let mut derivedContracts: Value = crate::precise::Precise::stringDiv(&marginBuffer, &denom);
4866                    if crate::precise::Precise::stringGt(&derivedContracts, &Value::Str("0".into())).as_bool() == Some(true) {
4867                        contractsString = derivedContracts.clone();
4868                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(derivedContracts, &[])); }
4869                    }
4870                }
4871            }  else if (contractSizeString == Value::Null) && hasEntryMargin && hasMm && hasPriceDiff && hasContracts {
4872                let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4873                let mut denom: Value = crate::precise::Precise::stringMul(&priceDiff, &contractsString);
4874                if crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&denom, &Value::Str("0".into())).as_bool() == Some(true) {
4875                    let mut derivedContractSize: Value = crate::precise::Precise::stringDiv(&marginBuffer, &denom);
4876                    if crate::precise::Precise::stringGt(&derivedContractSize, &Value::Str("0".into())).as_bool() == Some(true) {
4877                        contractSizeString = derivedContractSize.clone();
4878                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(derivedContractSize, &[])); }
4879                    }
4880                }
4881            }
4882        }
4883        //
4884        // POSITION-LOCAL DERIVATIONS (CROSS & ISOLATED)
4885        //
4886        let mut isZeroPosition: bool = (contractsString != Value::Null) && crate::precise::Precise::stringEq(&contractsString, &Value::Str("0".into())).as_bool() == Some(true);
4887        if !isZeroPosition {
4888            let mut notionalString: Value = self.safe_string_k(position.clone(), "notional", &[]);
4889            let mut markPriceString: Value = self.safe_string_k(position.clone(), "markPrice", &[]);
4890            let mut lastPriceString: Option<String> = self.safe_string_k(position.clone(), "lastPrice", &[]).as_str().map(str::to_owned);
4891            let mut hasContracts: bool = (contractsString != Value::Null) && crate::precise::Precise::stringGt(&contractsString, &Value::Str("0".into())).as_bool() == Some(true);
4892            let mut hasContractSize: bool = (contractSizeString != Value::Null) && crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into())).as_bool() == Some(true);
4893            let mut hasMarkPrice: bool = (markPriceString != Value::Null) && crate::precise::Precise::stringGt(&markPriceString, &Value::Str("0".into())).as_bool() == Some(true);
4894            let mut hasNotional: bool = (notionalString != Value::Null) && crate::precise::Precise::stringGt(&notionalString, &Value::Str("0".into())).as_bool() == Some(true);
4895            // 1. notional <-> markPrice / contracts / contractSize
4896            if (notionalString == Value::Null) && hasMarkPrice && hasContracts && hasContractSize {
4897                let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4898                let mut derivedNotional: Value = crate::precise::Precise::stringMul(&totalSize, &markPriceString);
4899                if isInverse {
4900                    derivedNotional = crate::precise::Precise::stringDiv(&totalSize, &markPriceString);
4901                }
4902                if crate::precise::Precise::stringGt(&derivedNotional, &Value::Str("0".into())).as_bool() == Some(true) {
4903                    notionalString = derivedNotional.clone();
4904                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("notional".into(), self.parse_number(derivedNotional, &[])); }
4905                }
4906            }  else if (markPriceString == Value::Null) && (entryPriceString == Value::Null) && (lastPriceString.is_none()) && hasNotional && hasContracts && hasContractSize {
4907                let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4908                let mut derivedMark: Value = crate::precise::Precise::stringDiv(&notionalString, &totalSize);
4909                if isInverse {
4910                    derivedMark = crate::precise::Precise::stringDiv(&totalSize, &notionalString);
4911                }
4912                if crate::precise::Precise::stringGt(&derivedMark, &Value::Str("0".into())).as_bool() == Some(true) {
4913                    markPriceString = derivedMark.clone();
4914                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("markPrice".into(), self.parse_number(derivedMark, &[])); }
4915                }
4916            }  else if (contractsString == Value::Null) && hasNotional && hasMarkPrice && hasContractSize {
4917                let mut notionalContracts: Value = crate::precise::Precise::stringDiv(&notionalString, &crate::precise::Precise::stringMul(&markPriceString, &contractSizeString));
4918                if isInverse {
4919                    notionalContracts = crate::precise::Precise::stringDiv(&crate::precise::Precise::stringMul(&notionalString, &markPriceString), &contractSizeString);
4920                }
4921                if crate::precise::Precise::stringGt(&notionalContracts, &Value::Str("0".into())).as_bool() == Some(true) {
4922                    contractsString = notionalContracts.clone();
4923                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(notionalContracts, &[])); }
4924                }
4925            }  else if (contractSizeString == Value::Null) && hasNotional && hasMarkPrice && hasContracts {
4926                let mut notionalContractSize: Value = crate::precise::Precise::stringDiv(&notionalString, &crate::precise::Precise::stringMul(&markPriceString, &contractsString));
4927                if isInverse {
4928                    notionalContractSize = crate::precise::Precise::stringDiv(&crate::precise::Precise::stringMul(&notionalString, &markPriceString), &contractsString);
4929                }
4930                if crate::precise::Precise::stringGt(&notionalContractSize, &Value::Str("0".into())).as_bool() == Some(true) {
4931                    contractSizeString = notionalContractSize.clone();
4932                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(notionalContractSize, &[])); }
4933                }
4934            }
4935            // 2. unrealizedPnl from entryPrice, markPrice, contracts, contractSize, side
4936            if (unrealizedPnlString == Value::Null) && (entryPriceString != Value::Null) && (markPriceString != Value::Null) && (contractsString != Value::Null) && (contractSizeString != Value::Null) {
4937                if crate::precise::Precise::stringGt(&entryPriceString, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&markPriceString, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&contractsString, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into())).as_bool() == Some(true) {
4938                    let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4939                    let mut pnlDiff: Value = Value::Null;
4940                    if isInverse {
4941                        let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4942                        let mut invMark: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &markPriceString);
4943                        if (side.as_deref() == Some("long")) {
4944                            pnlDiff = crate::precise::Precise::stringSub(&invEntry, &invMark);
4945                        }  else if (side.as_deref() == Some("short")) {
4946                            pnlDiff = crate::precise::Precise::stringSub(&invMark, &invEntry);
4947                        }
4948                    }  else {
4949                        if (side.as_deref() == Some("long")) {
4950                            pnlDiff = crate::precise::Precise::stringSub(&markPriceString, &entryPriceString);
4951                        }  else if (side.as_deref() == Some("short")) {
4952                            pnlDiff = crate::precise::Precise::stringSub(&entryPriceString, &markPriceString);
4953                        }
4954                    }
4955                    if (pnlDiff != Value::Null) {
4956                        let mut candidateUpnl: Value = crate::precise::Precise::stringMul(&pnlDiff, &totalSize);
4957                        if crate::precise::Precise::stringEq(&candidateUpnl, &Value::Str("0".into())).as_bool() == Some(true) || crate::precise::Precise::stringGe(&crate::precise::Precise::stringAbs(&candidateUpnl), &Value::Str("0.000001".into())).as_bool() == Some(true) {
4958                            unrealizedPnlString = candidateUpnl.clone();
4959                            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("unrealizedPnl".into(), self.parse_number(unrealizedPnlString.clone(), &[])); }
4960                        }
4961                    }
4962                }
4963            }
4964            // 3. initialMargin <-> initialMarginPercentage <-> leverage / notional
4965            let mut hasValidNotional: bool = (notionalString != Value::Null) && crate::precise::Precise::stringGt(&notionalString, &Value::Str("0".into())).as_bool() == Some(true);
4966            let mut hasNegativeCollateral: bool = (collateralString != Value::Null) && crate::precise::Precise::stringLt(&collateralString, &Value::Str("0".into())).as_bool() == Some(true);
4967            let mut initialMarginPercentageString: Value = self.safe_string_k(position.clone(), "initialMarginPercentage", &[]);
4968            let mut leverageString: Value = self.safe_string_k(position.clone(), "leverage", &[]);
4969            let mut hasLeverage: bool = (leverageString != Value::Null) && crate::precise::Precise::stringGt(&leverageString, &Value::Str("0".into())).as_bool() == Some(true);
4970            let mut hasInitialMargin: bool = (initialMarginString != Value::Null) && crate::precise::Precise::stringGt(&initialMarginString, &Value::Str("0".into())).as_bool() == Some(true);
4971            let mut hadInitialMargin: bool = initialMarginString != Value::Null;
4972            if (initialMarginPercentageString == Value::Null) && !hasNegativeCollateral && (hasInitialMargin || !hadInitialMargin) {
4973                if hasInitialMargin && hasValidNotional {
4974                    initialMarginPercentageString = crate::precise::Precise::stringDiv(&initialMarginString, &notionalString);
4975                }  else if hasLeverage {
4976                    initialMarginPercentageString = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &leverageString);
4977                }
4978                if (initialMarginPercentageString != Value::Null) && crate::precise::Precise::stringGt(&initialMarginPercentageString, &Value::Str("0".into())).as_bool() == Some(true) {
4979                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMarginPercentage".into(), self.parse_number(initialMarginPercentageString.clone(), &[])); }
4980                }
4981            }
4982            let mut hasImp: bool = (initialMarginPercentageString != Value::Null) && crate::precise::Precise::stringGt(&initialMarginPercentageString, &Value::Str("0".into())).as_bool() == Some(true);
4983            if (initialMarginString == Value::Null) && !hasNegativeCollateral && hasValidNotional {
4984                if hasLeverage {
4985                    initialMarginString = crate::precise::Precise::stringDiv(&notionalString, &leverageString);
4986                }  else if hasImp {
4987                    initialMarginString = crate::precise::Precise::stringMul(&notionalString, &initialMarginPercentageString);
4988                }
4989                if (initialMarginString != Value::Null) && crate::precise::Precise::stringGt(&initialMarginString, &Value::Str("0".into())).as_bool() == Some(true) {
4990                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMargin".into(), self.parse_number(initialMarginString.clone(), &[])); }
4991                }
4992            }
4993            if (leverageString == Value::Null) && !hadInitialMargin && hasImp {
4994                let mut derivedLeverage: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &initialMarginPercentageString);
4995                if crate::precise::Precise::stringGt(&derivedLeverage, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringLe(&derivedLeverage, &Value::Str("200".into())).as_bool() == Some(true) {
4996                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("leverage".into(), self.parse_number(derivedLeverage, &[])); }
4997                }
4998            }
4999            // 4. maintenanceMargin <-> maintenanceMarginPercentage / notional
5000            let mut maintenanceMarginPercentageString: Value = self.safe_string_k(position.clone(), "maintenanceMarginPercentage", &[]);
5001            let mut hasValidMm: bool = (maintenanceMarginString != Value::Null) && crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into())).as_bool() == Some(true);
5002            let mut hasValidMmp: bool = (maintenanceMarginPercentageString != Value::Null) && crate::precise::Precise::stringGt(&maintenanceMarginPercentageString, &Value::Str("0".into())).as_bool() == Some(true);
5003            if (maintenanceMarginString == Value::Null) && hasValidNotional && hasValidMmp {
5004                let mut derivedMm: Value = crate::precise::Precise::stringMul(&notionalString, &maintenanceMarginPercentageString);
5005                if crate::precise::Precise::stringGt(&derivedMm, &Value::Str("0".into())).as_bool() == Some(true) {
5006                    maintenanceMarginString = derivedMm.clone();
5007                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMargin".into(), self.parse_number(derivedMm, &[])); }
5008                }
5009            }  else if (maintenanceMarginPercentageString == Value::Null) && hasValidNotional && hasValidMm {
5010                let mut derivedMmp: Value = crate::precise::Precise::stringDiv(&maintenanceMarginString, &notionalString);
5011                if crate::precise::Precise::stringGt(&derivedMmp, &Value::Str("0".into())).as_bool() == Some(true) {
5012                    maintenanceMarginPercentageString = derivedMmp.clone();
5013                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMarginPercentage".into(), self.parse_number(derivedMmp, &[])); }
5014                }
5015            }
5016            // 5. marginRatio = maintenanceMargin / collateral
5017            let mut marginRatio: Value = self.safe_value_k(position.clone(), "marginRatio", &[]);
5018            if (marginRatio == Value::Null) && (maintenanceMarginString != Value::Null) && (collateralString != Value::Null) {
5019                if crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&collateralString, &Value::Str("0".into())).as_bool() == Some(true) {
5020                    let mut derivedMarginRatio: Value = crate::precise::Precise::stringDivPrec(&maintenanceMarginString, &collateralString, &Value::Int(4));
5021                    if (derivedMarginRatio != Value::Null) && crate::precise::Precise::stringGt(&derivedMarginRatio, &Value::Str("0".into())).as_bool() == Some(true) {
5022                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("marginRatio".into(), self.parse_number(derivedMarginRatio, &[])); }
5023                    }
5024                }
5025            }
5026        }
5027        //
5028        // PERCENTAGE
5029        //
5030        let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
5031        if (percentage == Value::Null) && (unrealizedPnlString != Value::Null) && (initialMarginString != Value::Null) {
5032            // as it was done in all implementations ( aax, btcex, bybit, deribit, gate, kucoinfutures, phemex )
5033            let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".into()));
5034            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("percentage".into(), self.parse_number(percentageString, &[])); }
5035        }
5036        return position;
5037
5038    Value::Null
5039}
5040
5041    fn parse_positions(&self, mut positions: Value, optional_args: &[Value]) -> Value {
5042        let mut symbols = get_arg(optional_args, 0, Value::Null);
5043        let mut params = get_arg(optional_args, 1, Value::Map({
5044    let mut m = indexmap::IndexMap::new();
5045    m
5046}));
5047        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
5048        let mut positionsArray: Value = self.to_array(positions);
5049        let mut result: Vec<Value> = Vec::new();
5050        {
5051                        let mut i: Value = Value::Int(0);
5052            let mut __for_first_122: bool = true;
5053            while { if !__for_first_122 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_122 = false; i.as_f64().unwrap_or(f64::NAN) < ((positionsArray.len() as i64) as f64) } {
5054            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()]);
5055            result.push(position);
5056        }
5057        }
5058        return self.filter_by_array_positions(Value::from(result), Value::Str("symbol".into()), &[symbolsNormalized]);
5059
5060    Value::Null
5061}
5062
5063    fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
5064        // virtual-dispatch (static: DerivedExchange::parse_adl_rank(self, ...))
5065        { 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; } }
5066
5067        let mut market = get_arg(optional_args, 0, Value::Null);
5068        if (info == Value::Null) {
5069            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
5070        }
5071        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
5072
5073    Value::Null
5074}
5075
5076    fn parse_adl_ranks(&self, mut ranks: Value, optional_args: &[Value]) -> Value {
5077        let mut symbols = get_arg(optional_args, 0, Value::Null);
5078        let mut params = get_arg(optional_args, 1, Value::Map({
5079    let mut m = indexmap::IndexMap::new();
5080    m
5081}));
5082        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
5083        let mut ranksArray: Value = self.to_array(ranks);
5084        let mut result: Vec<Value> = Vec::new();
5085        {
5086                        let mut i: Value = Value::Int(0);
5087            let mut __for_first_123: bool = true;
5088            while { if !__for_first_123 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_123 = false; i.as_f64().unwrap_or(f64::NAN) < ((ranksArray.len() as i64) as f64) } {
5089            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()]);
5090            result.push(rank);
5091        }
5092        }
5093        return self.filter_by_array_positions(Value::from(result), Value::Str("symbol".into()), &[symbolsNormalized]);
5094
5095    Value::Null
5096}
5097
5098    fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
5099        let mut params = get_arg(optional_args, 0, Value::Map({
5100    let mut m = indexmap::IndexMap::new();
5101    m
5102}));
5103        let mut accountsArray: Value = self.to_array(accounts);
5104        let mut result: Vec<Value> = Vec::new();
5105        {
5106                        let mut i: Value = Value::Int(0);
5107            let mut __for_first_124: bool = true;
5108            while { if !__for_first_124 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_124 = false; i.as_f64().unwrap_or(f64::NAN) < ((accountsArray.len() as i64) as f64) } {
5109            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()]);
5110            result.push(account);
5111        }
5112        }
5113        return Value::from(result);
5114
5115    Value::Null
5116}
5117
5118    fn parse_trades_helper(&self, mut isWs: Value, mut trades: Value, optional_args: &[Value]) -> Value {
5119        let mut market = get_arg(optional_args, 0, Value::Null);
5120        let mut since = get_arg(optional_args, 1, Value::Null);
5121        let mut limit = get_arg(optional_args, 2, Value::Null);
5122        let mut params = get_arg(optional_args, 3, Value::Map({
5123    let mut m = indexmap::IndexMap::new();
5124    m
5125}));
5126        let mut tradesArray: Value = self.to_array(trades);
5127        let mut result: Value = Value::from(vec![]);
5128        {
5129                        let mut i: Value = Value::Int(0);
5130            let mut __for_first_125: bool = true;
5131            while { if !__for_first_125 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_125 = false; i.as_f64().unwrap_or(f64::NAN) < ((tradesArray.len() as i64) as f64) } {
5132            let mut parsed: Value = Value::Null;
5133            if isWs.as_bool() == Some(true) {
5134                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()]);
5135            }  else {
5136                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()]);
5137            }
5138            let mut trade: Value = self.extend(parsed, &[params.clone()]);
5139            if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(trade); }
5140        }
5141        }
5142        result = self.sort_by2(result.clone(), Value::Str("timestamp".into()), Value::Str("id".into()), &[]);
5143        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
5144        return self.filter_by_symbol_since_limit(result, &[symbol, since, limit]);
5145
5146    Value::Null
5147}
5148
5149    fn parse_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5150        let mut market = get_arg(optional_args, 0, Value::Null);
5151        let mut since = get_arg(optional_args, 1, Value::Null);
5152        let mut limit = get_arg(optional_args, 2, Value::Null);
5153        let mut params = get_arg(optional_args, 3, Value::Map({
5154    let mut m = indexmap::IndexMap::new();
5155    m
5156}));
5157        return self.parse_trades_helper(Value::Bool(false), trades, &[market, since, limit, params]);
5158
5159    Value::Null
5160}
5161
5162    fn parse_ws_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5163        let mut market = get_arg(optional_args, 0, Value::Null);
5164        let mut since = get_arg(optional_args, 1, Value::Null);
5165        let mut limit = get_arg(optional_args, 2, Value::Null);
5166        let mut params = get_arg(optional_args, 3, Value::Map({
5167    let mut m = indexmap::IndexMap::new();
5168    m
5169}));
5170        return self.parse_trades_helper(Value::Bool(true), trades, &[market, since, limit, params]);
5171
5172    Value::Null
5173}
5174
5175    fn parse_transactions(&self, mut transactions: Value, optional_args: &[Value]) -> Value {
5176        let mut currency = get_arg(optional_args, 0, Value::Null);
5177        let mut since = get_arg(optional_args, 1, Value::Null);
5178        let mut limit = get_arg(optional_args, 2, Value::Null);
5179        let mut params = get_arg(optional_args, 3, Value::Map({
5180    let mut m = indexmap::IndexMap::new();
5181    m
5182}));
5183        let mut transactionsArray: Value = self.to_array(transactions);
5184        let mut result: Value = Value::from(vec![]);
5185        {
5186                        let mut i: Value = Value::Int(0);
5187            let mut __for_first_126: bool = true;
5188            while { if !__for_first_126 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_126 = false; i.as_f64().unwrap_or(f64::NAN) < ((transactionsArray.len() as i64) as f64) } {
5189            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()]);
5190            if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(transaction); }
5191        }
5192        }
5193        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5194        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 });
5195        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5196
5197    Value::Null
5198}
5199
5200    fn parse_transfers(&self, mut transfers: Value, optional_args: &[Value]) -> Value {
5201        let mut currency = get_arg(optional_args, 0, Value::Null);
5202        let mut since = get_arg(optional_args, 1, Value::Null);
5203        let mut limit = get_arg(optional_args, 2, Value::Null);
5204        let mut params = get_arg(optional_args, 3, Value::Map({
5205    let mut m = indexmap::IndexMap::new();
5206    m
5207}));
5208        let mut transfersArray: Value = self.to_array(transfers);
5209        let mut result: Value = Value::from(vec![]);
5210        {
5211                        let mut i: Value = Value::Int(0);
5212            let mut __for_first_127: bool = true;
5213            while { if !__for_first_127 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_127 = false; i.as_f64().unwrap_or(f64::NAN) < ((transfersArray.len() as i64) as f64) } {
5214            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()]);
5215            if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(transfer); }
5216        }
5217        }
5218        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5219        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 });
5220        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5221
5222    Value::Null
5223}
5224
5225    fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
5226        let mut currency = get_arg(optional_args, 0, Value::Null);
5227        let mut since = get_arg(optional_args, 1, Value::Null);
5228        let mut limit = get_arg(optional_args, 2, Value::Null);
5229        let mut params = get_arg(optional_args, 3, Value::Map({
5230    let mut m = indexmap::IndexMap::new();
5231    m
5232}));
5233        let mut result: Value = Value::from(vec![]);
5234        let mut arrayData: Value = self.to_array(data);
5235        {
5236                        let mut i: Value = Value::Int(0);
5237            let mut __for_first_129: bool = true;
5238            while { if !__for_first_129 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_129 = false; i.as_f64().unwrap_or(f64::NAN) < ((arrayData.len() as i64) as f64) } {
5239            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()]);
5240            if (matches!(&itemOrItems, Value::Arr(_))) {
5241                {
5242                                        let mut j: Value = Value::Int(0);
5243                    let mut __for_first_128: bool = true;
5244                    while { if !__for_first_128 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_128 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&itemOrItems).as_f64().unwrap_or(f64::NAN) } {
5245                    if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(self.extend(get_value(&itemOrItems, &j), &[params.clone()])); }
5246                }
5247                }
5248            }  else {
5249                if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(self.extend(itemOrItems, &[params.clone()])); }
5250            }
5251        }
5252        }
5253        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5254        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 });
5255        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5256
5257    Value::Null
5258}
5259
5260    fn nonce(&self) -> Value {
5261        // virtual-dispatch (static: DerivedExchange::nonce(self, ...))
5262        { let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
5263
5264        return self.seconds();
5265
5266    Value::Null
5267}
5268
5269/*
5270 * @method
5271 * @ignore
5272 * @name Exchange#incrementingNonce
5273 * @description returns a strictly-increasing nonce for venues that reject duplicate nonces per signer;
5274 * the unit is whatever nonce () returns — the base default is seconds, so a venue that does not override
5275 * nonce () gets a second-resolution counter that drifts ahead of wall clock under load, while venues
5276 * needing milliseconds override nonce () as hyperliquid does. The counter is per exchange instance,
5277 * so it narrows the duplicate-nonce race but does not remove it across instances or processes.
5278 * @returns {int} a strictly-increasing nonce in the unit returned by nonce ()
5279 */
5280    fn incrementing_nonce(&mut self) -> Value {
5281        let mut currentNonce: Value = <Self as crate::exchange_generated::ExchangeBase>::nonce(self, );
5282        self.lock_last_nonce(&[]);
5283        let mut lastNonce: Value = self.safe_integer_k(self.options.clone(), "lastNonce", &[Value::Int(0)]);
5284        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 }) });
5285        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("lastNonce".into(), result.clone()); }
5286        self.unlock_last_nonce(&[]);
5287        return result;
5288
5289    Value::Null
5290}
5291
5292    fn set_headers(&self, mut headers: Value) -> Value {
5293        return headers;
5294
5295    Value::Null
5296}
5297
5298    fn currency_id(&self, mut code: Value) -> Value {
5299        if (code == Value::Null) {
5300            return code;
5301        }
5302        let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5303        if (currency == Value::Null) {
5304            currency = self.safe_currency(code.clone(), &[]);
5305        }
5306        if (currency != Value::Null) {
5307            return currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5308        }
5309        return code;
5310
5311    Value::Null
5312}
5313
5314    fn market_id(&self, mut symbol: Value) -> Value {
5315        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
5316        if (market != Value::Null) {
5317            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5318        }
5319        return symbol;
5320
5321    Value::Null
5322}
5323
5324    fn symbol(&self, mut symbol: Value) -> Value {
5325        if (symbol == Value::Null) {
5326            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" symbol() requires a symbol argument".into()))));
5327        }
5328        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
5329        return self.safe_string_k(market, "symbol", &[symbol]);
5330
5331    Value::Null
5332}
5333
5334/* eslint-disable no-unused-vars */
5335/* eslint-enable no-unused-vars */
5336    fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5337        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5338        let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue]);
5339        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5340        return Value::from(vec![value, paramsOmitted]);
5341
5342    Value::Null
5343}
5344
5345/* eslint-disable no-unused-vars */
5346/* eslint-enable no-unused-vars */
5347    fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5348        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5349        let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5350        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5351        return Value::from(vec![value, paramsOmitted]);
5352
5353    Value::Null
5354}
5355
5356    fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5357        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5358        let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue]);
5359        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5360        return Value::from(vec![value, paramsOmitted]);
5361
5362    Value::Null
5363}
5364
5365    fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5366        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5367        let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5368        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5369        return Value::from(vec![value, paramsOmitted]);
5370
5371    Value::Null
5372}
5373
5374    fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5375        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5376        let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue]);
5377        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5378        return Value::from(vec![value, paramsOmitted]);
5379
5380    Value::Null
5381}
5382
5383    fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5384        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5385        let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5386        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5387        return Value::from(vec![value, paramsOmitted]);
5388
5389    Value::Null
5390}
5391
5392    fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5393        return Value::from(vec![self.implode_params(path.clone(), params.clone()), self.omit(params, self.extract_params(path), &[])]);
5394
5395    Value::Null
5396}
5397
5398    fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5399        let mut newArray: Value = objects.clone();
5400        if !(matches!(&objects, Value::Arr(_))) {
5401            newArray = self.to_array(objects.clone());
5402        }
5403        let mut results: Vec<Value> = Vec::new();
5404        {
5405                        let mut i: Value = Value::Int(0);
5406            let mut __for_first_130: bool = true;
5407            while { if !__for_first_130 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_130 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&newArray).as_f64().unwrap_or(f64::NAN) } {
5408            results.push(get_value(&get_value(&newArray, &i), &key));
5409        }
5410        }
5411        return Value::from(results);
5412
5413    Value::Null
5414}
5415
5416    fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5417        let mut marketType = get_arg(optional_args, 0, Value::Null);
5418        let mut subType = get_arg(optional_args, 1, Value::Null);
5419        let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5420        let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5421        let mut filteredMarkets: Value = self.markets.clone();
5422        if (marketType != Value::Null) {
5423            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".into()), marketType, &[]);
5424        }
5425        if (subType != Value::Null) {
5426            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())])]);
5427            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".into()), subType, &[]);
5428        }
5429        let mut activeStatuses: Vec<Value> = Vec::new();
5430        if symbolWithActiveStatus.as_bool() == Some(true) {
5431            activeStatuses.push(Value::Bool(true));
5432        }
5433        if symbolWithUnknownStatus.as_bool() == Some(true) {
5434            activeStatuses.push(Value::Null);
5435        }
5436        filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".into()), &[Value::from(activeStatuses), Value::Bool(false)]);
5437        return self.get_list_from_object_values(filteredMarkets, Value::Str("symbol".into()));
5438
5439    Value::Null
5440}
5441
5442    fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5443        let mut values = get_arg(optional_args, 0, Value::Null);
5444        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5445        let mut objectsValue: Value = self.to_array(objects);
5446        // return all of them if no values were passed
5447        if (values == Value::Null) || (values == Value::Null) || ((match &(values) { Value::Bool(__x) => *__x == false, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) || ((match &(values) { Value::Int(__x) => *__x == 0, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) || (values.as_str() == Some("")) {
5448            // return indexed ? this.indexBy (objects, key) : objects;
5449            if indexed.as_bool() == Some(true) {
5450                return self.index_by(objectsValue.clone(), key.clone());
5451            }  else {
5452                return objectsValue;
5453            }
5454        }
5455        let mut results: Vec<Value> = Vec::new();
5456        {
5457                        let mut i: Value = Value::Int(0);
5458            let mut __for_first_131: bool = true;
5459            while { if !__for_first_131 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_131 = false; i.as_f64().unwrap_or(f64::NAN) < ((objectsValue.len() as i64) as f64) } {
5460            if self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true) {
5461                results.push(get_value(&objectsValue, &i));
5462            }
5463        }
5464        }
5465        // return indexed ? this.indexBy (results, key) : results;
5466        if indexed.as_bool() == Some(true) {
5467            return self.index_by(Value::from(results), key);
5468        }
5469        return Value::from(results);
5470
5471    Value::Null
5472}
5473
5474    fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5475        let mut values = get_arg(optional_args, 0, Value::Null);
5476        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5477        let mut objectsValue: Value = self.to_array(objects);
5478        // return all of them if no values were passed
5479        if (values == Value::Null) || (values == Value::Null) || ((match &(values) { Value::Bool(__x) => *__x == false, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) || ((match &(values) { Value::Int(__x) => *__x == 0, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) || (values.as_str() == Some("")) {
5480            // return indexed ? this.indexBy (objects, key) : objects;
5481            if indexed.as_bool() == Some(true) {
5482                return self.index_by(objectsValue.clone(), key.clone());
5483            }  else {
5484                return objectsValue;
5485            }
5486        }
5487        let mut results: Vec<Value> = Vec::new();
5488        {
5489                        let mut i: Value = Value::Int(0);
5490            let mut __for_first_132: bool = true;
5491            while { if !__for_first_132 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_132 = false; i.as_f64().unwrap_or(f64::NAN) < ((objectsValue.len() as i64) as f64) } {
5492            if !(self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true)) {
5493                results.push(get_value(&objectsValue, &i));
5494            }
5495        }
5496        }
5497        // return indexed ? this.indexBy (results, key) : results;
5498        if indexed.as_bool() == Some(true) {
5499            return self.index_by(Value::from(results), key);
5500        }
5501        return Value::from(results);
5502
5503    Value::Null
5504}
5505
5506    fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5507        let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
5508        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5509        let mut params = get_arg(optional_args, 2, Value::Map({
5510    let mut m = indexmap::IndexMap::new();
5511    m
5512}));
5513        let mut config = get_arg(optional_args, 3, Value::Map({
5514    let mut m = indexmap::IndexMap::new();
5515    m
5516}));
5517        if is_true(&self.enableRateLimit) {
5518            let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config]);
5519            self.throttle(&[cost]).await;
5520        }
5521        let mut retries: Value = Value::Int(0);
5522        // implicit endpoints may pass a list body as params: keep it an untyped box
5523        let mut requestParams: Value = params;
5524        let mut retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable = self.handle_option_integer_and_params(requestParams, path.clone(), Value::Str("maxRetriesOnFailure".into()), &[retries]);
5525        let mut retriesMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5526        let mut paramsMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5527        let mut retryDelay: Value = Value::Int(0);
5528        let mut retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable = self.handle_option_integer_and_params(paramsMaxRetriesOnFailure, path.clone(), Value::Str("maxRetriesOnFailureDelay".into()), &[retryDelay]);
5529        let mut retryDelayMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5530        let mut paramsMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5531        let mut fetchDataCacheEnabled: bool = self.fetchHistoryCacheSize.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64);
5532        {
5533                        let mut i: Value = Value::Int(0);
5534            let mut __for_first_133: bool = true;
5535            while { if !__for_first_133 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_133 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(retriesMaxRetriesOnFailure), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (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) } {
5536            let mut fetchData: Value = Value::Null;
5537            if fetchDataCacheEnabled {
5538                fetchData = Value::Map({
5539                    let mut m = indexmap::IndexMap::new();
5540                        m.insert("request".to_string(), Value::Null);
5541                        m.insert("response".to_string(), Value::Map({
5542    let mut m = indexmap::IndexMap::new();
5543        m.insert("body".to_string(), Value::Null);
5544    m
5545}));
5546                        m.insert("error".to_string(), Value::Null);
5547                    m
5548                });
5549            }
5550            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5551                self.set_last_rest_request_timestamp();
5552                let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), paramsMaxRetriesOnFailureDelay.clone()]);
5553                if (fetchData != Value::Null) {
5554                    if let Value::Dict(__d) = &mut fetchData { std::sync::Arc::make_mut(__d).insert("request".into(), request.clone()); }
5555                }
5556                self.set_last_request(request.clone());
5557                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;
5558                if (fetchData != Value::Null) {
5559                    add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".into())), &Value::Str("body".into()), response.clone());
5560                    self.add_fetch_cache(fetchData.clone());
5561                }
5562                return response;
5563             #[allow(unreachable_code)] { Value::Null }})).await;
5564match _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); 
5565                if (fetchData != Value::Null) {
5566                    if let Value::Dict(__d) = &mut fetchData { std::sync::Arc::make_mut(__d).insert("error".into(), e.clone()); }
5567                    self.add_fetch_cache(fetchData);
5568                }
5569                if is_instance(&e, &Value::Str("OperationFailed".into())) {
5570                    if i.as_f64().unwrap_or(f64::NAN) < retriesMaxRetriesOnFailure.as_f64().unwrap_or(f64::NAN) {
5571                        if is_true(&self.verbose) {
5572                            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 });
5573                            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()), Value::Str(format!("{}", index).into())).into()), Value::Str(" of ".into())).into()), Value::Str(format!("{}", retriesMaxRetriesOnFailure).into())).into()), Value::Str("...".into())).into()));
5574                        }
5575                        if (retryDelayMaxRetriesOnFailureDelay != Value::Null) && (retryDelayMaxRetriesOnFailureDelay.as_f64() != Some(0.0)) {
5576                            self.sleep(retryDelayMaxRetriesOnFailureDelay.clone()).await;
5577                        }
5578                    }  else {
5579                        panic!("{}", e);
5580                    }
5581                }  else {
5582                    panic!("{}", e);
5583                }
5584             } }
5585        }
5586        }
5587        return Value::Null;
5588
5589    Value::Null
5590} }
5591
5592    fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5593        let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
5594        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5595        let mut params = get_arg(optional_args, 2, Value::Map({
5596    let mut m = indexmap::IndexMap::new();
5597    m
5598}));
5599        let mut config = get_arg(optional_args, 3, Value::Map({
5600    let mut m = indexmap::IndexMap::new();
5601    m
5602}));
5603        return self.fetch2(path, &[api, method, params, config]).await;
5604
5605    Value::Null
5606} }
5607
5608    fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5609        let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5610        let mut params = get_arg(optional_args, 1, Value::Map({
5611    let mut m = indexmap::IndexMap::new();
5612    m
5613}));
5614        if reload.as_bool() == Some(true) {
5615            { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5616        }  else {
5617            if (self.accounts.clone() != Value::Null) {
5618                return self.accounts.clone();
5619            }  else {
5620                { let __t = self.fetch_accounts(&[params]).await; self.accounts = __t; }
5621            }
5622        }
5623        { let __t = self.index_by(self.accounts.clone(), Value::Str("id".into())); self.accountsById = __t; }
5624        return self.accounts.clone();
5625
5626    Value::Null
5627} }
5628
5629    fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5630        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
5631        let mut since = get_arg(optional_args, 1, Value::Int(0));
5632        let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5633        // given a sorted arrays of trades (recent last) and a timeframe builds an array of OHLCV candles
5634        // note, default limit value (2147483647) is max int32 value
5635        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 });
5636        let mut ohlcvs: Value = Value::from(vec![]);
5637        let mut i_timestamp: Value = Value::Int(0);
5638        // const open = 1;
5639        let mut i_high: Value = Value::Int(2);
5640        let mut i_low: Value = Value::Int(3);
5641        let mut i_close: Value = Value::Int(4);
5642        let mut i_volume: Value = Value::Int(5);
5643        let mut i_count: Value = Value::Int(6);
5644        let mut tradesLength: Value = Value::Int(trades.len() as i64);
5645        let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5646        let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5647    let mut m = indexmap::IndexMap::new();
5648    m
5649})]);
5650        let mut skipZeroPrices: Value = self.safe_bool_k(options, "skipZeroPrices", &[Value::Bool(true)]);
5651        {
5652                        let mut i: Value = Value::Int(0);
5653            let mut __for_first_134: bool = true;
5654            while { if !__for_first_134 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_134 = false; i.as_f64().unwrap_or(f64::NAN) < oldest.as_f64().unwrap_or(f64::NAN) } {
5655            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);
5656            let mut ts: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
5657            let mut price: Value = trade.as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null);
5658            if (ts == Value::Null) || (price == Value::Null) {
5659                continue;
5660            }
5661            if ts.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5662                continue;
5663            }
5664            if (ts == Value::Null) {
5665                panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing ts".into()))));
5666            }
5667            let mut openingTime: Value = (match (&(((match ((ts).as_f64(), (ms).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })).as_f64().map(|__x| Value::Float(__x.floor())).unwrap_or(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)
5668            if openingTime.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5669                continue;
5670            }
5671            let mut ohlcv_length: Value = Value::Int(ohlcvs.len() as i64);
5672            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 });
5673            if (price == Value::Null) {
5674                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() requires a price argument".into()))));
5675            }
5676            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)) {
5677                continue;
5678            }
5679            let mut isNewCandle: bool = candle.as_f64() == Value::Int(-1).as_f64();
5680            if !isNewCandle {
5681                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);
5682                if (candleTimestamp == Value::Null) {
5683                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing candle timestamp".into()))));
5684                }
5685                isNewCandle = (match (&(openingTime), &(self.sum(&[candleTimestamp, ms.clone()]))) { (__a, __b) => (match ((match __a { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), (match __b { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None })) { (Some(__x), Some(__y)) => __x > __y, _ => matches!((__a, __b), (Value::Str(__x), Value::Str(__y)) if __x > __y) }) || (match (__a, __b) { (Value::Null, Value::Null) => true, (Value::Bool(__x), Value::Bool(__y)) => __x == __y, (Value::Str(__x), Value::Str(__y)) => __x == __y, (Value::Int(__x), Value::Int(__y)) => __x == __y, (Value::Float(__x), Value::Float(__y)) => __x == __y, _ => matches!(((match __a { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), (match __b { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None })), (Some(__x), Some(__y)) if __x == __y) }) });
5686            }
5687            if isNewCandle {
5688                // moved to a new timeframe -> create a new candle from opening trade
5689                if let Value::Arr(__a) = &mut ohlcvs { std::sync::Arc::make_mut(__a).push(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)])); }
5690            }  else {
5691                // still processing the same timeframe -> update opening trade
5692                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);
5693                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);
5694                let mut prevHighValue: Value = (if (prevHigh == Value::Null) { price.clone() } else { prevHigh });
5695                let mut prevLowValue: Value = (if (prevLow == Value::Null) { price.clone() } else { prevLow });
5696                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
5697                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
5698                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price);
5699                { 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); };
5700                { 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); };
5701            }
5702        }
5703        }
5704        return ohlcvs;
5705
5706    Value::Null
5707}
5708
5709    fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5710        let mut market = get_arg(optional_args, 0, Value::Null);
5711        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
5712        let mut since = get_arg(optional_args, 2, Value::Null);
5713        let mut limit = get_arg(optional_args, 3, Value::Null);
5714        let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs, &[]);
5715        return self.parse_ohlc_vs(result, &[market, timeframe, since, limit]);
5716
5717    Value::Null
5718}
5719
5720    fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5721        let mut code = get_arg(optional_args, 0, Value::Null);
5722        let mut symbol = get_arg(optional_args, 1, Value::Null);
5723        let mut since = get_arg(optional_args, 2, Value::Null);
5724        let mut limit = get_arg(optional_args, 3, Value::Null);
5725        let mut params = get_arg(optional_args, 4, Value::Map({
5726    let mut m = indexmap::IndexMap::new();
5727    m
5728}));
5729        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowInterest() is not supported yet".into()))));
5730
5731    Value::Null
5732} }
5733
5734    fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5735        // async-virtual: try the derived exchange first
5736        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 {
5737            if !matches!(__v, crate::Value::Null) { return __v; }
5738        }
5739
5740        let mut code = get_arg(optional_args, 0, Value::Null);
5741        let mut since = get_arg(optional_args, 1, Value::Null);
5742        let mut limit = get_arg(optional_args, 2, Value::Null);
5743        let mut params = get_arg(optional_args, 3, Value::Map({
5744    let mut m = indexmap::IndexMap::new();
5745    m
5746}));
5747        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedger() is not supported yet".into()))));
5748
5749    Value::Null
5750} }
5751
5752    fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5753        let mut code = get_arg(optional_args, 0, Value::Null);
5754        let mut params = get_arg(optional_args, 1, Value::Map({
5755    let mut m = indexmap::IndexMap::new();
5756    m
5757}));
5758        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedgerEntry() is not supported yet".into()))));
5759
5760    Value::Null
5761} }
5762
5763    fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5764        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5765        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5766        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5767        let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5768        let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5769        let mut countOrId: Value = self.safe_integer(bidask, countOrIdKey, &[]);
5770        let mut bidAsk: Value = Value::from(vec![price, amount]);
5771        if (countOrId != Value::Null) {
5772            if let Value::Arr(__a) = &mut bidAsk { std::sync::Arc::make_mut(__a).push(countOrId); }
5773        }
5774        return bidAsk;
5775
5776    Value::Null
5777}
5778
5779    fn parse_order_book_bid_ask_l3(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5780        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5781        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5782        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5783        let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5784        let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5785        let mut countOrId: Value = self.safe_string(bidask, countOrIdKey, &[]);
5786        let mut bidAsk: Value = Value::from(vec![price, amount]);
5787        if (countOrId != Value::Null) {
5788            if let Value::Arr(__a) = &mut bidAsk { std::sync::Arc::make_mut(__a).push(countOrId); }
5789        }
5790        return bidAsk;
5791
5792    Value::Null
5793}
5794
5795    fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5796        let mut currency = get_arg(optional_args, 0, Value::Null);
5797        if (currencyId == Value::Null) && (currency != Value::Null) {
5798            return currency;
5799        }
5800        if (currencyId != Value::Null) && (self.currencies_by_id.clone() != Value::Null) && (matches!((&self.currencies_by_id, &currencyId), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) && (self.currencies_by_id.as_map().and_then(|__m| currencyId.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null) != Value::Null) {
5801            return self.currencies_by_id.as_map().and_then(|__m| currencyId.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
5802        }
5803        let mut code: Value = currencyId.clone();
5804        if (currencyId != Value::Null) {
5805            code = self.common_currency_code(currencyId.as_str().map(|__s| Value::Str(__s.to_uppercase().into())).unwrap_or(Value::Null));
5806        }
5807        return self.safe_currency_structure(Value::Map({
5808    let mut m = indexmap::IndexMap::new();
5809        m.insert("id".to_string(), currencyId);
5810        m.insert("code".to_string(), code);
5811        m.insert("precision".to_string(), Value::Null);
5812    m
5813}));
5814
5815    Value::Null
5816}
5817
5818    fn safe_market(&self, optional_args: &[Value]) -> Value {
5819        let mut marketId = get_arg(optional_args, 0, Value::Null);
5820        let mut market = get_arg(optional_args, 1, Value::Null);
5821        let mut delimiter = get_arg(optional_args, 2, Value::Null);
5822        let mut marketType = get_arg(optional_args, 3, Value::Null);
5823        if (marketId != Value::Null) {
5824            if (self.markets_by_id.clone() != Value::Null) && (matches!((&self.markets_by_id, &marketId), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
5825                let mut markets: Value = self.markets_by_id.as_map().and_then(|__m| marketId.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
5826                let mut numMarkets: Value = get_array_length(&markets);
5827                if (numMarkets.as_f64() == Some(1.0)) {
5828                    return get_value(&markets, &Value::Int(0));
5829                }  else {
5830                    if (marketType == Value::Null) && (market == Value::Null) {
5831                        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()))));
5832                    }
5833                    let mut marketTypeResolved: Value = (if (marketType == Value::Null) { self.safe_string_k(market.clone(), "type", &[Value::Str("".into())]) } else { marketType });
5834                    {
5835                                                let mut i: Value = Value::Int(0);
5836                        let mut __for_first_135: bool = true;
5837                        while { if !__for_first_135 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_135 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
5838                        let mut currentMarket: Value = get_value(&markets, &i);
5839                        let mut currentMarket: Value = get_value(&markets, &i);
5840                        if (match &(get_value(&currentMarket, &marketTypeResolved)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
5841                            return currentMarket;
5842                        }
5843                    }
5844                    }
5845                }
5846            }  else if (delimiter != Value::Null) && (delimiter.as_str() != Some("")) {
5847                let mut parts: Value = Value::Array(marketId.as_str().zip(delimiter.as_str()).map(|(__s, __d)| __s.split(__d).map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
5848                let mut partsLength: f64 = ((parts.len() as i64) as f64);
5849                let mut result: Value = self.safe_market_structure(&[Value::Map({
5850    let mut m = indexmap::IndexMap::new();
5851        m.insert("symbol".to_string(), marketId.clone());
5852        m.insert("marketId".to_string(), marketId.clone());
5853    m
5854})]);
5855                if (result == Value::Null) {
5856                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5857                }
5858                if (partsLength == 2.0) {
5859                    let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
5860                    let mut quoteId: Value = self.safe_string(parts, Value::Int(1), &[]);
5861                    let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
5862                    let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
5863                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("baseId".into(), baseId); }
5864                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quoteId); }
5865                    if (base != Value::Null) {
5866                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("base".into(), base.clone()); }
5867                    }
5868                    if (quote != Value::Null) {
5869                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quote".into(), quote.clone()); }
5870                    }
5871                    if (base != Value::Null) && (quote != Value::Null) {
5872                        add_element_to_object(&mut result, &Value::Str("symbol".into()), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
5873                    }
5874                }
5875                return result;
5876            }
5877        }
5878        if (market != Value::Null) {
5879            return market;
5880        }
5881        let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5882    let mut m = indexmap::IndexMap::new();
5883        m.insert("symbol".to_string(), marketId.clone());
5884        m.insert("marketId".to_string(), marketId);
5885    m
5886})]);
5887        if (emptyMarket == Value::Null) {
5888            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5889        }
5890        return emptyMarket;
5891
5892    Value::Null
5893}
5894
5895    fn market_or_null(&self, optional_args: &[Value]) -> Value {
5896        let mut symbol = get_arg(optional_args, 0, Value::Null);
5897        if (symbol == Value::Null) {
5898            return Value::Null;
5899        }
5900        return <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
5901
5902    Value::Null
5903}
5904
5905    fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5906        let mut error = get_arg(optional_args, 0, Value::Bool(true));
5907        /*
5908         * @ignore
5909         * @method
5910         * @param {boolean} error throw an error that a credential is required if true
5911         * @returns {boolean} true if all required credentials have been set, otherwise false or an error is thrown is param error=true
5912         */
5913        let mut keys: Value = Value::Array(self.requiredCredentials.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
5914        {
5915                        let mut i: Value = Value::Int(0);
5916            let mut __for_first_136: bool = true;
5917            while { if !__for_first_136 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_136 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
5918            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);
5919            let mut credentialValue: Value = self.prop(&key);
5920            let mut credentialMissing: bool = (credentialValue == Value::Null) || (credentialValue == Value::Null) || ((match &(credentialValue) { Value::Bool(__x) => *__x == false, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) || (credentialValue.as_str() == Some(""));
5921            if (self.requiredCredentials.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) && credentialMissing {
5922                if is_true(&error) {
5923                    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()))));
5924                }  else {
5925                    return Value::Bool(false);
5926                }
5927            }
5928        }
5929        }
5930        return Value::Bool(true);
5931
5932    Value::Null
5933}
5934
5935    fn oath(&self) -> Value {
5936        if (self.twofa.clone() != Value::Null) {
5937            return totp(self.twofa.clone());
5938        }  else {
5939            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".into()))));
5940        }
5941
5942    Value::Null
5943}
5944
5945    fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5946        // async-virtual: try the derived exchange first
5947        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 {
5948            if !matches!(__v, crate::Value::Null) { return __v; }
5949        }
5950
5951        let mut params = get_arg(optional_args, 0, Value::Map({
5952    let mut m = indexmap::IndexMap::new();
5953    m
5954}));
5955        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalance() is not supported yet".into()))));
5956
5957    Value::Null
5958} }
5959
5960    fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5961        let mut params = get_arg(optional_args, 0, Value::Map({
5962    let mut m = indexmap::IndexMap::new();
5963    m
5964}));
5965        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalanceWs() is not supported yet".into()))));
5966
5967    Value::Null
5968} }
5969
5970    fn parse_balance(&self, mut response: Value) -> Value {
5971        // virtual-dispatch (static: DerivedExchange::parse_balance(self, ...))
5972        { let __v = crate::exchange::DerivedExchange::parse_balance(self, response); if !matches!(__v, crate::Value::Null) { return __v; } }
5973
5974        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBalance() is not supported yet".into()))));
5975
5976    Value::Null
5977}
5978
5979    fn watch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5980        let mut params = get_arg(optional_args, 0, Value::Map({
5981    let mut m = indexmap::IndexMap::new();
5982    m
5983}));
5984        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBalance() is not supported yet".into()))));
5985
5986    Value::Null
5987} }
5988
5989    fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5990        let mut params = get_arg(optional_args, 0, Value::Map({
5991    let mut m = indexmap::IndexMap::new();
5992    m
5993}));
5994        let mut balance: Value = self.fetch_balance(&[params]).await;
5995        return get_value(&balance, &part);
5996
5997    Value::Null
5998} }
5999
6000    fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6001        let mut params = get_arg(optional_args, 0, Value::Map({
6002    let mut m = indexmap::IndexMap::new();
6003    m
6004}));
6005        return self.fetch_partial_balance(Value::Str("free".into()), &[params]).await;
6006
6007    Value::Null
6008} }
6009
6010    fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6011        let mut params = get_arg(optional_args, 0, Value::Map({
6012    let mut m = indexmap::IndexMap::new();
6013    m
6014}));
6015        return self.fetch_partial_balance(Value::Str("used".into()), &[params]).await;
6016
6017    Value::Null
6018} }
6019
6020    fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6021        let mut params = get_arg(optional_args, 0, Value::Map({
6022    let mut m = indexmap::IndexMap::new();
6023    m
6024}));
6025        return self.fetch_partial_balance(Value::Str("total".into()), &[params]).await;
6026
6027    Value::Null
6028} }
6029
6030    fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6031        // async-virtual: try the derived exchange first
6032        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 {
6033            if !matches!(__v, crate::Value::Null) { return __v; }
6034        }
6035
6036        let mut params = get_arg(optional_args, 0, Value::Map({
6037    let mut m = indexmap::IndexMap::new();
6038    m
6039}));
6040        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchStatus() is not supported yet".into()))));
6041
6042    Value::Null
6043} }
6044
6045    fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6046        let mut params = get_arg(optional_args, 0, Value::Map({
6047    let mut m = indexmap::IndexMap::new();
6048    m
6049}));
6050        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)) {
6051            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFee() is not supported yet".into()))));
6052        }
6053        return self.fetch_transaction_fees(&[Value::from(vec![code]), params]).await;
6054
6055    Value::Null
6056} }
6057
6058    fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6059        let mut codes = get_arg(optional_args, 0, Value::Null);
6060        let mut params = get_arg(optional_args, 1, Value::Map({
6061    let mut m = indexmap::IndexMap::new();
6062    m
6063}));
6064        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFees() is not supported yet".into()))));
6065
6066    Value::Null
6067} }
6068
6069    fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6070        // async-virtual: try the derived exchange first
6071        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 {
6072            if !matches!(__v, crate::Value::Null) { return __v; }
6073        }
6074
6075        let mut codes = get_arg(optional_args, 0, Value::Null);
6076        let mut params = get_arg(optional_args, 1, Value::Map({
6077    let mut m = indexmap::IndexMap::new();
6078    m
6079}));
6080        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFees() is not supported yet".into()))));
6081
6082    Value::Null
6083} }
6084
6085    fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6086        // async-virtual: try the derived exchange first
6087        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 {
6088            if !matches!(__v, crate::Value::Null) { return __v; }
6089        }
6090
6091        let mut params = get_arg(optional_args, 0, Value::Map({
6092    let mut m = indexmap::IndexMap::new();
6093    m
6094}));
6095        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)) {
6096            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFee() is not supported yet".into()))));
6097        }
6098        let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::from(vec![code.clone()]), params]).await;
6099        return self.safe_dict(fees, code, &[]);
6100
6101    Value::Null
6102} }
6103
6104    fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
6105        let mut mapping = get_arg(optional_args, 0, Value::Map({
6106    let mut m = indexmap::IndexMap::new();
6107    m
6108}));
6109        if (key == Value::Null) {
6110            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" getSupportedMapping() requires a key argument".into()))));
6111        }
6112        if (matches!((&mapping, &key), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
6113            return mapping.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6114        }  else {
6115            let mut keys: Value = object_keys(&mapping);
6116            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()), Value::Str(keys.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(", ")).unwrap_or_default().into()))));
6117        }
6118
6119    Value::Null
6120}
6121
6122    fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6123        let mut params = get_arg(optional_args, 0, Value::Map({
6124    let mut m = indexmap::IndexMap::new();
6125    m
6126}));
6127        self.load_markets(&[]).await;
6128        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)) {
6129            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() is not supported yet".into()))));
6130        }
6131        let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params]).await;
6132        let mut rate: Value = self.safe_dict(borrowRates, code.clone(), &[]);
6133        if (rate == Value::Null) {
6134            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)));
6135        }
6136        return rate;
6137
6138    Value::Null
6139} }
6140
6141    fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6142        let mut params = get_arg(optional_args, 0, Value::Map({
6143    let mut m = indexmap::IndexMap::new();
6144    m
6145}));
6146        self.load_markets(&[]).await;
6147        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)) {
6148            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() is not supported yet".into()))));
6149        }
6150        let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params]).await;
6151        let mut rate: Value = self.safe_dict(borrowRates, symbol.clone(), &[]);
6152        if (rate == Value::Null) {
6153            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)));
6154        }
6155        return rate;
6156
6157    Value::Null
6158} }
6159
6160/* eslint-disable no-unused-vars */
6161/* eslint-enable no-unused-vars */
6162    fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
6163        let mut message = get_arg(optional_args, 0, Value::Null);
6164        if (value == Value::Null) {
6165            let mut errorMessage: Value = (if (message != Value::Null) { message } else { Value::Str("value is required".into()) });
6166            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), errorMessage)));
6167        }
6168        return value;
6169
6170    Value::Null
6171}
6172
6173/* eslint-disable no-unused-vars */
6174/* eslint-enable no-unused-vars */
6175    fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6176        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6177        // This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
6178        let mut defaultOptionName: Value = Value::Str(format!("{}{}", Value::Str("default".into()), self.capitalize(optionName.clone())).into()); // we also need to check the 'defaultXyzWhatever'
6179        // check if params contain the key
6180        let mut value: Value = self.safe_value2(params.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
6181        if (value != Value::Null) {
6182            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
6183            return Value::from(vec![value.clone(), paramsOmitted]);
6184        }  else {
6185            // handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
6186            let mut callerMethodNameparamsCallerMethodNameVariable = self.handle_param_string(params, Value::Str("callerMethodName".into()), &[methodName]);
6187            let mut callerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6188            let mut paramsCallerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6189            // check if exchange has properties for this method
6190            let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), callerMethodName, &[]);
6191            if (exchangeWideMethodOptions != Value::Null) {
6192                // check if the option is defined inside this method's props
6193                value = self.safe_value2(exchangeWideMethodOptions, optionName.clone(), defaultOptionName.clone(), &[]);
6194            }
6195            if (value == Value::Null) {
6196                // if it's still undefined, check if global exchange-wide option exists
6197                value = self.safe_value2(self.options.clone(), optionName, defaultOptionName, &[]);
6198            }
6199            // if it's still undefined, use the default value
6200            value = (if (value != Value::Null) { value.clone() } else { defaultValue });
6201            return Value::from(vec![value, paramsCallerMethodName]);
6202        }
6203
6204    Value::Null
6205}
6206
6207/* eslint-disable no-unused-vars */
6208/* eslint-enable no-unused-vars */
6209    fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6210        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6211        let mut valueparamsOption1Variable = self.handle_option_and_params(params, methodName1.clone(), optionName1, &[]);
6212        let mut value: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6213        let mut paramsOption1: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6214        if (value != Value::Null) {
6215            // omit optionName2 too from params
6216            let mut paramsOmitted: Value = self.omit(paramsOption1.clone(), optionName2.clone(), &[]);
6217            return Value::from(vec![value, paramsOmitted]);
6218        }
6219        return self.handle_option_and_params(paramsOption1, methodName1, optionName2, &[defaultValue]);
6220
6221    Value::Null
6222}
6223
6224/* eslint-disable no-unused-vars */
6225/* eslint-enable no-unused-vars */
6226    fn handle_option_string_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6227        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6228        // handleOptionAndParams read as a string; the statically typed ports throw on another type
6229        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6230        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6231        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6232        return Value::from(vec![self.check_option_string(methodName, optionName, value), newParams]);
6233
6234    Value::Null
6235}
6236
6237/* eslint-disable no-unused-vars */
6238/* eslint-enable no-unused-vars */
6239    fn handle_option_string_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6240        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6241        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6242        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6243        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6244        return Value::from(vec![self.check_option_string(methodName, optionName1, value), newParams]);
6245
6246    Value::Null
6247}
6248
6249/* eslint-disable no-unused-vars */
6250/* eslint-enable no-unused-vars */
6251    fn handle_option_bool_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6252        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6253        // handleOptionAndParams read as a boolean (see checkOptionBool)
6254        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6255        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6256        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6257        return Value::from(vec![self.check_option_bool(methodName, optionName, value), newParams]);
6258
6259    Value::Null
6260}
6261
6262/* eslint-disable no-unused-vars */
6263/* eslint-enable no-unused-vars */
6264    fn handle_option_bool_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6265        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6266        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6267        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6268        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6269        return Value::from(vec![self.check_option_bool(methodName, optionName1, value), newParams]);
6270
6271    Value::Null
6272}
6273
6274/* eslint-disable no-unused-vars */
6275/* eslint-enable no-unused-vars */
6276    fn handle_option_integer_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6277        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6278        // handleOptionAndParams read as an integer; the statically typed ports throw on another type
6279        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6280        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6281        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6282        return Value::from(vec![self.check_option_integer(methodName, optionName, value), newParams]);
6283
6284    Value::Null
6285}
6286
6287/* eslint-disable no-unused-vars */
6288/* eslint-enable no-unused-vars */
6289    fn handle_option_integer_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6290        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6291        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6292        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6293        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6294        return Value::from(vec![self.check_option_integer(methodName, optionName1, value), newParams]);
6295
6296    Value::Null
6297}
6298
6299    fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6300        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6301        let mut res: Value = self.handle_option_and_params(Value::Map({
6302    let mut m = indexmap::IndexMap::new();
6303    m
6304}), methodName, optionName, &[defaultValue]);
6305        return self.safe_value(res, Value::Int(0), &[]);
6306
6307    Value::Null
6308}
6309
6310    fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6311        let mut market = get_arg(optional_args, 0, Value::Null);
6312        let mut params = get_arg(optional_args, 1, Value::Map({
6313    let mut m = indexmap::IndexMap::new();
6314    m
6315}));
6316        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6317        /*
6318         * @ignore
6319         * @method
6320         * @name exchange#handleMarketTypeAndParams
6321         * @param methodName the method calling handleMarketTypeAndParams
6322         * @param {Market} market
6323         * @param {object} params
6324         * @param {string} [params.type] type assigned by user
6325         * @param {string} [params.defaultType] same as params.type
6326         * @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
6327         * @returns {[string, object]} the market type and params with type and defaultType omitted
6328         */
6329        // type from param
6330        let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6331        if (type_var != Value::Null) {
6332            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("defaultType".into()), Value::Str("type".into())]), &[]);
6333            return Value::from(vec![type_var, paramsOmitted]);
6334        }
6335        // type from market
6336        if (market != Value::Null) {
6337            return Value::from(vec![market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), params.clone()]);
6338        }
6339        // type from default-argument
6340        if (defaultValue != Value::Null) {
6341            return Value::from(vec![defaultValue, params.clone()]);
6342        }
6343        let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName, &[]);
6344        if (methodOptions != Value::Null) {
6345            if matches!(&methodOptions, Value::Str(_)) {
6346                return Value::from(vec![methodOptions.clone(), params.clone()]);
6347            }  else {
6348                let mut typeFromMethod: Value = self.safe_string2(methodOptions, Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6349                if (typeFromMethod != Value::Null) {
6350                    return Value::from(vec![typeFromMethod, params.clone()]);
6351                }
6352            }
6353        }
6354        let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[Value::Str("spot".into())]);
6355        return Value::from(vec![defaultType, params]);
6356
6357    Value::Null
6358}
6359
6360    fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6361        let mut market = get_arg(optional_args, 0, Value::Null);
6362        let mut params = get_arg(optional_args, 1, Value::Map({
6363    let mut m = indexmap::IndexMap::new();
6364    m
6365}));
6366        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6367        let mut subType: Value = Value::Null;
6368        // if set in params, it takes precedence
6369        let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".into()), Value::Str("defaultSubType".into()), &[]);
6370        // avoid omitting if it's not present
6371        if (subTypeInParams != Value::Null) {
6372            if (subTypeInParams.as_str() == Some("linear")) || (subTypeInParams.as_str() == Some("inverse")) {
6373                subType = subTypeInParams;
6374            }
6375            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("subType".into()), Value::Str("defaultSubType".into())]), &[]);
6376            return Value::from(vec![subType.clone(), paramsOmitted]);
6377        }  else {
6378            // at first, check from market object
6379            if (market != Value::Null) {
6380                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6381                    subType = Value::Str("linear".into());
6382                }  else if (market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6383                    subType = Value::Str("inverse".into());
6384                }
6385            }
6386            // if it was not defined in market object
6387            if (subType == Value::Null) {
6388                let mut values: Value = self.handle_option_and_params(Value::Map({
6389    let mut m = indexmap::IndexMap::new();
6390    m
6391}), methodName, Value::Str("subType".into()), &[defaultValue]); // no need to re-test params here
6392                subType = values.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6393            }
6394        }
6395        return Value::from(vec![subType, params]);
6396
6397    Value::Null
6398}
6399
6400    fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6401        let mut params = get_arg(optional_args, 0, Value::Map({
6402    let mut m = indexmap::IndexMap::new();
6403    m
6404}));
6405        let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6406        return self.handle_option_string_and_params(params, methodName, Value::Str("marginMode".into()), &[defaultValue]);
6407
6408    Value::Null
6409}
6410
6411    fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6412        if (string == Value::Null) {
6413            return;
6414        }
6415        if (in_op(&exact, &string)) {
6416            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
6417        }
6418}
6419
6420    fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6421        let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string);
6422        if (broadKey != Value::Null) {
6423            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
6424        }
6425}
6426
6427    fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6428        // a helper for matching error strings exactly vs broadly
6429        let mut keys: Value = object_keys(&broad);
6430        {
6431                        let mut i: Value = Value::Int(0);
6432            let mut __for_first_137: bool = true;
6433            while { if !__for_first_137 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_137 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
6434            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);
6435            if (string != Value::Null) {
6436                if Value::Int(string.as_str().zip(key.as_str()).and_then(|(__s, __n)| __s.find(__n)).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
6437                    return key;
6438                }
6439            }
6440        }
6441        }
6442        return Value::Null;
6443
6444    Value::Null
6445}
6446
6447    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 {
6448        // virtual-dispatch (static: DerivedExchange::handle_errors(self, ...))
6449        { 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; } }
6450
6451        return Value::Null;
6452
6453    Value::Null
6454}
6455
6456    fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6457        let mut config = get_arg(optional_args, 0, Value::Map({
6458    let mut m = indexmap::IndexMap::new();
6459    m
6460}));
6461        let __config_empty = indexmap::IndexMap::new();
6462        let config = config.as_map().unwrap_or(&__config_empty);
6463        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) });
6464
6465    Value::Null
6466}
6467
6468    fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6469        let mut symbols = get_arg(optional_args, 0, Value::Null);
6470        let mut params = get_arg(optional_args, 1, Value::Map({
6471    let mut m = indexmap::IndexMap::new();
6472    m
6473}));
6474        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotTickers() is not supported yet".into()))));
6475
6476    Value::Null
6477} }
6478
6479    fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6480        let mut symbols = get_arg(optional_args, 0, Value::Null);
6481        let mut params = get_arg(optional_args, 1, Value::Map({
6482    let mut m = indexmap::IndexMap::new();
6483    m
6484}));
6485        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractTickers() is not supported yet".into()))));
6486
6487    Value::Null
6488} }
6489
6490    fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6491        let mut symbols = get_arg(optional_args, 0, Value::Null);
6492        let mut limit = get_arg(optional_args, 1, Value::Null);
6493        let mut params = get_arg(optional_args, 2, Value::Map({
6494    let mut m = indexmap::IndexMap::new();
6495    m
6496}));
6497        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBooks() is not supported yet".into()))));
6498
6499    Value::Null
6500} }
6501
6502    fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6503        let mut symbols = get_arg(optional_args, 0, Value::Null);
6504        let mut params = get_arg(optional_args, 1, Value::Map({
6505    let mut m = indexmap::IndexMap::new();
6506    m
6507}));
6508        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTickers() is not supported yet".into()))));
6509
6510    Value::Null
6511} }
6512
6513    fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6514        let mut params = get_arg(optional_args, 0, Value::Map({
6515    let mut m = indexmap::IndexMap::new();
6516    m
6517}));
6518        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRate() is not supported yet".into()))));
6519
6520    Value::Null
6521} }
6522
6523    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 {
6524        let mut params = get_arg(optional_args, 0, Value::Map({
6525    let mut m = indexmap::IndexMap::new();
6526    m
6527}));
6528        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTwapOrder() is not supported yet".into()))));
6529
6530    Value::Null
6531} }
6532
6533    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 {
6534        let mut amount = get_arg(optional_args, 0, Value::Null);
6535        let mut params = get_arg(optional_args, 1, Value::Map({
6536    let mut m = indexmap::IndexMap::new();
6537    m
6538}));
6539        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() is not supported yet".into()))));
6540
6541    Value::Null
6542} }
6543
6544    fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6545        let mut code = get_arg(optional_args, 0, Value::Null);
6546        let mut params = get_arg(optional_args, 1, Value::Map({
6547    let mut m = indexmap::IndexMap::new();
6548    m
6549}));
6550        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTrade() is not supported yet".into()))));
6551
6552    Value::Null
6553} }
6554
6555    fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6556        let mut code = get_arg(optional_args, 0, Value::Null);
6557        let mut since = get_arg(optional_args, 1, Value::Null);
6558        let mut limit = get_arg(optional_args, 2, Value::Null);
6559        let mut params = get_arg(optional_args, 3, Value::Map({
6560    let mut m = indexmap::IndexMap::new();
6561    m
6562}));
6563        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTradeHistory() is not supported yet".into()))));
6564
6565    Value::Null
6566} }
6567
6568    fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6569        // async-virtual: try the derived exchange first
6570        if let Some(__v) = self.dispatch_to_derived("fetch_position_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
6571            if !matches!(__v, crate::Value::Null) { return __v; }
6572        }
6573
6574        let mut symbol = get_arg(optional_args, 0, Value::Null);
6575        let mut params = get_arg(optional_args, 1, 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(" fetchPositionMode() is not supported yet".into()))));
6580
6581    Value::Null
6582} }
6583
6584    fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6585        let mut params = get_arg(optional_args, 0, Value::Map({
6586    let mut m = indexmap::IndexMap::new();
6587    m
6588}));
6589        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchADLRank() is not supported yet".into()))));
6590
6591    Value::Null
6592} }
6593
6594    fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6595        // async-virtual: try the derived exchange first
6596        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 {
6597            if !matches!(__v, crate::Value::Null) { return __v; }
6598        }
6599
6600        let mut symbols = get_arg(optional_args, 0, Value::Null);
6601        let mut params = get_arg(optional_args, 1, Value::Map({
6602    let mut m = indexmap::IndexMap::new();
6603    m
6604}));
6605        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6606
6607    Value::Null
6608} }
6609
6610    fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6611        // async-virtual: try the derived exchange first
6612        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 {
6613            if !matches!(__v, crate::Value::Null) { return __v; }
6614        }
6615
6616        let mut params = get_arg(optional_args, 0, Value::Map({
6617    let mut m = indexmap::IndexMap::new();
6618    m
6619}));
6620        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)) {
6621            self.load_markets(&[]).await;
6622            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
6623            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
6624            let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::from(vec![symbolResolved.clone()]), params]).await;
6625            let mut rank: Value = self.safe_dict(ranks, Value::Int(0), &[]);
6626            if (rank == Value::Null) {
6627                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)));
6628            }  else {
6629                return rank;
6630            }
6631        }  else {
6632            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6633        }
6634
6635    Value::Null
6636} }
6637
6638    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 {
6639        let mut price = get_arg(optional_args, 0, Value::Null);
6640        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6641        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6642        let mut params = get_arg(optional_args, 3, Value::Map({
6643    let mut m = indexmap::IndexMap::new();
6644    m
6645}));
6646        if (takeProfit == Value::Null) && (stopLoss == Value::Null) {
6647            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".into()))));
6648        }
6649        if (takeProfit != Value::Null) {
6650            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), Value::Map({
6651    let mut m = indexmap::IndexMap::new();
6652        m.insert("triggerPrice".to_string(), takeProfit);
6653    m
6654})); }
6655        }
6656        if (stopLoss != Value::Null) {
6657            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), Value::Map({
6658    let mut m = indexmap::IndexMap::new();
6659        m.insert("triggerPrice".to_string(), stopLoss);
6660    m
6661})); }
6662        }
6663        let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
6664        let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
6665        let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
6666        let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
6667        let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
6668        let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
6669        let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
6670        let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
6671        if (takeProfitType != Value::Null) {
6672            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("type".into()), takeProfitType);
6673        }
6674        if (takeProfitPriceType != Value::Null) {
6675            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("priceType".into()), takeProfitPriceType);
6676        }
6677        if (takeProfitLimitPrice != Value::Null) {
6678            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("price".into()), self.parse_to_numeric(takeProfitLimitPrice));
6679        }
6680        if (takeProfitAmount != Value::Null) {
6681            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("amount".into()), self.parse_to_numeric(takeProfitAmount));
6682        }
6683        if (stopLossType != Value::Null) {
6684            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("type".into()), stopLossType);
6685        }
6686        if (stopLossPriceType != Value::Null) {
6687            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("priceType".into()), stopLossPriceType);
6688        }
6689        if (stopLossLimitPrice != Value::Null) {
6690            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("price".into()), self.parse_to_numeric(stopLossLimitPrice));
6691        }
6692        if (stopLossAmount != Value::Null) {
6693            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("amount".into()), self.parse_to_numeric(stopLossAmount));
6694        }
6695        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())]), &[]);
6696        return paramsOmitted;
6697
6698    Value::Null
6699}
6700
6701    fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6702        let mut params = get_arg(optional_args, 0, Value::Map({
6703    let mut m = indexmap::IndexMap::new();
6704    m
6705}));
6706        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSpotOrders() is not supported yet".into()))));
6707
6708    Value::Null
6709} }
6710
6711    fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6712        let mut params = get_arg(optional_args, 0, Value::Map({
6713    let mut m = indexmap::IndexMap::new();
6714    m
6715}));
6716        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createContractOrders() is not supported yet".into()))));
6717
6718    Value::Null
6719} }
6720
6721    fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6722        let mut symbol = get_arg(optional_args, 0, Value::Null);
6723        let mut params = get_arg(optional_args, 1, Value::Map({
6724    let mut m = indexmap::IndexMap::new();
6725    m
6726}));
6727        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelSpotOrder() is not supported yet".into()))));
6728
6729    Value::Null
6730} }
6731
6732    fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6733        let mut symbol = get_arg(optional_args, 0, Value::Null);
6734        let mut params = get_arg(optional_args, 1, Value::Map({
6735    let mut m = indexmap::IndexMap::new();
6736    m
6737}));
6738        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelContractOrder() is not supported yet".into()))));
6739
6740    Value::Null
6741} }
6742
6743    fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6744        let mut symbol = get_arg(optional_args, 0, Value::Null);
6745        let mut params = get_arg(optional_args, 1, Value::Map({
6746    let mut m = indexmap::IndexMap::new();
6747    m
6748}));
6749        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllSpotOrders() is not supported yet".into()))));
6750
6751    Value::Null
6752} }
6753
6754    fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6755        let mut symbol = get_arg(optional_args, 0, Value::Null);
6756        let mut params = get_arg(optional_args, 1, Value::Map({
6757    let mut m = indexmap::IndexMap::new();
6758    m
6759}));
6760        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllContractOrders() is not supported yet".into()))));
6761
6762    Value::Null
6763} }
6764
6765    fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6766        let mut params = get_arg(optional_args, 0, Value::Map({
6767    let mut m = indexmap::IndexMap::new();
6768    m
6769}));
6770        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersAfter() is not supported yet".into()))));
6771
6772    Value::Null
6773} }
6774
6775    fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6776        let mut params = get_arg(optional_args, 0, Value::Map({
6777    let mut m = indexmap::IndexMap::new();
6778    m
6779}));
6780        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersForSymbols() is not supported yet".into()))));
6781
6782    Value::Null
6783} }
6784
6785    fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6786        let mut symbol = get_arg(optional_args, 0, Value::Null);
6787        let mut since = get_arg(optional_args, 1, Value::Null);
6788        let mut limit = get_arg(optional_args, 2, Value::Null);
6789        let mut params = get_arg(optional_args, 3, Value::Map({
6790    let mut m = indexmap::IndexMap::new();
6791    m
6792}));
6793        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() is not supported yet".into()))));
6794
6795    Value::Null
6796} }
6797
6798    fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6799        let mut since = get_arg(optional_args, 0, Value::Null);
6800        let mut limit = get_arg(optional_args, 1, Value::Null);
6801        let mut params = get_arg(optional_args, 2, Value::Map({
6802    let mut m = indexmap::IndexMap::new();
6803    m
6804}));
6805        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLiquidations() is not supported yet".into()))));
6806
6807    Value::Null
6808} }
6809
6810    fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6811        let mut params = get_arg(optional_args, 0, Value::Map({
6812    let mut m = indexmap::IndexMap::new();
6813    m
6814}));
6815        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchGreeks() is not supported yet".into()))));
6816
6817    Value::Null
6818} }
6819
6820    fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6821        let mut symbols = get_arg(optional_args, 0, Value::Null);
6822        let mut params = get_arg(optional_args, 1, Value::Map({
6823    let mut m = indexmap::IndexMap::new();
6824    m
6825}));
6826        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAllGreeks() is not supported yet".into()))));
6827
6828    Value::Null
6829} }
6830
6831    fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6832        let mut params = get_arg(optional_args, 0, Value::Map({
6833    let mut m = indexmap::IndexMap::new();
6834    m
6835}));
6836        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOptionChain() is not supported yet".into()))));
6837
6838    Value::Null
6839} }
6840
6841    fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6842        let mut params = get_arg(optional_args, 0, Value::Map({
6843    let mut m = indexmap::IndexMap::new();
6844    m
6845}));
6846        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOption() is not supported yet".into()))));
6847
6848    Value::Null
6849} }
6850
6851    fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6852        let mut amount = get_arg(optional_args, 0, Value::Null);
6853        let mut params = get_arg(optional_args, 1, Value::Map({
6854    let mut m = indexmap::IndexMap::new();
6855    m
6856}));
6857        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertQuote() is not supported yet".into()))));
6858
6859    Value::Null
6860} }
6861
6862    fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6863        // async-virtual: try the derived exchange first
6864        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 {
6865            if !matches!(__v, crate::Value::Null) { return __v; }
6866        }
6867
6868        let mut code = get_arg(optional_args, 0, Value::Null);
6869        let mut since = get_arg(optional_args, 1, Value::Null);
6870        let mut limit = get_arg(optional_args, 2, Value::Null);
6871        let mut params = get_arg(optional_args, 3, Value::Map({
6872    let mut m = indexmap::IndexMap::new();
6873    m
6874}));
6875        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWithdrawals() is not supported yet".into()))));
6876
6877    Value::Null
6878} }
6879
6880    fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6881        // async-virtual: try the derived exchange first
6882        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 {
6883            if !matches!(__v, crate::Value::Null) { return __v; }
6884        }
6885
6886        let mut code = get_arg(optional_args, 0, Value::Null);
6887        let mut since = get_arg(optional_args, 1, Value::Null);
6888        let mut limit = get_arg(optional_args, 2, Value::Null);
6889        let mut params = get_arg(optional_args, 3, Value::Map({
6890    let mut m = indexmap::IndexMap::new();
6891    m
6892}));
6893        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposits() is not supported yet".into()))));
6894
6895    Value::Null
6896} }
6897
6898    fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6899        // async-virtual: try the derived exchange first
6900        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 {
6901            if !matches!(__v, crate::Value::Null) { return __v; }
6902        }
6903
6904        let mut code = get_arg(optional_args, 0, Value::Null);
6905        let mut since = get_arg(optional_args, 1, Value::Null);
6906        let mut limit = get_arg(optional_args, 2, Value::Null);
6907        let mut params = get_arg(optional_args, 3, Value::Map({
6908    let mut m = indexmap::IndexMap::new();
6909    m
6910}));
6911        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawals() is not supported yet".into()))));
6912
6913    Value::Null
6914} }
6915
6916    fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6917        let mut code = get_arg(optional_args, 0, Value::Null);
6918        let mut since = get_arg(optional_args, 1, Value::Null);
6919        let mut limit = get_arg(optional_args, 2, Value::Null);
6920        let mut params = get_arg(optional_args, 3, Value::Map({
6921    let mut m = indexmap::IndexMap::new();
6922    m
6923}));
6924        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWs() is not supported yet".into()))));
6925
6926    Value::Null
6927} }
6928
6929    fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6930        let mut code = get_arg(optional_args, 0, Value::Null);
6931        let mut since = get_arg(optional_args, 1, Value::Null);
6932        let mut limit = get_arg(optional_args, 2, Value::Null);
6933        let mut params = get_arg(optional_args, 3, Value::Map({
6934    let mut m = indexmap::IndexMap::new();
6935    m
6936}));
6937        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawalsWs() is not supported yet".into()))));
6938
6939    Value::Null
6940} }
6941
6942    fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6943        // async-virtual: try the derived exchange first
6944        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 {
6945            if !matches!(__v, crate::Value::Null) { return __v; }
6946        }
6947
6948        let mut symbol = get_arg(optional_args, 0, Value::Null);
6949        let mut since = get_arg(optional_args, 1, Value::Null);
6950        let mut limit = get_arg(optional_args, 2, Value::Null);
6951        let mut params = get_arg(optional_args, 3, Value::Map({
6952    let mut m = indexmap::IndexMap::new();
6953    m
6954}));
6955        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() is not supported yet".into()))));
6956
6957    Value::Null
6958} }
6959
6960    fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6961        let mut symbol = get_arg(optional_args, 0, Value::Null);
6962        let mut since = get_arg(optional_args, 1, Value::Null);
6963        let mut limit = get_arg(optional_args, 2, Value::Null);
6964        let mut params = get_arg(optional_args, 3, Value::Map({
6965    let mut m = indexmap::IndexMap::new();
6966    m
6967}));
6968        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() is not supported yet".into()))));
6969
6970    Value::Null
6971} }
6972
6973    fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
6974        // virtual-dispatch (static: DerivedExchange::parse_last_price(self, ...))
6975        { 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; } }
6976
6977        let mut market = get_arg(optional_args, 0, Value::Null);
6978        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLastPrice() is not supported yet".into()))));
6979
6980    Value::Null
6981}
6982
6983    fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6984        // async-virtual: try the derived exchange first
6985        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 {
6986            if !matches!(__v, crate::Value::Null) { return __v; }
6987        }
6988
6989        let mut params = get_arg(optional_args, 0, Value::Map({
6990    let mut m = indexmap::IndexMap::new();
6991    m
6992}));
6993        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)) {
6994            let mut depositAddressesList: Value = self.fetch_deposit_addresses(&[Value::from(vec![code.clone()]), params.clone()]).await;
6995            let mut depositAddresses: Value = self.index_by(depositAddressesList, Value::Str("currency".into()));
6996            if (self.safe_dict(depositAddresses.clone(), code.clone(), &[]) == Value::Null) {
6997                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()))));
6998            }
6999            return self.safe_dict(depositAddresses, code.clone(), &[]);
7000        }  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)) {
7001            let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
7002            let mut paramsOmitted: Value = self.omit(params, Value::Str("network".into()), &[]);
7003            let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code, &[paramsOmitted]).await;
7004            if (network != Value::Null) {
7005                return self.safe_dict(addressStructures.clone(), network, &[]);
7006            }  else {
7007                let mut keys: Value = object_keys(&addressStructures);
7008                let mut key: Value = keys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
7009                return self.safe_dict(addressStructures, key, &[]);
7010            }
7011        }  else {
7012            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() is not supported yet".into()))));
7013        }
7014
7015    Value::Null
7016} }
7017
7018    fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7019        let mut params = get_arg(optional_args, 0, Value::Map({
7020    let mut m = indexmap::IndexMap::new();
7021    m
7022}));
7023        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractDepositAddress() is not supported yet".into()))));
7024
7025    Value::Null
7026} }
7027
7028    fn account(&self) -> Value {
7029        return Value::Map({
7030    let mut m = indexmap::IndexMap::new();
7031        m.insert("free".to_string(), Value::Null);
7032        m.insert("used".to_string(), Value::Null);
7033        m.insert("total".to_string(), Value::Null);
7034    m
7035});
7036
7037    Value::Null
7038}
7039
7040/*
7041 * @ignore
7042 * @method
7043 * @description merges a per-market (isolated margin) account into a flat code-keyed balance dict, summing string fields when the code recurs across markets
7044 * @param {object} result the code-keyed balance dict being built
7045 * @param {string} code unified currency code
7046 * @param {object} account a balance account with string free/used/total/debt
7047 * @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
7048 */
7049    fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
7050        if !(matches!((&result, &code), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7051            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
7052            return result;
7053        }
7054        let mut fields: Value = Value::from(vec![Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into()), Value::Str("debt".into())]);
7055        {
7056                        let mut i: Value = Value::Int(0);
7057            let mut __for_first_138: bool = true;
7058            while { if !__for_first_138 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_138 = false; i.as_f64().unwrap_or(f64::NAN) < ((fields.len() as i64) as f64) } {
7059            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);
7060            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(), &[]);
7061            let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
7062            if (current == Value::Null) {
7063                add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
7064            }  else if (incoming != Value::Null) {
7065                add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(&current, &incoming));
7066            }
7067        }
7068        }
7069        return result;
7070
7071    Value::Null
7072}
7073
7074    fn common_currency_code(&self, mut code: Value) -> Value {
7075        if !(self.substituteCommonCurrencyCodes.as_bool() == Some(true)) {
7076            return code;
7077        }
7078        return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
7079
7080    Value::Null
7081}
7082
7083    fn currency(&self, mut code: Value) -> Value {
7084        if (code == Value::Null) {
7085            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currency() requires a code argument".into()))));
7086        }
7087        let mut keys: Value = Value::Array(self.currencies.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
7088        let mut numCurrencies: f64 = ((keys.len() as i64) as f64);
7089        if (numCurrencies == 0.0) {
7090            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" currencies not loaded".into()))));
7091        }
7092        if matches!(&code, Value::Str(_)) {
7093            let mut currencies: Value = self.currencies.clone();
7094            let mut currenciesById: Value = self.currencies_by_id.clone();
7095            if (matches!((&currencies, &code), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7096                return currencies.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
7097            }  else if (currenciesById != Value::Null) && (matches!((&currenciesById, &code), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7098                return currenciesById.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
7099            }
7100        }
7101        panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have currency code ".into())).into()), code)));
7102
7103    Value::Null
7104}
7105
7106    fn market(&self, mut symbol: Value) -> Value {
7107        // virtual-dispatch (static: DerivedExchange::market(self, ...))
7108        { let __v = crate::exchange::DerivedExchange::market(self, symbol.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
7109        self.market_non_virtual(symbol)
7110    }
7111
7112    fn market_non_virtual(&self, mut symbol: Value) -> Value {
7113        if (symbol == Value::Null) {
7114            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" market() requires a symbol argument".into()))));
7115        }
7116        let mut markets: Value = self.markets.clone();
7117        if (markets == Value::Null) {
7118            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
7119        }
7120        let mut marketsById: Value = self.markets_by_id.clone();
7121        if (matches!((&markets, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7122            return get_value(&markets, &symbol);
7123        }  else if (marketsById != Value::Null) && (matches!((&marketsById, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7124            let mut marketsList: Value = get_value(&marketsById, &symbol);
7125            let mut marketsList: Value = get_value(&marketsById, &symbol);
7126            let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("defaultSubType".into()), &[Value::Str("spot".into())]);
7127            {
7128                                let mut i: Value = Value::Int(0);
7129                let mut __for_first_139: bool = true;
7130                while { if !__for_first_139 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_139 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&marketsList).as_f64().unwrap_or(f64::NAN) } {
7131                let mut market: Value = get_value(&marketsList, &i);
7132                let mut market: Value = get_value(&marketsList, &i);
7133                if (match &(get_value(&market, &defaultType)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
7134                    return market;
7135                }
7136            }
7137            }
7138            return get_value(&marketsList, &Value::Int(0));
7139        }  else if (symbol.as_str().is_some_and(|__s| __s.ends_with("-C"))) || (symbol.as_str().is_some_and(|__s| __s.ends_with("-P"))) || (symbol.as_str().is_some_and(|__s| __s.starts_with("C-"))) || (symbol.as_str().is_some_and(|__s| __s.starts_with("P-"))) {
7140            return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
7141        }
7142        panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have market symbol ".into())).into()), symbol)));
7143
7144    Value::Null
7145}
7146
7147    fn create_expired_option_market(&self, mut symbol: Value) -> Value {
7148        // virtual-dispatch (static: DerivedExchange::create_expired_option_market(self, ...))
7149        { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol); if !matches!(__v, crate::Value::Null) { return __v; } }
7150
7151        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createExpiredOptionMarket () is not supported yet".into()))));
7152
7153    Value::Null
7154}
7155
7156    fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
7157        let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
7158        let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
7159        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())]);
7160        {
7161                        let mut i: Value = Value::Int(0);
7162            let mut __for_first_140: bool = true;
7163            while { if !__for_first_140 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_140 = false; i.as_f64().unwrap_or(f64::NAN) < ((leverageSuffixes.len() as i64) as f64) } {
7164            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);
7165            let mut endsWithSuffix: bool = ends_with(&currencyCode, &leverageSuffix);
7166            if endsWithSuffix {
7167                if !(checkBaseCoin.as_bool() == Some(true)) {
7168                    return Value::Bool(true);
7169                }  else {
7170                    // check if base currency is inside dict
7171                    let mut baseCurrencyCode: Value = replace_str(&currencyCode, &leverageSuffix, &Value::Str("".into()));
7172                    if (existingCurrencies != Value::Null) && (matches!((&existingCurrencies, &baseCurrencyCode), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7173                        return Value::Bool(true);
7174                    }
7175                }
7176            }
7177        }
7178        }
7179        return Value::Bool(false);
7180
7181    Value::Null
7182}
7183
7184    fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
7185        if (cost == Value::Null) {
7186            return Value::Null;
7187        }
7188        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7189        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()]);
7190
7191    Value::Null
7192}
7193
7194    fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
7195        if (price == Value::Null) {
7196            return Value::Null;
7197        }
7198        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7199        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()]);
7200        if (result.as_str() == Some("0")) {
7201            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));
7202            if (pricePrecision == Value::Null) {
7203                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()))));
7204            }
7205            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)));
7206        }
7207        return result;
7208
7209    Value::Null
7210}
7211
7212    fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
7213        if (amount == Value::Null) {
7214            return Value::Null;
7215        }
7216        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7217        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()]);
7218        if (result.as_str() == Some("0")) {
7219            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));
7220            if (amountPrecision == Value::Null) {
7221                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()))));
7222            }
7223            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)));
7224        }
7225        return result;
7226
7227    Value::Null
7228}
7229
7230    fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
7231        if (fee == Value::Null) {
7232            return Value::Null;
7233        }
7234        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7235        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()]);
7236
7237    Value::Null
7238}
7239
7240    fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
7241        let mut networkCode = get_arg(optional_args, 0, Value::Null);
7242        if (code == Value::Null) {
7243            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currencyToPrecision() requires a code argument".into()))));
7244        }
7245        let mut currency: Value = self.currencies.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
7246        let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
7247        if (networkCode != Value::Null) {
7248            let mut networks: Value = self.safe_dict_k(currency, "networks", &[Value::Map({
7249    let mut m = indexmap::IndexMap::new();
7250    m
7251})]);
7252            let mut networkItem: Value = self.safe_dict(networks, networkCode, &[Value::Map({
7253    let mut m = indexmap::IndexMap::new();
7254    m
7255})]);
7256            precision = self.safe_value_k(networkItem, "precision", &[precision.clone()]);
7257        }
7258        if (precision == Value::Null) {
7259            return self.force_string(fee.clone());
7260        }  else {
7261            let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
7262            return self.decimal_to_precision(fee, roundingMode, precision, &[self.precisionMode.clone(), self.paddingMode.clone()]);
7263        }
7264
7265    Value::Null
7266}
7267
7268    fn force_string(&self, mut value: Value) -> Value {
7269        if !matches!(&value, Value::Str(_)) {
7270            return self.number_to_string(value.clone());
7271        }
7272        return value;
7273
7274    Value::Null
7275}
7276
7277    fn is_tick_precision(&self) -> Value {
7278        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64());
7279
7280    Value::Null
7281}
7282
7283    fn is_significant_precision(&self) -> Value {
7284        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::SIGNIFICANT_DIGITS).as_f64());
7285
7286    Value::Null
7287}
7288
7289    fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
7290        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7291        let mut value: Value = self.safe_string(obj, key, &[]);
7292        return self.parse_number(value, &[defaultNumber]);
7293
7294    Value::Null
7295}
7296
7297    fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
7298        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7299        let mut value: Value = self.safe_string_n(obj, arr, &[]);
7300        return self.parse_number(value, &[defaultNumber]);
7301
7302    Value::Null
7303}
7304
7305    fn parse_precision(&self, optional_args: &[Value]) -> Value {
7306        let mut precision = get_arg(optional_args, 0, Value::Null);
7307        /*
7308         * @ignore
7309         * @method
7310         * @param {string} precision The number of digits to the right of the decimal
7311         * @returns {string} a string number equal to 1e-precision
7312         */
7313        if (precision == Value::Null) {
7314            return Value::Null;
7315        }
7316        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 });
7317        if (precisionNumber.as_f64() == Some(0.0)) {
7318            return Value::Str("1".into());
7319        }
7320        if precisionNumber.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
7321            let mut parsedPrecision: Value = Value::Str("0.".into());
7322            {
7323                                let mut i: Value = Value::Int(0);
7324                let mut __for_first_141: bool = true;
7325                while { if !__for_first_141 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_141 = 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) } {
7326                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7327            }
7328            }
7329            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("1".into())).into());
7330        }  else {
7331            let mut parsedPrecision: Value = Value::Str("1".into());
7332            {
7333                                let mut i: Value = Value::Int(0);
7334                let mut __for_first_142: bool = true;
7335                while { if !__for_first_142 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_142 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(Value::Int(-1)), &(precisionNumber)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (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) } {
7336                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7337            }
7338            }
7339            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7340        }
7341
7342    Value::Null
7343}
7344
7345    fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7346        /*
7347         * @ignore
7348         * @method
7349         * @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
7350         * @param {string} precision The number of digits to the right of the decimal
7351         * @returns {string} a string number equal to 1e-precision
7352         */
7353        if (precision == Value::Null) {
7354            return Value::Null;
7355        }
7356        if crate::precise::Precise::stringGe(&precision, &Value::Str("0".into())).as_bool() == Some(true) {
7357            return self.parse_precision(&[precision.clone()]);
7358        }  else {
7359            let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7360            if (positivePrecisionString == Value::Null) {
7361                return Value::Null;
7362            }
7363            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 });
7364            let mut parsedPrecision: Value = Value::Str("1".into());
7365            {
7366                                let mut i: Value = Value::Int(0);
7367                let mut __for_first_143: bool = true;
7368                while { if !__for_first_143 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_143 = 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) } {
7369                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7370            }
7371            }
7372            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7373        }
7374}
7375
7376    fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7377        let mut params = get_arg(optional_args, 0, Value::Map({
7378    let mut m = indexmap::IndexMap::new();
7379    m
7380}));
7381        let mut serverTime: Value = self.fetch_time(&[params]).await;
7382        let mut after: Value = self.milliseconds();
7383        if (serverTime == Value::Null) {
7384            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" loadTimeDifference() missing serverTime".into()))));
7385        }
7386        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 })); }
7387        return self.parse_to_int(self.options.as_map().and_then(|__m| __m.get("timeDifference")).cloned().unwrap_or(Value::Null));
7388
7389    Value::Null
7390} }
7391
7392    fn implode_hostname(&self, mut url: Value) -> Value {
7393        return self.implode_params(url, Value::Map({
7394    let mut m = indexmap::IndexMap::new();
7395        m.insert("hostname".to_string(), self.hostname.clone());
7396    m
7397}));
7398
7399    Value::Null
7400}
7401
7402    fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7403        // async-virtual: try the derived exchange first
7404        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 {
7405            if !matches!(__v, crate::Value::Null) { return __v; }
7406        }
7407
7408        let mut params = get_arg(optional_args, 0, Value::Map({
7409    let mut m = indexmap::IndexMap::new();
7410    m
7411}));
7412        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)) {
7413            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
7414            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7415                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() supports contract markets only".into()))));
7416            }
7417            let mut tiers: Value = self.fetch_leverage_tiers(&[Value::from(vec![symbol.clone()])]).await;
7418            let mut marketTiers: Value = self.safe_list(tiers, symbol, &[]);
7419            return marketTiers;
7420        }  else {
7421            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() is not supported yet".into()))));
7422        }
7423
7424    Value::Null
7425} }
7426
7427    fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7428        let mut params = get_arg(optional_args, 0, Value::Map({
7429    let mut m = indexmap::IndexMap::new();
7430    m
7431}));
7432        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSubAccount() is not supported yet".into()))));
7433
7434    Value::Null
7435} }
7436
7437    fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7438        let mut currency = get_arg(optional_args, 0, Value::Null);
7439        let mut currencyResolved: Value = self.safe_currency(currencyId, &[currency]);
7440        return currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
7441
7442    Value::Null
7443}
7444
7445    fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7446        let mut symbol = get_arg(optional_args, 0, Value::Null);
7447        let mut since = get_arg(optional_args, 1, Value::Null);
7448        let mut limit = get_arg(optional_args, 2, Value::Null);
7449        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7450        return self.filter_by_value_since_limit(array, Value::Str("symbol".into()), &[symbol, since, limit, Value::Str("timestamp".into()), tail]);
7451
7452    Value::Null
7453}
7454
7455    fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7456        let mut code = get_arg(optional_args, 0, Value::Null);
7457        let mut since = get_arg(optional_args, 1, Value::Null);
7458        let mut limit = get_arg(optional_args, 2, Value::Null);
7459        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7460        return self.filter_by_value_since_limit(array, Value::Str("currency".into()), &[code, since, limit, Value::Str("timestamp".into()), tail]);
7461
7462    Value::Null
7463}
7464
7465    fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7466        let mut symbols = get_arg(optional_args, 0, Value::Null);
7467        let mut since = get_arg(optional_args, 1, Value::Null);
7468        let mut limit = get_arg(optional_args, 2, Value::Null);
7469        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7470        let mut result: Value = self.filter_by_array(array, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
7471        return self.filter_by_since_limit(result, &[since, limit, Value::Str("timestamp".into()), tail]);
7472
7473    Value::Null
7474}
7475
7476    fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7477        let mut symbols = get_arg(optional_args, 0, Value::Null);
7478        let mut params = get_arg(optional_args, 1, Value::Map({
7479    let mut m = indexmap::IndexMap::new();
7480    m
7481}));
7482        //
7483        // the value of tickers is either a dict or a list
7484        //
7485        // dict
7486        //
7487        //     {
7488        //         'marketId1': { ... },
7489        //         'marketId2': { ... },
7490        //         ...
7491        //     }
7492        //
7493        // list
7494        //
7495        //     [
7496        //         { 'market': 'marketId1', ... },
7497        //         { 'market': 'marketId2', ... },
7498        //         ...
7499        //     ]
7500        //
7501        let mut results: Vec<Value> = Vec::new();
7502        if (matches!(&pricesData, Value::Arr(_))) {
7503            {
7504                                let mut i: Value = Value::Int(0);
7505                let mut __for_first_144: bool = true;
7506                while { if !__for_first_144 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_144 = false; i.as_f64().unwrap_or(f64::NAN) < ((pricesData.len() as i64) as f64) } {
7507                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()]);
7508                results.push(priceData.clone());
7509            }
7510            }
7511        }  else {
7512            let mut marketIds: Value = object_keys(&pricesData);
7513            {
7514                                let mut i: Value = Value::Int(0);
7515                let mut __for_first_145: bool = true;
7516                while { if !__for_first_145 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_145 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
7517                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);
7518                let mut market: Value = self.safe_market(&[marketId.clone()]);
7519                let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market]), &[params.clone()]);
7520                results.push(priceData);
7521            }
7522            }
7523        }
7524        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7525        return self.index_by(self.filter_by_array(Value::from(results), Value::Str("symbol".into()), &[symbolsNormalized, Value::Bool(false)]), Value::Str("symbol".into()));
7526
7527    Value::Null
7528}
7529
7530    fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7531        let mut symbols = get_arg(optional_args, 0, Value::Null);
7532        let mut params = get_arg(optional_args, 1, Value::Map({
7533    let mut m = indexmap::IndexMap::new();
7534    m
7535}));
7536        //
7537        // the value of tickers is either a dict or a list
7538        //
7539        //
7540        // dict
7541        //
7542        //     {
7543        //         'marketId1': { ... },
7544        //         'marketId2': { ... },
7545        //         'marketId3': { ... },
7546        //         ...
7547        //     }
7548        //
7549        // list
7550        //
7551        //     [
7552        //         { 'market': 'marketId1', ... },
7553        //         { 'market': 'marketId2', ... },
7554        //         { 'market': 'marketId3', ... },
7555        //         ...
7556        //     ]
7557        //
7558        let mut results: Vec<Value> = Vec::new();
7559        if (matches!(&tickers, Value::Arr(_))) {
7560            {
7561                                let mut i: Value = Value::Int(0);
7562                let mut __for_first_146: bool = true;
7563                while { if !__for_first_146 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_146 = false; i.as_f64().unwrap_or(f64::NAN) < ((tickers.len() as i64) as f64) } {
7564                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), &[]);
7565                let mut ticker: Value = self.extend(parsedTicker, &[params.clone()]);
7566                results.push(ticker.clone());
7567            }
7568            }
7569        }  else {
7570            let mut marketIds: Value = object_keys(&tickers);
7571            {
7572                                let mut i: Value = Value::Int(0);
7573                let mut __for_first_147: bool = true;
7574                while { if !__for_first_147 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_147 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
7575                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);
7576                let mut market: Value = self.safe_market(&[marketId.clone()]);
7577                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market]);
7578                let mut ticker: Value = self.extend(parsed, &[params.clone()]);
7579                results.push(ticker);
7580            }
7581            }
7582        }
7583        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7584        return self.filter_by_array_tickers(Value::from(results), Value::Str("symbol".into()), &[symbolsNormalized]);
7585
7586    Value::Null
7587}
7588
7589    fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7590        let mut codes = get_arg(optional_args, 0, Value::Null);
7591        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7592        let mut params = get_arg(optional_args, 2, Value::Map({
7593    let mut m = indexmap::IndexMap::new();
7594    m
7595}));
7596        let mut result: Value = Value::from(vec![]);
7597        {
7598                        let mut i: Value = Value::Int(0);
7599            let mut __for_first_148: bool = true;
7600            while { if !__for_first_148 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_148 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&addresses).as_f64().unwrap_or(f64::NAN) } {
7601            let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7602            if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(address); }
7603        }
7604        }
7605        if (codes != Value::Null) {
7606            result = self.to_array(self.filter_by_array(result.clone(), Value::Str("currency".into()), &[codes, Value::Bool(false)]));
7607        }
7608        if indexed.as_bool() == Some(true) {
7609            result = self.to_array(self.filter_by_array(result.clone(), Value::Str("currency".into()), &[Value::Null, indexed]));
7610        }
7611        return result;
7612
7613    Value::Null
7614}
7615
7616    fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7617        let mut market = get_arg(optional_args, 0, Value::Null);
7618        let mut interests: Value = Value::from(vec![]);
7619        {
7620                        let mut i: Value = Value::Int(0);
7621            let mut __for_first_149: bool = true;
7622            while { if !__for_first_149 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_149 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7623            let mut row: Value = get_value(&response, &i);
7624            let mut row: Value = get_value(&response, &i);
7625            if let Value::Arr(__a) = &mut interests { std::sync::Arc::make_mut(__a).push(<Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row, &[market.clone()])); }
7626        }
7627        }
7628        return interests;
7629
7630    Value::Null
7631}
7632
7633    fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7634        // virtual-dispatch (static: DerivedExchange::parse_borrow_rate(self, ...))
7635        { 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; } }
7636
7637        let mut currency = get_arg(optional_args, 0, Value::Null);
7638        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowRate() is not supported yet".into()))));
7639
7640    Value::Null
7641}
7642
7643    fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7644        let mut result: Vec<Value> = Vec::new();
7645        {
7646                        let mut i: Value = Value::Int(0);
7647            let mut __for_first_150: bool = true;
7648            while { if !__for_first_150 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_150 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7649            let mut item: Value = get_value(&response, &i);
7650            let mut item: Value = get_value(&response, &i);
7651            let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item, &[]);
7652            result.push(borrowRate);
7653        }
7654        }
7655        let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
7656        return self.filter_by_currency_since_limit(sorted, &[code, since, limit]);
7657
7658    Value::Null
7659}
7660
7661    fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7662        let mut result: Value = Value::Map({
7663            let mut m = indexmap::IndexMap::new();
7664            m
7665        });
7666        {
7667                        let mut i: Value = Value::Int(0);
7668            let mut __for_first_151: bool = true;
7669            while { if !__for_first_151 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_151 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&info).as_f64().unwrap_or(f64::NAN) } {
7670            let mut item: Value = get_value(&info, &i);
7671            let mut item: Value = get_value(&info, &i);
7672            let mut borrowRate: Value = self.parse_isolated_borrow_rate(item, &[]);
7673            let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
7674            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), borrowRate); }
7675        }
7676        }
7677        return result;
7678
7679    Value::Null
7680}
7681
7682    fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7683        let mut market = get_arg(optional_args, 0, Value::Null);
7684        let mut since = get_arg(optional_args, 1, Value::Null);
7685        let mut limit = get_arg(optional_args, 2, Value::Null);
7686        let mut rates: Vec<Value> = Vec::new();
7687        {
7688                        let mut i: Value = Value::Int(0);
7689            let mut __for_first_152: bool = true;
7690            while { if !__for_first_152 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_152 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7691            let mut entry: Value = get_value(&response, &i);
7692            let mut entry: Value = get_value(&response, &i);
7693            rates.push(<Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry, &[market.clone()]));
7694        }
7695        }
7696        let mut sorted: Value = self.sort_by(Value::from(rates), Value::Str("timestamp".into()), &[]);
7697        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) });
7698        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7699
7700    Value::Null
7701}
7702
7703    fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7704        let mut market = get_arg(optional_args, 0, Value::Null);
7705        let mut delimiter = get_arg(optional_args, 1, Value::Null);
7706        let mut marketType = get_arg(optional_args, 2, Value::Null);
7707        let mut marketResolved: Value = self.safe_market(&[marketId, market, delimiter, marketType]);
7708        return marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7709
7710    Value::Null
7711}
7712
7713    fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7714        // virtual-dispatch (static: DerivedExchange::parse_funding_rate(self, ...))
7715        { 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; } }
7716
7717        let mut market = get_arg(optional_args, 0, Value::Null);
7718        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRate() is not supported yet".into()))));
7719
7720    Value::Null
7721}
7722
7723    fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7724        let mut symbols = get_arg(optional_args, 0, Value::Null);
7725        let mut fundingRates: Value = Value::Map({
7726            let mut m = indexmap::IndexMap::new();
7727            m
7728        });
7729        {
7730                        let mut i: Value = Value::Int(0);
7731            let mut __for_first_153: bool = true;
7732            while { if !__for_first_153 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_153 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7733            let mut entry: Value = get_value(&response, &i);
7734            let mut entry: Value = get_value(&response, &i);
7735            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry, &[]);
7736            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7737                add_element_to_object(&mut fundingRates, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7738            }
7739        }
7740        }
7741        return self.index_by(self.filter_by_array(fundingRates, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]), Value::Str("symbol".into()));
7742
7743    Value::Null
7744}
7745
7746    fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7747        let mut market = get_arg(optional_args, 0, Value::Null);
7748        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLongShortRatio() is not supported yet".into()))));
7749
7750    Value::Null
7751}
7752
7753    fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7754        let mut market = get_arg(optional_args, 0, Value::Null);
7755        let mut since = get_arg(optional_args, 1, Value::Null);
7756        let mut limit = get_arg(optional_args, 2, Value::Null);
7757        let mut rates: Vec<Value> = Vec::new();
7758        {
7759                        let mut i: Value = Value::Int(0);
7760            let mut __for_first_154: bool = true;
7761            while { if !__for_first_154 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_154 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7762            let mut entry: Value = get_value(&response, &i);
7763            let mut entry: Value = get_value(&response, &i);
7764            rates.push(self.parse_long_short_ratio(entry, &[market.clone()]));
7765        }
7766        }
7767        let mut sorted: Value = self.sort_by(Value::from(rates), Value::Str("timestamp".into()), &[]);
7768        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) });
7769        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7770
7771    Value::Null
7772}
7773
7774    fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7775        let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7776        //
7777        let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
7778        let mut triggerPriceStr: Value = Value::Null;
7779        let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7780        let mut stopLossPriceStr: Value = Value::Null;
7781        let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7782        let mut takeProfitPriceStr: Value = Value::Null;
7783        //
7784        let mut keysToOmit: Vec<Value> = Vec::new();
7785        if (triggerPrice != Value::Null) {
7786            if omitParams.as_bool() == Some(true) {
7787                keysToOmit.push(Value::Str("triggerPrice".into()));
7788                keysToOmit.push(Value::Str("stopPrice".into()));
7789            }
7790            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 }));
7791        }
7792        if (stopLossPrice != Value::Null) {
7793            if omitParams.as_bool() == Some(true) {
7794                keysToOmit.push(Value::Str("stopLossPrice".into()));
7795            }
7796            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 }));
7797        }
7798        if (takeProfitPrice != Value::Null) {
7799            if omitParams.as_bool() == Some(true) {
7800                keysToOmit.push(Value::Str("takeProfitPrice".into()));
7801            }
7802            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 }));
7803        }
7804        let mut keysToOmitLength: f64 = ((keysToOmit.len() as i64) as f64);
7805        let mut paramsOmitted: Value = (if (keysToOmitLength > ((0i64) as f64)) { self.omit(params.clone(), Value::from(keysToOmit), &[]) } else { params });
7806        return Value::from(vec![triggerPriceStr, stopLossPriceStr, takeProfitPriceStr, paramsOmitted]);
7807
7808    Value::Null
7809}
7810
7811    fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7812        let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7813        let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7814        /*
7815         * @ignore
7816         * @method
7817         * @returns {[string, object]} the trigger-direction value and omited params
7818         */
7819        let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7820        let mut exchangeSpecificDefined: bool = (exchangeSpecificKey != Value::Null) && (in_op(&params, &exchangeSpecificKey));
7821        let mut paramsOmitted: Value = (if (triggerDirection != Value::Null) { self.omit(params.clone(), Value::Str("triggerDirection".into()), &[]) } else { params });
7822        // throw exception if:
7823        // A) if provided value is not unified (support old "up/down" strings too)
7824        // B) if exchange specific "trigger direction key" (eg. "stopPriceSide") was not provided
7825        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 && !(allowEmpty.as_bool() == Some(true)) {
7826            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()))));
7827        }
7828        // if old format was provided, overwrite to new
7829        if (triggerDirection.as_str() == Some("up")) || (triggerDirection.as_str() == Some("above")) {
7830            triggerDirection = Value::Str("ascending".into());
7831        }  else if (triggerDirection.as_str() == Some("down")) || (triggerDirection.as_str() == Some("below")) {
7832            triggerDirection = Value::Str("descending".into());
7833        }
7834        return Value::from(vec![triggerDirection, paramsOmitted]);
7835
7836    Value::Null
7837}
7838
7839    fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7840        let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[]);
7841        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 });
7842        return Value::from(vec![isTrigger, paramsOmitted]);
7843
7844    Value::Null
7845}
7846
7847    fn is_trigger_order(&self, mut params: Value) -> Value {
7848        return self.handle_trigger_and_params(params);
7849
7850    Value::Null
7851}
7852
7853    fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7854        let mut params = get_arg(optional_args, 0, Value::Map({
7855    let mut m = indexmap::IndexMap::new();
7856    m
7857}));
7858        /*
7859         * @ignore
7860         * @method
7861         * @param {string} type Order type
7862         * @param {boolean} exchangeSpecificParam exchange specific postOnly
7863         * @param {object} [params] exchange specific params
7864         * @returns {boolean} true if a post only order, false otherwise
7865         */
7866        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7867        // we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
7868        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7869        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7870        let mut timeInForcePostOnly: bool = timeInForce.as_str() == Some("PO");
7871        let mut postOnly: bool = self.safe_bool2(params, Value::Str("postOnly".into()), Value::Str("post_only".into()), &[Value::Bool(false)]).as_bool() == Some(true) || timeInForcePostOnly || is_true(&exchangeSpecificParam);
7872        if postOnly {
7873            if ioc || fok {
7874                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)));
7875            }  else if is_true(&isMarketOrder) {
7876                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7877            }  else {
7878                return Value::Bool(true);
7879            }
7880        }  else {
7881            return Value::Bool(false);
7882        }
7883
7884    Value::Null
7885}
7886
7887    fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7888        let mut params = get_arg(optional_args, 0, Value::Map({
7889    let mut m = indexmap::IndexMap::new();
7890    m
7891}));
7892        /*
7893         * @ignore
7894         * @method
7895         * @param {string} type Order type
7896         * @param {boolean} exchangeSpecificBoolean exchange specific postOnly
7897         * @param {object} [params] exchange specific params
7898         * @returns {Array}
7899         */
7900        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7901        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7902        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7903        let mut po: bool = timeInForce.as_str() == Some("PO");
7904        let mut postOnly: bool = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]).as_bool() == Some(true) || po || is_true(&exchangeSpecificPostOnlyOption);
7905        if postOnly {
7906            if ioc || fok {
7907                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)));
7908            }  else if is_true(&isMarketOrder) {
7909                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7910            }  else {
7911                let mut keysToOmit: Value = Value::Null;
7912                if po {
7913                    keysToOmit = Value::from(vec![Value::Str("timeInForce".into()), Value::Str("postOnly".into())]);
7914                }  else {
7915                    keysToOmit = Value::from(vec![Value::Str("postOnly".into())]);
7916                }
7917                let mut paramsOmitted: Value = self.omit(params.clone(), keysToOmit, &[]);
7918                return Value::from(vec![Value::Bool(true), paramsOmitted]);
7919            }
7920        }
7921        return Value::from(vec![Value::Bool(false), params]);
7922
7923    Value::Null
7924}
7925
7926    fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7927        let mut symbols = get_arg(optional_args, 0, Value::Null);
7928        let mut params = get_arg(optional_args, 1, Value::Map({
7929    let mut m = indexmap::IndexMap::new();
7930    m
7931}));
7932        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLastPrices() is not supported yet".into()))));
7933
7934    Value::Null
7935} }
7936
7937    fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7938        // async-virtual: try the derived exchange first
7939        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 {
7940            if !matches!(__v, crate::Value::Null) { return __v; }
7941        }
7942
7943        let mut params = get_arg(optional_args, 0, Value::Map({
7944    let mut m = indexmap::IndexMap::new();
7945    m
7946}));
7947        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFees() is not supported yet".into()))));
7948
7949    Value::Null
7950} }
7951
7952    fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7953        let mut params = get_arg(optional_args, 0, Value::Map({
7954    let mut m = indexmap::IndexMap::new();
7955    m
7956}));
7957        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFeesWs() is not supported yet".into()))));
7958
7959    Value::Null
7960} }
7961
7962    fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7963        let mut params = get_arg(optional_args, 0, Value::Map({
7964    let mut m = indexmap::IndexMap::new();
7965    m
7966}));
7967        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertCurrencies() is not supported yet".into()))));
7968
7969    Value::Null
7970} }
7971
7972    fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
7973        // virtual-dispatch (static: DerivedExchange::parse_open_interest(self, ...))
7974        { 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; } }
7975
7976        let mut market = get_arg(optional_args, 0, Value::Null);
7977        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOpenInterest () is not supported yet".into()))));
7978
7979    Value::Null
7980}
7981
7982    fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7983        let mut symbols = get_arg(optional_args, 0, Value::Null);
7984        let mut result: Value = Value::Map({
7985            let mut m = indexmap::IndexMap::new();
7986            m
7987        });
7988        {
7989                        let mut i: Value = Value::Int(0);
7990            let mut __for_first_155: bool = true;
7991            while { if !__for_first_155 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_155 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7992            let mut entry: Value = get_value(&response, &i);
7993            let mut entry: Value = get_value(&response, &i);
7994            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[]);
7995            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7996                add_element_to_object(&mut result, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7997            }
7998        }
7999        }
8000        return self.index_by(self.filter_by_array(result, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]), Value::Str("symbol".into()));
8001
8002    Value::Null
8003}
8004
8005    fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
8006        let mut market = get_arg(optional_args, 0, Value::Null);
8007        let mut since = get_arg(optional_args, 1, Value::Null);
8008        let mut limit = get_arg(optional_args, 2, Value::Null);
8009        let mut interests: Vec<Value> = Vec::new();
8010        {
8011                        let mut i: Value = Value::Int(0);
8012            let mut __for_first_156: bool = true;
8013            while { if !__for_first_156 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_156 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
8014            let mut entry: Value = get_value(&response, &i);
8015            let mut entry: Value = get_value(&response, &i);
8016            let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[market.clone()]);
8017            interests.push(interest);
8018        }
8019        }
8020        let mut sorted: Value = self.sort_by(Value::from(interests), Value::Str("timestamp".into()), &[]);
8021        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8022        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8023
8024    Value::Null
8025}
8026
8027    fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8028        // async-virtual: try the derived exchange first
8029        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 {
8030            if !matches!(__v, crate::Value::Null) { return __v; }
8031        }
8032
8033        let mut params = get_arg(optional_args, 0, Value::Map({
8034    let mut m = indexmap::IndexMap::new();
8035    m
8036}));
8037        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)) {
8038            self.load_markets(&[]).await;
8039            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
8040            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
8041            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
8042                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports contract markets only".into()))));
8043            }
8044            let mut rates: Value = self.fetch_funding_rates(&[Value::from(vec![symbolResolved.clone()]), params]).await;
8045            let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
8046            if (rate == Value::Null) {
8047                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () returned no data for ".into())).into()), symbolResolved)));
8048            }  else {
8049                return rate;
8050            }
8051        }  else {
8052            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () is not supported yet".into()))));
8053        }
8054
8055    Value::Null
8056} }
8057
8058    fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8059        // async-virtual: try the derived exchange first
8060        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 {
8061            if !matches!(__v, crate::Value::Null) { return __v; }
8062        }
8063
8064        let mut params = get_arg(optional_args, 0, Value::Map({
8065    let mut m = indexmap::IndexMap::new();
8066    m
8067}));
8068        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)) {
8069            self.load_markets(&[]).await;
8070            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
8071            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
8072            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
8073                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() supports contract markets only".into()))));
8074            }
8075            let mut rates: Value = self.fetch_funding_intervals(&[Value::from(vec![symbolResolved.clone()]), params]).await;
8076            let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
8077            if (rate == Value::Null) {
8078                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() returned no data for ".into())).into()), symbolResolved)));
8079            }  else {
8080                return rate;
8081            }
8082        }  else {
8083            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() is not supported yet".into()))));
8084        }
8085
8086    Value::Null
8087} }
8088
8089    fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8090        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8091        let mut since = get_arg(optional_args, 1, Value::Null);
8092        let mut limit = get_arg(optional_args, 2, Value::Null);
8093        let mut params = get_arg(optional_args, 3, Value::Map({
8094    let mut m = indexmap::IndexMap::new();
8095    m
8096}));
8097        /*
8098         * @method
8099         * @name exchange#fetchMarkOHLCV
8100         * @description fetches historical mark price candlestick data containing the open, high, low, and close price of a market
8101         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
8102         * @param {string} timeframe the length of time each candle represents
8103         * @param {int} [since] timestamp in ms of the earliest candle to fetch
8104         * @param {int} [limit] the maximum amount of candles to fetch
8105         * @param {object} [params] extra parameters specific to the exchange API endpoint
8106         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
8107         */
8108        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)) {
8109            let mut request: Value = Value::Map({
8110                let mut m = indexmap::IndexMap::new();
8111                    m.insert("price".to_string(), Value::Str("mark".into()));
8112                m
8113            });
8114            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
8115        }  else {
8116            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkOHLCV () is not supported yet".into()))));
8117        }
8118} }
8119
8120    fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8121        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8122        let mut since = get_arg(optional_args, 1, Value::Null);
8123        let mut limit = get_arg(optional_args, 2, Value::Null);
8124        let mut params = get_arg(optional_args, 3, Value::Map({
8125    let mut m = indexmap::IndexMap::new();
8126    m
8127}));
8128        /*
8129         * @method
8130         * @name exchange#fetchIndexOHLCV
8131         * @description fetches historical index price candlestick data containing the open, high, low, and close price of a market
8132         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
8133         * @param {string} timeframe the length of time each candle represents
8134         * @param {int} [since] timestamp in ms of the earliest candle to fetch
8135         * @param {int} [limit] the maximum amount of candles to fetch
8136         * @param {object} [params] extra parameters specific to the exchange API endpoint
8137         * @returns {} A list of candles ordered as timestamp, open, high, low, close, undefined
8138         */
8139        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)) {
8140            let mut request: Value = Value::Map({
8141                let mut m = indexmap::IndexMap::new();
8142                    m.insert("price".to_string(), Value::Str("index".into()));
8143                m
8144            });
8145            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
8146        }  else {
8147            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIndexOHLCV () is not supported yet".into()))));
8148        }
8149} }
8150
8151    fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8152        // async-virtual: try the derived exchange first
8153        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 {
8154            if !matches!(__v, crate::Value::Null) { return __v; }
8155        }
8156
8157        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8158        let mut since = get_arg(optional_args, 1, Value::Null);
8159        let mut limit = get_arg(optional_args, 2, Value::Null);
8160        let mut params = get_arg(optional_args, 3, Value::Map({
8161    let mut m = indexmap::IndexMap::new();
8162    m
8163}));
8164        /*
8165         * @method
8166         * @name exchange#fetchPremiumIndexOHLCV
8167         * @description fetches historical premium index price candlestick data containing the open, high, low, and close price of a market
8168         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
8169         * @param {string} timeframe the length of time each candle represents
8170         * @param {int} [since] timestamp in ms of the earliest candle to fetch
8171         * @param {int} [limit] the maximum amount of candles to fetch
8172         * @param {object} [params] extra parameters specific to the exchange API endpoint
8173         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
8174         */
8175        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)) {
8176            let mut request: Value = Value::Map({
8177                let mut m = indexmap::IndexMap::new();
8178                    m.insert("price".to_string(), Value::Str("premiumIndex".into()));
8179                m
8180            });
8181            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
8182        }  else {
8183            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".into()))));
8184        }
8185} }
8186
8187    fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
8188        let mut params = get_arg(optional_args, 0, Value::Map({
8189    let mut m = indexmap::IndexMap::new();
8190    m
8191}));
8192        /*
8193         * @ignore
8194         * @method
8195         * Must add timeInForce to this.options to use this method
8196         * @returns {string} returns the exchange specific value for timeInForce
8197         */
8198        let mut timeInForce: Value = self.safe_string_upper_k(params, "timeInForce", &[]); // supported values GTC, IOC, PO
8199        if (timeInForce != Value::Null) {
8200            let mut exchangeValue: Value = self.safe_string(self.options.as_map().and_then(|__m| __m.get("timeInForce")).cloned().unwrap_or(Value::Null), timeInForce.clone(), &[]);
8201            if (exchangeValue == Value::Null) {
8202                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()))));
8203            }
8204            return exchangeValue;
8205        }
8206        return Value::Null;
8207
8208    Value::Null
8209}
8210
8211    fn convert_type_to_account(&self, mut account: Value) -> Value {
8212        /*
8213         * @ignore
8214         * @method
8215         * Must add accountsByType to this.options to use this method
8216         * @param {string} account key for account name in this.options['accountsByType']
8217         * @returns the exchange specific account name or the isolated margin id for transfers
8218         */
8219        let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
8220    let mut m = indexmap::IndexMap::new();
8221    m
8222})]);
8223        let mut lowercaseAccount: Value = (match &(account) { Value::Str(__s) => Value::Str(__s.to_lowercase().into()), _ => Value::Null });
8224        if (matches!((&accountsByType, &lowercaseAccount), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
8225            return accountsByType.as_map().and_then(|__m| lowercaseAccount.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
8226        }
8227        let mut markets: Value = self.markets.clone();
8228        let mut marketsById: Value = self.markets_by_id.clone();
8229        if ((markets != Value::Null) && (matches!((&markets, &account), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref())))) || ((marketsById != Value::Null) && (matches!((&marketsById, &account), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref())))) {
8230            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, account.clone());
8231            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
8232        }  else {
8233            return account;
8234        }
8235
8236    Value::Null
8237}
8238
8239    fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
8240        let mut options = get_arg(optional_args, 0, Value::from(vec![]));
8241        /*
8242         * @ignore
8243         * @method
8244         * @param {string} methodName the name of the method that the argument is being checked for
8245         * @param {string} argument the argument's actual value provided
8246         * @param {string} argumentName the name of the argument being checked (for logging purposes)
8247         * @param {string[]} options a list of options that the argument can be
8248         * @returns {undefined}
8249         */
8250        let mut optionsLength: f64 = ((options.len() as i64) as f64);
8251        if (argument == Value::Null) || ((optionsLength > ((0i64) as f64)) && (!(self.in_array(argument, options.clone()).as_bool() == Some(true)))) {
8252            let mut messageOptions: Value = Value::Str(options.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(", ")).unwrap_or_default().into());
8253            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());
8254            if (!matches!(&messageOptions, Value::Str(__s15) if __s15 == "")) {
8255                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());
8256            }
8257            panic!("{}", crate::exchange_errors::arguments_required(message));
8258        }
8259}
8260
8261    fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
8262        /*
8263         * @ignore
8264         * @method
8265         * @param {string} symbol unified symbol of the market
8266         * @param {string} methodName name of the method that requires a symbol
8267         * @param {string} marginMode is either 'isolated' or 'cross'
8268         */
8269        if (marginMode.as_str() == Some("isolated")) && (symbol == Value::Null) {
8270            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()))));
8271        }  else if (marginMode.as_str() == Some("cross")) && (symbol != Value::Null) {
8272            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()))));
8273        }
8274}
8275
8276    fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
8277        let mut codes = get_arg(optional_args, 0, Value::Null);
8278        let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
8279        /*
8280         * @ignore
8281         * @method
8282         * @param {object[]|object} response unparsed response from the exchange
8283         * @param {string[]|undefined} codes the unified currency codes to fetch transactions fees for, returns all currencies when undefined
8284         * @param {str} currencyIdKey *should only be undefined when response is a dictionary* the object key that corresponds to the currency id
8285         * @returns {object} objects with withdraw and deposit fees, indexed by currency codes
8286         */
8287        let mut depositWithdrawFees: Value = Value::Map({
8288            let mut m = indexmap::IndexMap::new();
8289            m
8290        });
8291        let mut isArray: bool = matches!(&response, Value::Arr(_));
8292        let mut responseKeys: Value = response.clone();
8293        if !isArray {
8294            responseKeys = object_keys(&response);
8295        }
8296        {
8297                        let mut i: Value = Value::Int(0);
8298            let mut __for_first_157: bool = true;
8299            while { if !__for_first_157 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_157 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&responseKeys).as_f64().unwrap_or(f64::NAN) } {
8300            let mut entry: Value = get_value(&responseKeys, &i);
8301            let mut entry: Value = get_value(&responseKeys, &i);
8302            let mut dictionary: Value = (if isArray { entry.clone() } else { get_value(&response, &entry) });
8303            let mut currencyId: Value = entry;
8304            if isArray {
8305                currencyId = (if (currencyIdKey == Value::Null) { Value::Null } else { self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]) });
8306            }
8307            let mut currency: Value = self.safe_currency(currencyId, &[]);
8308            let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
8309            if (codes == Value::Null) || self.in_array(code.clone(), codes.clone()).as_bool() == Some(true) {
8310                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])); }
8311            }
8312        }
8313        }
8314        return depositWithdrawFees;
8315
8316    Value::Null
8317}
8318
8319    fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8320        // virtual-dispatch (static: DerivedExchange::parse_deposit_withdraw_fee(self, ...))
8321        { 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; } }
8322
8323        let mut currency = get_arg(optional_args, 0, Value::Null);
8324        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositWithdrawFee() is not supported yet".into()))));
8325
8326    Value::Null
8327}
8328
8329    fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8330        return Value::Map({
8331    let mut m = indexmap::IndexMap::new();
8332        m.insert("info".to_string(), info);
8333        m.insert("withdraw".to_string(), Value::Map({
8334    let mut m = indexmap::IndexMap::new();
8335        m.insert("fee".to_string(), Value::Null);
8336        m.insert("percentage".to_string(), Value::Null);
8337    m
8338}));
8339        m.insert("deposit".to_string(), Value::Map({
8340    let mut m = indexmap::IndexMap::new();
8341        m.insert("fee".to_string(), Value::Null);
8342        m.insert("percentage".to_string(), Value::Null);
8343    m
8344}));
8345        m.insert("networks".to_string(), Value::Map({
8346    let mut m = indexmap::IndexMap::new();
8347    m
8348}));
8349    m
8350});
8351
8352    Value::Null
8353}
8354
8355    fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8356        let mut currency = get_arg(optional_args, 0, Value::Null);
8357        let __currency_empty = indexmap::IndexMap::new();
8358        let currency = currency.as_map().unwrap_or(&__currency_empty);
8359        /*
8360         * @ignore
8361         * @method
8362         * @description Takes a depositWithdrawFee structure and assigns the default values for withdraw and deposit
8363         * @param {object} fee A deposit withdraw fee structure
8364         * @param {object} currency A currency structure, the response from this.currency ()
8365         * @returns {object} A deposit withdraw fee structure
8366         */
8367        let mut networkKeys: Value = object_keys(&crate::value::get_value_k(&fee, "networks"));
8368        let mut numNetworks: f64 = ((networkKeys.len() as i64) as f64);
8369        if (numNetworks == 1.0) {
8370            { 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); };
8371            { 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); };
8372            return fee;
8373        }
8374        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 });
8375        {
8376                        let mut i: Value = Value::Int(0);
8377            let mut __for_first_158: bool = true;
8378            while { if !__for_first_158 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_158 = false; i.as_f64().unwrap_or(f64::NAN) < numNetworks } {
8379            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);
8380            if (network.as_str() == currencyCode.as_str()) {
8381                { 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); };
8382                { 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); };
8383            }
8384        }
8385        }
8386        return fee;
8387
8388    Value::Null
8389}
8390
8391    fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8392        // virtual-dispatch (static: DerivedExchange::parse_income(self, ...))
8393        { 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; } }
8394
8395        let mut market = get_arg(optional_args, 0, Value::Null);
8396        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIncome () is not supported yet".into()))));
8397
8398    Value::Null
8399}
8400
8401    fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8402        let mut market = get_arg(optional_args, 0, Value::Null);
8403        let mut since = get_arg(optional_args, 1, Value::Null);
8404        let mut limit = get_arg(optional_args, 2, Value::Null);
8405        /*
8406         * @ignore
8407         * @method
8408         * @description parses funding fee info from exchange response
8409         * @param {object[]} incomes each item describes once instance of currency being received or paid
8410         * @param {object} market ccxt market
8411         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
8412         * @param {int} [limit] limits the number of items in the response
8413         * @returns {object[]} an array of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure}
8414         */
8415        let mut result: Vec<Value> = Vec::new();
8416        {
8417                        let mut i: Value = Value::Int(0);
8418            let mut __for_first_159: bool = true;
8419            while { if !__for_first_159 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_159 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&incomes).as_f64().unwrap_or(f64::NAN) } {
8420            let mut entry: Value = get_value(&incomes, &i);
8421            let mut entry: Value = get_value(&incomes, &i);
8422            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry, &[market.clone()]);
8423            result.push(parsed);
8424        }
8425        }
8426        let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
8427        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8428        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8429
8430    Value::Null
8431}
8432
8433    fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8434        let mut symbols = get_arg(optional_args, 0, Value::Null);
8435        /*
8436         * @param {string[]|undefined} symbols list of unified symbols (first element selects the market)
8437         * @returns {MarketInterface|undefined} market structure for the first symbol, or undefined if symbols is undefined
8438         * Overloads: non-null `string[]` input yields `MarketInterface`; optional input yields `Market`.
8439         */
8440        if (symbols == Value::Null) {
8441            return Value::Null;
8442        }
8443        let mut firstMarket: Value = self.safe_string(symbols, Value::Int(0), &[]);
8444        if (firstMarket == Value::Null) {
8445            return Value::Null;
8446        }
8447        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, firstMarket);
8448        return market;
8449
8450    Value::Null
8451}
8452
8453    fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8454        let mut market = get_arg(optional_args, 0, Value::Null);
8455        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
8456        let mut since = get_arg(optional_args, 2, Value::Null);
8457        let mut limit = get_arg(optional_args, 3, Value::Null);
8458        let mut results: Vec<Value> = Vec::new();
8459        {
8460                        let mut i: Value = Value::Int(0);
8461            let mut __for_first_160: bool = true;
8462            while { if !__for_first_160 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_160 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
8463            results.push(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()]));
8464        }
8465        }
8466        return Value::from(results);
8467
8468    Value::Null
8469}
8470
8471    fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8472        let mut code = get_arg(optional_args, 0, Value::Null);
8473        let mut since = get_arg(optional_args, 1, Value::Null);
8474        let mut limit = get_arg(optional_args, 2, Value::Null);
8475        let mut params = get_arg(optional_args, 3, Value::Map({
8476    let mut m = indexmap::IndexMap::new();
8477    m
8478}));
8479        /*
8480         * @method
8481         * @name exchange#fetchTransactions
8482         * @deprecated
8483         * @description *DEPRECATED* use fetchDepositsWithdrawals instead
8484         * @param {string} code unified currency code for the currency of the deposit/withdrawals, default is undefined
8485         * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
8486         * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
8487         * @param {object} [params] extra parameters specific to the exchange API endpoint
8488         * @returns {object} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
8489         */
8490        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)) {
8491            return self.fetch_deposits_withdrawals(&[code, since, limit, params]).await;
8492        }  else {
8493            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactions () is not supported yet".into()))));
8494        }
8495} }
8496
8497    fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8498        let mut values = get_arg(optional_args, 0, Value::Null);
8499        return self.to_array(self.filter_by_array(objects, key, &[values, Value::Bool(false)]));
8500
8501    Value::Null
8502}
8503
8504    fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8505        let mut values = get_arg(optional_args, 0, Value::Null);
8506        return self.index_by(self.filter_by_array(objects, key.clone(), &[values, Value::Bool(false)]), key);
8507
8508    Value::Null
8509}
8510
8511    fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8512        let mut values = get_arg(optional_args, 0, Value::Null);
8513        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8514        return self.to_array(self.filter_by_array(objects, key, &[values, indexed]));
8515
8516    Value::Null
8517}
8518
8519    fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8520        let mut res: Value = Value::Map({
8521            let mut m = indexmap::IndexMap::new();
8522            m
8523        });
8524        if let Value::Dict(__d) = &mut res { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
8525    let mut m = indexmap::IndexMap::new();
8526    m
8527})); }
8528        add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data);
8529        return res;
8530
8531    Value::Null
8532}
8533
8534    fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8535        let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8536        let mut params = get_arg(optional_args, 1, Value::Map({
8537    let mut m = indexmap::IndexMap::new();
8538    m
8539}));
8540        let mut newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable = self.handle_option_integer_and_params(params, method, Value::Str("maxEntriesPerRequest".into()), &[]);
8541        let mut newMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8542        let mut paramsMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8543        let mut maxEntriesPerRequestOption: Value = (if (newMaxEntriesPerRequest != Value::Null) { newMaxEntriesPerRequest } else { maxEntriesPerRequest });
8544        let mut maxEntriesPerRequestResolved: Value = (if (maxEntriesPerRequestOption == Value::Null) { Value::Int(1000) } else { maxEntriesPerRequestOption }); // default to 1000
8545        return Value::from(vec![maxEntriesPerRequestResolved, paramsMaxEntriesPerRequest]);
8546
8547    Value::Null
8548}
8549
8550    fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8551        let mut symbol = get_arg(optional_args, 0, Value::Null);
8552        let mut since = get_arg(optional_args, 1, Value::Null);
8553        let mut limit = get_arg(optional_args, 2, Value::Null);
8554        let mut params = get_arg(optional_args, 3, Value::Map({
8555    let mut m = indexmap::IndexMap::new();
8556    m
8557}));
8558        let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8559        let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8560        let mut maxCalls: Value = Value::Int(10);
8561        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8562        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8563        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8564        let mut maxRetries: Value = Value::Int(3);
8565        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8566        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8567        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8568        let mut paginationDirectionparamsPaginationDirectionVariable = self.handle_option_and_params(paramsMaxRetries, method.clone(), Value::Str("paginationDirection".into()), &[Value::Str("backward".into())]);
8569        let mut paginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8570        let mut paramsPaginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8571        let mut paginationTimestamp: Value = Value::Null;
8572        let mut removeRepeatedOptionparamsRemoveRepeatedVariable = self.handle_option_and_params(paramsPaginationDirection, method.clone(), Value::Str("removeRepeated".into()), &[removeRepeated]);
8573        let mut removeRepeatedOption: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8574        let mut paramsRemoveRepeated: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8575        let mut calls: Value = Value::Int(0);
8576        let mut result: Value = Value::from(vec![]);
8577        let mut errors: Value = Value::Int(0);
8578        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
8579        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsRemoveRepeated]);
8580        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8581        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8582        if (paginationDirection.as_str() == Some("forward")) {
8583            if (since == Value::Null) {
8584                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" pagination requires a since argument when paginationDirection set to forward".into()))));
8585            }
8586            paginationTimestamp = since.clone();
8587        }
8588        let mut shouldBreak: bool = false;
8589        while (calls.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN)) {
8590            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 });
8591            {
8592                if (paginationDirection.as_str() == Some("backward")) {
8593                    // do it backwards, starting from the last
8594                    // UNTIL filtering is required in order to work
8595                    if (paginationTimestamp != Value::Null) {
8596                        if let Value::Dict(__d) = &mut paramsMaxEntriesPerRequest { std::sync::Arc::make_mut(__d).insert("until".into(), (match (&(paginationTimestamp), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
8597                    }
8598                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (Value::Null).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8599                    let mut responseLength: Value = get_array_length(&response);
8600                    if is_true(&self.verbose) {
8601                        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());
8602                        if (paginationTimestamp != Value::Null) {
8603                            backwardMessage = Value::Str(format!("{}{}", backwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8604                        }
8605                        self.log(backwardMessage);
8606                    }
8607                    if (responseLength.as_f64() == Some(0.0)) {
8608                        shouldBreak = true;
8609                        break;
8610                    }
8611                    errors = Value::Int(0);
8612                    result = self.array_concat(result.clone(), response.clone());
8613                    let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
8614                    paginationTimestamp = self.safe_integer2(firstElement, Value::Str("timestamp".into()), Value::Int(0), &[]);
8615                    if (paginationTimestamp == Value::Null) {
8616                        shouldBreak = true;
8617                        break;
8618                    }
8619                    if (since != Value::Null) && (paginationTimestamp.as_f64().unwrap_or(f64::NAN) <= since.as_f64().unwrap_or(f64::NAN)) {
8620                        shouldBreak = true;
8621                        break;
8622                    }
8623                }  else {
8624                    // do it forwards, starting from the since
8625                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paginationTimestamp).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8626                    let mut responseLength: Value = get_array_length(&response);
8627                    if is_true(&self.verbose) {
8628                        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());
8629                        if (paginationTimestamp != Value::Null) {
8630                            forwardMessage = Value::Str(format!("{}{}", forwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8631                        }
8632                        self.log(forwardMessage);
8633                    }
8634                    if (responseLength.as_f64() == Some(0.0)) {
8635                        shouldBreak = true;
8636                        break;
8637                    }
8638                    errors = Value::Int(0);
8639                    result = self.array_concat(result.clone(), response.clone());
8640                    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 }), &[]);
8641                    let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[Value::Int(0)]);
8642                    if (lastTimestamp == Value::Null) {
8643                        shouldBreak = true;
8644                        break;
8645                    }
8646                    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 });
8647                    paginationTimestamp = nextPaginationTimestamp.clone();
8648                    if (until != Value::Null) && (nextPaginationTimestamp.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8649                        shouldBreak = true;
8650                        break;
8651                    }
8652                }
8653            }
8654            if shouldBreak {
8655                break;
8656            }
8657        }
8658        let mut uniqueResults: Value = result.clone();
8659        if is_true(&removeRepeatedOption) {
8660            uniqueResults = self.remove_repeated_elements_from_array(result, &[]);
8661        }
8662        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8663        let mut sortedRes: Value = self.sort_by(uniqueResults, key.clone(), &[]);
8664        return self.filter_by_since_limit(sortedRes, &[since, limit, key]);
8665
8666    Value::Null
8667} }
8668
8669    fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8670        let mut symbol = get_arg(optional_args, 0, Value::Null);
8671        let mut since = get_arg(optional_args, 1, Value::Null);
8672        let mut limit = get_arg(optional_args, 2, Value::Null);
8673        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8674        let mut params = get_arg(optional_args, 4, Value::Map({
8675    let mut m = indexmap::IndexMap::new();
8676    m
8677}));
8678        let mut maxRetries: Value = Value::Int(3);
8679        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8680        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8681        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8682        let mut errors: Value = Value::Int(0);
8683        while errors.as_f64().unwrap_or(f64::NAN) <= maxRetriesOption.as_f64().unwrap_or(f64::NAN) {
8684            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8685                if ((timeframe != Value::Null) && (timeframe.as_str() != Some(""))) && (method.as_str() != Some("fetchFundingRateHistory")) {
8686                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8687                }  else {
8688                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8689                }
8690             #[allow(unreachable_code)] { Value::Null }})).await;
8691match _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); 
8692                if matches!(&e, Value::Str(__s) if __s.contains("[RateLimitExceeded]")) {
8693                    panic!("{}", e);
8694                }
8695                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 });
8696                if errors.as_f64().unwrap_or(f64::NAN) > maxRetriesOption.as_f64().unwrap_or(f64::NAN) {
8697                    panic!("{}", e);
8698                }
8699             } }
8700        }
8701        return Value::from(vec![]);
8702
8703    Value::Null
8704} }
8705
8706    fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8707        let mut symbol = get_arg(optional_args, 0, Value::Null);
8708        let mut since = get_arg(optional_args, 1, Value::Null);
8709        let mut limit = get_arg(optional_args, 2, Value::Null);
8710        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8711        let mut params = get_arg(optional_args, 4, Value::Map({
8712    let mut m = indexmap::IndexMap::new();
8713    m
8714}));
8715        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8716        let mut maxCalls: Value = Value::Int(10);
8717        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8718        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8719        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8720        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsPaginationCalls]);
8721        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8722        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8723        // paginationDirection is only relevant to fetchPaginatedCallDynamic/Cursor; deterministic
8724        // pagination always walks forward internally, so strip it here to avoid leaking an
8725        // unrecognized param into the underlying exchange request (e.g. binance -1104 errors)
8726        let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("paginationDirection".into()), &[]);
8727        let mut current: Value = self.milliseconds();
8728        let mut tasks: Vec<Value> = Vec::new();
8729        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 });
8730        let mut maxEntriesPerRequestValue: Value = self.require_value(maxEntriesPerRequestOption, &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".into())]);
8731        let mut step: Value = (match (&(time), &(self.parse_to_int(maxEntriesPerRequestValue.clone()))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
8732        let mut until: Value = self.safe_integer2(paramsOmitted.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]); // do not omit it here
8733        let mut currentSince: Value = (match (&((match (&(current), &(((match (&(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(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (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 });
8734        if (since != Value::Null) {
8735            if (until != Value::Null) {
8736                // the recent-window floor below would jump past a fully-historical [ since, until ]
8737                // range and return an empty result - requiredCalls is validated against maxCalls
8738                // further down, so anchoring at since directly is safe here,
8739                // see https://github.com/ccxt/ccxt/issues/26252
8740                currentSince = since.clone();
8741            }  else {
8742                currentSince = crate::runtime::Math::max(&currentSince, &since);
8743            }
8744        }  else {
8745            currentSince = crate::runtime::Math::max(&currentSince, &Value::Int(1241440531000)); // avoid timestamps older than 2009
8746        }
8747        if (until != Value::Null) {
8748            if (since == Value::Null) {
8749                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".into()))));
8750            }
8751            let mut requiredCalls: Value = ((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 })).as_f64().map(|__x| Value::Float(__x.ceil())).unwrap_or(Value::Null);
8752            if requiredCalls.as_f64().unwrap_or(f64::NAN) > maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8753                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()), Value::Str(format!("{}", maxCallsPaginationCalls).into())).into()), Value::Str(" required calls is ".into())).into()), Value::Str(format!("{}", requiredCalls).into()))));
8754            }
8755        }
8756        {
8757                        let mut i: Value = Value::Int(0);
8758            let mut __for_first_161: bool = true;
8759            while { if !__for_first_161 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_161 = false; i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) } {
8760            if (until != Value::Null) && (currentSince.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8761                break;
8762            }
8763            if currentSince.as_f64().unwrap_or(f64::NAN) >= current.as_f64().unwrap_or(f64::NAN) {
8764                break;
8765            }
8766            tasks.push(self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequestValue.clone(), timeframe.clone(), paramsOmitted.clone()]).await);
8767            // this.sum keeps it numeric in PHP, where the regex transpiler turns `a + b` into string concatenation
8768            currentSince = (match (&(self.sum(&[currentSince.clone(), step.clone()])), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8769        }
8770        }
8771        let mut results: Value = promise_all(&Value::from(tasks)).await;
8772        let mut result: Value = Value::from(vec![]);
8773        {
8774                        let mut i: Value = Value::Int(0);
8775            let mut __for_first_162: bool = true;
8776            while { if !__for_first_162 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_162 = false; i.as_f64().unwrap_or(f64::NAN) < ((results.len() as i64) as f64) } {
8777            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));
8778        }
8779        }
8780        let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result, &[]);
8781        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8782        return self.filter_by_since_limit(uniqueResults, &[since, limit, key]);
8783
8784    Value::Null
8785} }
8786
8787// the 'symbol' slot is forwarded to `this[method]` untouched and is only compared against
8788// undefined here, so fetchPositions/fetchPositionsHistory legitimately pass a symbol list
8789    fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8790        let mut symbol = get_arg(optional_args, 0, Value::Null);
8791        let mut since = get_arg(optional_args, 1, Value::Null);
8792        let mut limit = get_arg(optional_args, 2, Value::Null);
8793        let mut params = get_arg(optional_args, 3, Value::Map({
8794    let mut m = indexmap::IndexMap::new();
8795    m
8796}));
8797        let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8798        let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8799        let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8800        let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8801        let mut maxCalls: Value = Value::Int(10);
8802        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8803        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8804        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8805        let mut maxRetries: Value = Value::Int(3);
8806        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8807        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8808        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8809        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8810        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8811        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8812        let mut cursorValue: Value = Value::Null;
8813        let mut i: Value = Value::Int(0);
8814        let mut errors: Value = Value::Int(0);
8815        let mut result: Value = Value::from(vec![]);
8816        let mut timeframe: Value = self.safe_string_k(paramsMaxEntriesPerRequest.clone(), "timeframe", &[]);
8817        let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("timeframe".into()), &[]); // reading the timeframe from the method arguments to avoid changing the signature
8818        let mut shouldBreak: bool = false;
8819        while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8820            {
8821                if (cursorValue != Value::Null) {
8822                    if (cursorIncrement != Value::Null) {
8823                        cursorValue = self.sum(&[self.parse_to_int(cursorValue.clone()), cursorIncrement.clone()]);
8824                    }
8825                    if let Value::Dict(__d) = &mut paramsOmitted { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&cursorSent), cursorValue.clone()); }
8826                }
8827                let mut response: Value = Value::Null;
8828                if (method.as_str() == Some("fetchAccounts")) {
8829                    response = self.call_dynamic_checked(method.clone(), vec![(paramsOmitted).clone()]).await;
8830                }  else if (method.as_str() == Some("getLeverageTiersPaginated")) || (method.as_str() == Some("fetchPositions")) {
8831                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paramsOmitted).clone()]).await;
8832                }  else if (method.as_str() == Some("fetchOpenInterestHistory")) {
8833                    if !matches!(&symbol, Value::Str(_)) {
8834                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".into()))));
8835                    }
8836                    if (timeframe == Value::Null) {
8837                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".into()))));
8838                    }
8839                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8840                }  else {
8841                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8842                }
8843                errors = Value::Int(0);
8844                if (response == Value::Null) {
8845                    panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() returned empty response".into()))));
8846                }
8847                let mut responseLength: Value = Value::Int(response.len() as i64);
8848                if is_true(&self.verbose) {
8849                    let mut cursorString: Value = (if (cursorValue == Value::Null) { Value::Str("".into()) } else { cursorValue.clone() });
8850                    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 }));
8851                    let mut cursorMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Cursor pagination call ".into()), Value::Str(format!("{}", iteration).into())).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), Value::Str(format!("{}", responseLength).into())).into()), Value::Str(" cursor ".into())).into()), cursorString).into());
8852                    self.log(cursorMessage);
8853                }
8854                if (responseLength.as_f64() == Some(0.0)) {
8855                    shouldBreak = true;
8856                    break;
8857                }
8858                if (response != Value::Null) {
8859                    result = self.array_concat(result.clone(), response.clone());
8860                }
8861                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 }), &[]);
8862                // cursorValue = this.safeValue (last['info'], cursorReceived);
8863                cursorValue = Value::Null; // search for the cursor
8864                {
8865                                        let mut j: Value = Value::Int(0);
8866                    let mut __for_first_163: bool = true;
8867                    while { if !__for_first_163 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_163 = false; j.as_f64().unwrap_or(f64::NAN) < responseLength.as_f64().unwrap_or(f64::NAN) } {
8868                    if (cursorValue == Value::Null) {
8869                        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 });
8870                        let mut entry: Value = self.safe_dict(response.clone(), index, &[]);
8871                        let mut info: Value = self.safe_dict_k(entry, "info", &[]);
8872                        cursorValue = (if (cursorReceived == Value::Null) { Value::Null } else { self.safe_value(info, cursorReceived.clone(), &[]) });
8873                    }
8874                }
8875                }
8876                if (cursorValue == Value::Null) {
8877                    shouldBreak = true;
8878                    break;
8879                }
8880                let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[]);
8881                if (since == Value::Null) {
8882                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a since argument".into()))));
8883                }
8884                if (lastTimestamp != Value::Null) && lastTimestamp.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
8885                    shouldBreak = true;
8886                    break;
8887                }
8888            }
8889            if shouldBreak {
8890                break;
8891            }
8892            i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8893        }
8894        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8895        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8896        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8897
8898    Value::Null
8899} }
8900
8901    fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8902        let mut symbol = get_arg(optional_args, 0, Value::Null);
8903        let mut since = get_arg(optional_args, 1, Value::Null);
8904        let mut limit = get_arg(optional_args, 2, Value::Null);
8905        let mut params = get_arg(optional_args, 3, Value::Map({
8906    let mut m = indexmap::IndexMap::new();
8907    m
8908}));
8909        let mut pageKey = get_arg(optional_args, 4, Value::Null);
8910        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8911        let mut maxCalls: Value = Value::Int(10);
8912        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8913        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8914        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8915        let mut maxRetries: Value = Value::Int(3);
8916        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8917        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8918        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8919        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8920        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8921        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8922        let mut i: Value = Value::Int(0);
8923        let mut errors: Value = Value::Int(0);
8924        let mut result: Value = Value::from(vec![]);
8925        let mut shouldBreak: bool = false;
8926        while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8927            {
8928                if let Value::Dict(__d) = &mut paramsMaxEntriesPerRequest { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&pageKey), (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })); }
8929                let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8930                errors = Value::Int(0);
8931                let mut responseLength: Value = get_array_length(&response);
8932                if is_true(&self.verbose) {
8933                    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 }));
8934                    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()), Value::Str(format!("{}", iteration).into())).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), Value::Str(format!("{}", responseLength).into())).into());
8935                    self.log(incrementalMessage);
8936                }
8937                if (responseLength.as_f64() == Some(0.0)) {
8938                    shouldBreak = true;
8939                    break;
8940                }
8941                result = self.array_concat(result.clone(), response);
8942            }
8943            if shouldBreak {
8944                break;
8945            }
8946            i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8947        }
8948        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8949        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8950        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8951
8952    Value::Null
8953} }
8954
8955    fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
8956        let mut first: Value = self.safe_dict(result.clone(), Value::Int(0), &[]);
8957        if (first != Value::Null) {
8958            if (matches!(&first, Value::Dict(__d) if __d.contains_key("timestamp"))) {
8959                return self.sort_by(result.clone(), Value::Str("timestamp".into()), &[Value::Bool(true)]);
8960            }
8961            if (matches!(&first, Value::Dict(__d) if __d.contains_key("id"))) {
8962                return self.sort_by(result.clone(), Value::Str("id".into()), &[Value::Bool(true)]);
8963            }
8964        }
8965        return result;
8966
8967    Value::Null
8968}
8969
8970    fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
8971        let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
8972        let mut uniqueDic: Value = Value::Map({
8973            let mut m = indexmap::IndexMap::new();
8974            m
8975        });
8976        let mut uniqueResult: Value = Value::from(vec![]);
8977        {
8978                        let mut i: Value = Value::Int(0);
8979            let mut __for_first_164: bool = true;
8980            while { if !__for_first_164 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_164 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
8981            let mut entry: Value = get_value(&input, &i);
8982            let mut entry: Value = get_value(&input, &i);
8983            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", &[]) });
8984            if (uniqValue != Value::Null) && !(matches!((&uniqueDic, &uniqValue), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
8985                if let Value::Dict(__d) = &mut uniqueDic { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&uniqValue), Value::Int(1)); }
8986                if let Value::Arr(__a) = &mut uniqueResult { std::sync::Arc::make_mut(__a).push(entry); }
8987            }
8988        }
8989        }
8990        let mut valuesLength: f64 = ((uniqueResult.len() as i64) as f64);
8991        if valuesLength > ((0i64) as f64) {
8992            return uniqueResult;
8993        }
8994        return input;
8995
8996    Value::Null
8997}
8998
8999    fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
9000        let mut uniqueResult: Value = Value::Map({
9001            let mut m = indexmap::IndexMap::new();
9002            m
9003        });
9004        {
9005                        let mut i: Value = Value::Int(0);
9006            let mut __for_first_165: bool = true;
9007            while { if !__for_first_165 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_165 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
9008            let mut entry: Value = get_value(&input, &i);
9009            let mut entry: Value = get_value(&input, &i);
9010            let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
9011            if (id == Value::Null) {
9012                let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
9013                let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
9014                let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
9015                let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
9016                // unique trade identifier
9017                if (timestamp == Value::Null) {
9018                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" removeRepeatedTradesFromArray() missing timestamp".into()))));
9019                }
9020                // optional parts are appended only when present, separators keep positions distinct
9021                id = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("t_".into()), Value::Str(format!("{}", timestamp).into())).into()), Value::Str("_".into())).into());
9022                if (side != Value::Null) {
9023                    id = Value::Str(format!("{}{}", id, side).into());
9024                }
9025                id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
9026                if (price != Value::Null) {
9027                    id = Value::Str(format!("{}{}", id, price).into());
9028                }
9029                id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
9030                if (amount != Value::Null) {
9031                    id = Value::Str(format!("{}{}", id, amount).into());
9032                }
9033            }
9034            if (id != Value::Null) && !(matches!((&uniqueResult, &id), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9035                if let Value::Dict(__d) = &mut uniqueResult { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&id), entry); }
9036            }
9037        }
9038        }
9039        let mut values: Value = Value::Array(uniqueResult.as_map().map(|__m| __m.values().cloned().collect()).unwrap_or_default());
9040        return values;
9041
9042    Value::Null
9043}
9044
9045    fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
9046        let mut keys: Value = object_keys(&dict);
9047        let mut newDict: Value = Value::Map({
9048            let mut m = indexmap::IndexMap::new();
9049            m
9050        });
9051        {
9052                        let mut i: Value = Value::Int(0);
9053            let mut __for_first_166: bool = true;
9054            while { if !__for_first_166 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_166 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
9055            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);
9056            if !(self.in_array(key.clone(), removeKeys.clone()).as_bool() == Some(true)) {
9057                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)); }
9058            }
9059        }
9060        }
9061        return newDict;
9062
9063    Value::Null
9064}
9065
9066    fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
9067        let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
9068        let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]);
9069        if (until != Value::Null) {
9070            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 }))); }
9071        }
9072        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 });
9073        return Value::from(vec![request, paramsOmitted]);
9074
9075    Value::Null
9076}
9077
9078    fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
9079        let mut market = get_arg(optional_args, 0, Value::Null);
9080        let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
9081        if (symbol == Value::Null) {
9082            symbol = self.safe_string_k(market, "symbol", &[]);
9083        }
9084        return self.extend(interest.clone(), &[Value::Map({
9085    let mut m = indexmap::IndexMap::new();
9086        m.insert("symbol".to_string(), symbol);
9087        m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
9088        m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
9089        m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
9090        m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
9091        m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
9092        m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
9093        m.insert("info".to_string(), self.safe_value_k(interest, "info", &[]));
9094    m
9095})]);
9096
9097    Value::Null
9098}
9099
9100    fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
9101        // virtual-dispatch (static: DerivedExchange::parse_liquidation(self, ...))
9102        { 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; } }
9103
9104        let mut market = get_arg(optional_args, 0, Value::Null);
9105        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLiquidation () is not supported yet".into()))));
9106
9107    Value::Null
9108}
9109
9110    fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
9111        let mut market = get_arg(optional_args, 0, Value::Null);
9112        let mut since = get_arg(optional_args, 1, Value::Null);
9113        let mut limit = get_arg(optional_args, 2, Value::Null);
9114        /*
9115         * @ignore
9116         * @method
9117         * @description parses liquidation info from the exchange response
9118         * @param {object[]} liquidations each item describes an instance of a liquidation event
9119         * @param {object} market ccxt market
9120         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
9121         * @param {int} [limit] limits the number of items in the response
9122         * @returns {object[]} an array of [liquidation structures]{@link https://docs.ccxt.com/?id=liquidation-structure}
9123         */
9124        let mut result: Vec<Value> = Vec::new();
9125        {
9126                        let mut i: Value = Value::Int(0);
9127            let mut __for_first_167: bool = true;
9128            while { if !__for_first_167 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_167 = false; i.as_f64().unwrap_or(f64::NAN) < ((liquidations.len() as i64) as f64) } {
9129            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);
9130            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry, &[market.clone()]);
9131            result.push(parsed);
9132        }
9133        }
9134        let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
9135        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
9136        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
9137
9138    Value::Null
9139}
9140
9141    fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
9142        // virtual-dispatch (static: DerivedExchange::parse_greeks(self, ...))
9143        { 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; } }
9144
9145        let mut market = get_arg(optional_args, 0, Value::Null);
9146        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseGreeks () is not supported yet".into()))));
9147
9148    Value::Null
9149}
9150
9151    fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
9152        let mut symbols = get_arg(optional_args, 0, Value::Null);
9153        let mut params = get_arg(optional_args, 1, Value::Map({
9154    let mut m = indexmap::IndexMap::new();
9155    m
9156}));
9157        //
9158        // the value of greeks is either a dict or a list
9159        //
9160        let mut results: Vec<Value> = Vec::new();
9161        if (matches!(&greeks, Value::Arr(_))) {
9162            {
9163                                let mut i: Value = Value::Int(0);
9164                let mut __for_first_168: bool = true;
9165                while { if !__for_first_168 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_168 = false; i.as_f64().unwrap_or(f64::NAN) < ((greeks.len() as i64) as f64) } {
9166                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), &[]);
9167                let mut greek: Value = self.extend(parsedTicker, &[params.clone()]);
9168                results.push(greek.clone());
9169            }
9170            }
9171        }  else {
9172            let mut marketIds: Value = object_keys(&greeks);
9173            {
9174                                let mut i: Value = Value::Int(0);
9175                let mut __for_first_169: bool = true;
9176                while { if !__for_first_169 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_169 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
9177                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);
9178                let mut market: Value = self.safe_market(&[marketId.clone()]);
9179                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market]);
9180                let mut greek: Value = self.extend(parsed, &[params.clone()]);
9181                results.push(greek);
9182            }
9183            }
9184        }
9185        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
9186        return self.index_by(self.filter_by_array(Value::from(results), Value::Str("symbol".into()), &[symbolsNormalized, Value::Bool(false)]), Value::Str("symbol".into()));
9187
9188    Value::Null
9189}
9190
9191    fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
9192        let mut currency = get_arg(optional_args, 0, Value::Null);
9193        let mut market = get_arg(optional_args, 1, Value::Null);
9194        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOption () is not supported yet".into()))));
9195
9196    Value::Null
9197}
9198
9199    fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
9200        let mut currencyKey = get_arg(optional_args, 0, Value::Null);
9201        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9202        let mut optionStructures: Value = Value::Map({
9203            let mut m = indexmap::IndexMap::new();
9204            m
9205        });
9206        {
9207                        let mut i: Value = Value::Int(0);
9208            let mut __for_first_170: bool = true;
9209            while { if !__for_first_170 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_170 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9210            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);
9211            let mut currencyId: Value = (if (currencyKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), currencyKey.clone(), &[]) });
9212            let mut currency: Value = self.safe_currency(currencyId, &[]);
9213            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9214            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("option".into())]);
9215            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()]));
9216        }
9217        }
9218        return optionStructures;
9219
9220    Value::Null
9221}
9222
9223    fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
9224        let mut symbols = get_arg(optional_args, 0, Value::Null);
9225        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9226        let mut marketType = get_arg(optional_args, 2, Value::Null);
9227        let mut marginModeStructures: Value = Value::Map({
9228            let mut m = indexmap::IndexMap::new();
9229            m
9230        });
9231        let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); // default to swap
9232        {
9233                        let mut i: Value = Value::Int(0);
9234            let mut __for_first_171: bool = true;
9235            while { if !__for_first_171 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_171 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9236            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);
9237            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9238            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9239            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) {
9240                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()]));
9241            }
9242        }
9243        }
9244        return marginModeStructures;
9245
9246    Value::Null
9247}
9248
9249    fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
9250        // virtual-dispatch (static: DerivedExchange::parse_margin_mode(self, ...))
9251        { 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; } }
9252
9253        let mut market = get_arg(optional_args, 0, Value::Null);
9254        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginMode () is not supported yet".into()))));
9255
9256    Value::Null
9257}
9258
9259    fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
9260        let mut symbols = get_arg(optional_args, 0, Value::Null);
9261        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9262        let mut marketType = get_arg(optional_args, 2, Value::Null);
9263        let mut leverageStructures: Value = Value::Map({
9264            let mut m = indexmap::IndexMap::new();
9265            m
9266        });
9267        let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); // default to swap
9268        {
9269                        let mut i: Value = Value::Int(0);
9270            let mut __for_first_172: bool = true;
9271            while { if !__for_first_172 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_172 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9272            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);
9273            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9274            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9275            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) {
9276                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()]));
9277            }
9278        }
9279        }
9280        return leverageStructures;
9281
9282    Value::Null
9283}
9284
9285    fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
9286        // virtual-dispatch (static: DerivedExchange::parse_leverage(self, ...))
9287        { 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; } }
9288
9289        let mut market = get_arg(optional_args, 0, Value::Null);
9290        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLeverage () is not supported yet".into()))));
9291
9292    Value::Null
9293}
9294
9295    fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
9296        let mut code = get_arg(optional_args, 0, Value::Null);
9297        let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
9298        let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
9299        let mut since = get_arg(optional_args, 3, Value::Null);
9300        let mut limit = get_arg(optional_args, 4, Value::Null);
9301        let mut params = get_arg(optional_args, 5, Value::Map({
9302    let mut m = indexmap::IndexMap::new();
9303    m
9304}));
9305        let mut conversionsArray: Value = self.to_array(conversions);
9306        let mut result: Vec<Value> = Vec::new();
9307        let mut fromCurrency: Value = Value::Null;
9308        let mut toCurrency: Value = Value::Null;
9309        {
9310                        let mut i: Value = Value::Int(0);
9311            let mut __for_first_173: bool = true;
9312            while { if !__for_first_173 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_173 = false; i.as_f64().unwrap_or(f64::NAN) < ((conversionsArray.len() as i64) as f64) } {
9313            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);
9314            let mut fromId: Value = (if (fromCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]) });
9315            let mut toId: Value = (if (toCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]) });
9316            if (fromId != Value::Null) {
9317                fromCurrency = self.safe_currency(fromId, &[]);
9318            }
9319            if (toId != Value::Null) {
9320                toCurrency = self.safe_currency(toId, &[]);
9321            }
9322            let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry, &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
9323            result.push(conversion);
9324        }
9325        }
9326        let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
9327        if (code == Value::Null) {
9328            return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
9329        }
9330        let mut currency: Value = self.safe_currency(code, &[]);
9331        if (currency == Value::Null) {
9332            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseConversions() could not resolve currency".into()))));
9333        }
9334        let mut currencyCode: Value = currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
9335        let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".into()), currencyCode.clone(), &[]);
9336        let mut toConversion: Value = self.filter_by(sorted, Value::Str("toCurrency".into()), currencyCode, &[]);
9337        let mut both: Value = self.array_concat(fromConversion, toConversion);
9338        return self.filter_by_since_limit(both, &[since, limit]);
9339
9340    Value::Null
9341}
9342
9343    fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
9344        // virtual-dispatch (static: DerivedExchange::parse_conversion(self, ...))
9345        { 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; } }
9346
9347        let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
9348        let mut toCurrency = get_arg(optional_args, 1, Value::Null);
9349        if (conversion == Value::Null) {
9350            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9351        }
9352        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9353
9354    Value::Null
9355}
9356
9357    fn convert_expire_date(&self, mut date: Value) -> Value {
9358        if (date == Value::Null) {
9359            return Value::Null;
9360        }
9361        // parse YYMMDD to datetime string
9362        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);
9363        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);
9364        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);
9365        // the milliseconds are spelled out because every caller writes the result into
9366        // expiryDatetime, which types.ts documents in the ISO 8601 form with them
9367        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());
9368        return reconstructedDate;
9369
9370    Value::Null
9371}
9372
9373    fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9374        if (date == Value::Null) {
9375            return Value::Null;
9376        }
9377        // parse 240119 to 19JAN24
9378        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);
9379        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);
9380        let mut month: Value = Value::Null;
9381        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);
9382        if (monthRaw.as_str() == Some("01")) {
9383            month = Value::Str("JAN".into());
9384        }  else if (monthRaw.as_str() == Some("02")) {
9385            month = Value::Str("FEB".into());
9386        }  else if (monthRaw.as_str() == Some("03")) {
9387            month = Value::Str("MAR".into());
9388        }  else if (monthRaw.as_str() == Some("04")) {
9389            month = Value::Str("APR".into());
9390        }  else if (monthRaw.as_str() == Some("05")) {
9391            month = Value::Str("MAY".into());
9392        }  else if (monthRaw.as_str() == Some("06")) {
9393            month = Value::Str("JUN".into());
9394        }  else if (monthRaw.as_str() == Some("07")) {
9395            month = Value::Str("JUL".into());
9396        }  else if (monthRaw.as_str() == Some("08")) {
9397            month = Value::Str("AUG".into());
9398        }  else if (monthRaw.as_str() == Some("09")) {
9399            month = Value::Str("SEP".into());
9400        }  else if (monthRaw.as_str() == Some("10")) {
9401            month = Value::Str("OCT".into());
9402        }  else if (monthRaw.as_str() == Some("11")) {
9403            month = Value::Str("NOV".into());
9404        }  else if (monthRaw.as_str() == Some("12")) {
9405            month = Value::Str("DEC".into());
9406        }
9407        if (month == Value::Null) {
9408            panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9409        }
9410        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9411        return reconstructedDate;
9412
9413    Value::Null
9414}
9415
9416    fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9417        if (date == Value::Null) {
9418            return Value::Null;
9419        }
9420        // parse 03JAN24 to 240103.
9421        let mut monthMappping: Value = Value::Map({
9422            let mut m = indexmap::IndexMap::new();
9423                m.insert("JAN".to_string(), Value::Str("01".into()));
9424                m.insert("FEB".to_string(), Value::Str("02".into()));
9425                m.insert("MAR".to_string(), Value::Str("03".into()));
9426                m.insert("APR".to_string(), Value::Str("04".into()));
9427                m.insert("MAY".to_string(), Value::Str("05".into()));
9428                m.insert("JUN".to_string(), Value::Str("06".into()));
9429                m.insert("JUL".to_string(), Value::Str("07".into()));
9430                m.insert("AUG".to_string(), Value::Str("08".into()));
9431                m.insert("SEP".to_string(), Value::Str("09".into()));
9432                m.insert("OCT".to_string(), Value::Str("10".into()));
9433                m.insert("NOV".to_string(), Value::Str("11".into()));
9434                m.insert("DEC".to_string(), Value::Str("12".into()));
9435            m
9436        });
9437        // if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
9438        let mut datePadded: Value = date.clone();
9439        if (Value::Int(date.len() as i64).as_f64() == Some(6.0)) {
9440            datePadded = Value::Str(format!("{}{}", Value::Str("0".into()), date).into());
9441        }
9442        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);
9443        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);
9444        let mut month: Value = self.safe_string(monthMappping, monthName, &[]);
9445        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);
9446        if (month == Value::Null) {
9447            panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9448        }
9449        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9450        return reconstructedDate;
9451
9452    Value::Null
9453}
9454
9455    fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9456        promise_all(&Value::from(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9457
9458    Value::Null
9459} }
9460
9461    fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9462        // virtual-dispatch (static: DerivedExchange::parse_margin_modification(self, ...))
9463        { 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; } }
9464
9465        let mut market = get_arg(optional_args, 0, Value::Null);
9466        if (data == Value::Null) {
9467            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9468        }
9469        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9470
9471    Value::Null
9472}
9473
9474    fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9475        let mut symbols = get_arg(optional_args, 0, Value::Null);
9476        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9477        let mut marketType = get_arg(optional_args, 2, Value::Null);
9478        let mut marginModifications: Vec<Value> = Vec::new();
9479        if (response == Value::Null) {
9480            return Value::from(marginModifications);
9481        }
9482        {
9483                        let mut i: Value = Value::Int(0);
9484            let mut __for_first_174: bool = true;
9485            while { if !__for_first_174 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_174 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9486            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);
9487            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9488            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
9489            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) {
9490                marginModifications.push(<Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info, &[market]));
9491            }
9492        }
9493        }
9494        return Value::from(marginModifications);
9495
9496    Value::Null
9497}
9498
9499    fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9500        let mut code = get_arg(optional_args, 0, Value::Null);
9501        let mut params = get_arg(optional_args, 1, Value::Map({
9502    let mut m = indexmap::IndexMap::new();
9503    m
9504}));
9505        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfer () is not supported yet".into()))));
9506
9507    Value::Null
9508} }
9509
9510    fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9511        let mut code = get_arg(optional_args, 0, Value::Null);
9512        let mut since = get_arg(optional_args, 1, Value::Null);
9513        let mut limit = get_arg(optional_args, 2, Value::Null);
9514        let mut params = get_arg(optional_args, 3, Value::Map({
9515    let mut m = indexmap::IndexMap::new();
9516    m
9517}));
9518        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfers () is not supported yet".into()))));
9519
9520    Value::Null
9521} }
9522
9523    fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9524        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
9525        let mut params = get_arg(optional_args, 1, Value::Map({
9526    let mut m = indexmap::IndexMap::new();
9527    m
9528}));
9529        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCV () is not supported yet".into()))));
9530
9531    Value::Null
9532} }
9533
9534    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 {
9535        let mut params = get_arg(optional_args, 0, Value::Map({
9536    let mut m = indexmap::IndexMap::new();
9537    m
9538}));
9539        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdrawWs () is not supported yet".into()))));
9540
9541    Value::Null
9542} }
9543
9544    fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9545        let mut symbol = get_arg(optional_args, 0, Value::Null);
9546        let mut params = get_arg(optional_args, 1, Value::Map({
9547    let mut m = indexmap::IndexMap::new();
9548    m
9549}));
9550        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMyTrades () is not supported yet".into()))));
9551
9552    Value::Null
9553} }
9554
9555    fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9556        let mut symbol = get_arg(optional_args, 0, Value::Null);
9557        let mut since = get_arg(optional_args, 1, Value::Null);
9558        let mut limit = get_arg(optional_args, 2, Value::Null);
9559        let mut params = get_arg(optional_args, 3, Value::Map({
9560    let mut m = indexmap::IndexMap::new();
9561    m
9562}));
9563        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersByStatusWs () is not supported yet".into()))));
9564
9565    Value::Null
9566} }
9567
9568    fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9569        let mut symbols = get_arg(optional_args, 0, Value::Null);
9570        let mut params = get_arg(optional_args, 1, Value::Map({
9571    let mut m = indexmap::IndexMap::new();
9572    m
9573}));
9574        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchBidsAsks () is not supported yet".into()))));
9575
9576    Value::Null
9577} }
9578
9579    fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9580        let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9581        if (unsubHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &unsubHash)) {
9582            remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &unsubHash);
9583        }
9584        if !is_true(&subHashIsPrefix) {
9585            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &subHash)) {
9586                remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &subHash);
9587            }
9588            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("futures".into())), &subHash)) {
9589                let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), subHash));
9590                client.reject(&[Value::from(error.clone()), subHash.clone()]);
9591            }
9592        }  else {
9593            let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".into())));
9594            {
9595                                let mut i: Value = Value::Int(0);
9596                let mut __for_first_175: bool = true;
9597                while { if !__for_first_175 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_175 = false; i.as_f64().unwrap_or(f64::NAN) < ((clientSubscriptions.len() as i64) as f64) } {
9598                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);
9599                if (sub != Value::Null) && (subHash != Value::Null) && (sub.as_str().zip(subHash.as_str()).is_some_and(|(__s, __p)| __s.starts_with(__p))) {
9600                    remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &sub);
9601                }
9602            }
9603            }
9604            let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
9605            {
9606                                let mut i: Value = Value::Int(0);
9607                let mut __for_first_176: bool = true;
9608                while { if !__for_first_176 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_176 = false; i.as_f64().unwrap_or(f64::NAN) < ((clientFutures.len() as i64) as f64) } {
9609                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);
9610                if (future != Value::Null) && (subHash != Value::Null) && (future.as_str().zip(subHash.as_str()).is_some_and(|(__s, __p)| __s.starts_with(__p))) {
9611                    let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), future));
9612                    client.reject(&[Value::from(error), future]);
9613                }
9614            }
9615            }
9616        }
9617        client.resolve(&[Value::Bool(true), unsubHash]);
9618}
9619
9620    fn clean_cache(&mut self, mut subscription: Value) {
9621        let __subscription_empty = indexmap::IndexMap::new();
9622        let subscription = subscription.as_map().unwrap_or(&__subscription_empty);
9623        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);
9624        let mut symbols: Value = (match subscription.get("symbols") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9625        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
9626        if (topic.as_deref() == Some("ohlcv")) {
9627            let mut symbolsAndTimeframes: Value = (match subscription.get("symbolsAndTimeframes") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9628            {
9629                                let mut i: Value = Value::Int(0);
9630                let mut __for_first_177: bool = true;
9631                while { if !__for_first_177 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_177 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbolsAndTimeframes.len() as i64) as f64) } {
9632                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9633                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9634                let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9635                let mut timeframe: Value = self.safe_string(symbolAndTimeFrame, Value::Int(1), &[]);
9636                if (symbol == Value::Null) {
9637                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a symbol argument".into()))));
9638                }
9639                if (timeframe == Value::Null) {
9640                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a timeframe argument".into()))));
9641                }
9642                if (self.ohlcvs.clone() != Value::Null) && (matches!((&self.ohlcvs, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9643                    if (in_op(&self.ohlcvs.as_map().and_then(|__m| symbol.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &timeframe)) {
9644                        remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
9645                    }
9646                }
9647            }
9648            }
9649        }  else if symbolsLength > ((0i64) as f64) {
9650            {
9651                                let mut i: Value = Value::Int(0);
9652                let mut __for_first_178: bool = true;
9653                while { if !__for_first_178 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_178 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
9654                let mut symbol: Value = get_value(&symbols, &i);
9655                let mut symbol: Value = get_value(&symbols, &i);
9656                if (topic.as_deref() == Some("trades")) {
9657                    if (matches!((&self.trades, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9658                        if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.trades.clone(), &symbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9659                    }
9660                }  else if (topic.as_deref() == Some("orderbook")) {
9661                    if (matches!((&self.orderbooks, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9662                        if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.orderbooks.clone(), &symbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9663                    }
9664                }  else if (topic.as_deref() == Some("ticker")) {
9665                    if (matches!((&self.tickers, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9666                        if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.tickers.clone(), &symbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9667                    }
9668                }  else if (topic.as_deref() == Some("bidsasks")) {
9669                    if (matches!((&self.bidsasks, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9670                        if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.bidsasks.clone(), &symbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9671                    }
9672                }
9673            }
9674            }
9675        }  else {
9676            if (topic.as_deref() == Some("myTrades")) && (self.myTrades.clone() != Value::Null) {
9677                self.myTrades = Value::Null;
9678            }  else if (topic.as_deref() == Some("orders")) && (self.orders.clone() != Value::Null) {
9679                self.orders = Value::Null;
9680            }  else if (topic.as_deref() == Some("positions")) && (self.positions.clone() != Value::Null) {
9681                self.positions = Value::Null;
9682                let mut clients: Value = Value::Array(self.clients.as_map().map(|__m| __m.values().cloned().collect()).unwrap_or_default());
9683                {
9684                                        let mut i: Value = Value::Int(0);
9685                    let mut __for_first_179: bool = true;
9686                    while { if !__for_first_179 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_179 = false; i.as_f64().unwrap_or(f64::NAN) < ((clients.len() as i64) as f64) } {
9687                    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);
9688                    let mut futures: Value = get_value(&client, &Value::Str("futures".into()));
9689                    if (futures != Value::Null) && (matches!(&futures, Value::Dict(__d) if __d.contains_key("fetchPositionsSnapshot"))) {
9690                        remove(&mut futures, &Value::Str("fetchPositionsSnapshot".into()));
9691                    }
9692                }
9693                }
9694            }  else if ((topic.as_deref() == Some("ticker")) || (topic.as_deref() == Some("markPrice"))) && (self.tickers.clone() != Value::Null) {
9695                let mut tickerSymbols: Value = Value::Array(self.tickers.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
9696                {
9697                                        let mut i: Value = Value::Int(0);
9698                    let mut __for_first_180: bool = true;
9699                    while { if !__for_first_180 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_180 = false; i.as_f64().unwrap_or(f64::NAN) < ((tickerSymbols.len() as i64) as f64) } {
9700                    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);
9701                    if (matches!((&self.tickers, &tickerSymbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9702                        if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.tickers.clone(), &tickerSymbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9703                    }
9704                }
9705                }
9706            }  else if (topic.as_deref() == Some("bidsasks")) && (self.bidsasks.clone() != Value::Null) {
9707                let mut bidsaskSymbols: Value = Value::Array(self.bidsasks.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
9708                {
9709                                        let mut i: Value = Value::Int(0);
9710                    let mut __for_first_181: bool = true;
9711                    while { if !__for_first_181 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_181 = false; i.as_f64().unwrap_or(f64::NAN) < ((bidsaskSymbols.len() as i64) as f64) } {
9712                    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);
9713                    if (matches!((&self.bidsasks, &bidsaskSymbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9714                        if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.bidsasks.clone(), &bidsaskSymbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9715                    }
9716                }
9717                }
9718            }
9719        }
9720}
9721
9722    fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9723        let mut msInt: Value = self.parse_to_int(ms);
9724        if msInt.as_f64().unwrap_or(f64::NAN) <= ((0i64) as f64) {
9725            return Value::Str("".into());
9726        }
9727        let mut second: Value = Value::Int(1000);
9728        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 });
9729        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 });
9730        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 });
9731        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 });
9732        if ((match (&(msInt), &(week)) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9733            return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (week).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("w".into())).into());
9734        }
9735        if ((match (&(msInt), &(day)) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9736            return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (day).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("d".into())).into());
9737        }
9738        if ((match (&(msInt), &(hour)) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9739            return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (hour).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("h".into())).into());
9740        }
9741        if ((match (&(msInt), &(minute)) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9742            return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (minute).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("m".into())).into());
9743        }
9744        if ((match (&(msInt), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9745            return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("s".into())).into());
9746        }
9747        return Value::Str("".into());
9748
9749    Value::Null
9750}
9751
9752    fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9753        let mut params = get_arg(optional_args, 0, Value::Map({
9754    let mut m = indexmap::IndexMap::new();
9755    m
9756}));
9757        return Value::Bool(false);
9758
9759    Value::Null
9760} }
9761    fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9762        let mut side = get_arg(optional_args, 0, Value::Null);
9763        let mut params = get_arg(optional_args, 1, Value::Map({
9764    let mut m = indexmap::IndexMap::new();
9765    m
9766}));
9767        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closePosition() is not supported yet".into()))));
9768
9769    Value::Null
9770} }
9771
9772    fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9773        let mut params = get_arg(optional_args, 0, Value::Map({
9774    let mut m = indexmap::IndexMap::new();
9775    m
9776}));
9777        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closeAllPositions() is not supported yet".into()))));
9778
9779    Value::Null
9780} }
9781
9782    fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9783        let mut params = get_arg(optional_args, 0, Value::Map({
9784    let mut m = indexmap::IndexMap::new();
9785    m
9786}));
9787        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" editOrders() is not supported yet".into()))));
9788
9789    Value::Null
9790} }
9791
9792    fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9793        let mut symbol = get_arg(optional_args, 0, Value::Null);
9794        let mut since = get_arg(optional_args, 1, Value::Null);
9795        let mut limit = get_arg(optional_args, 2, Value::Null);
9796        let mut params = get_arg(optional_args, 3, Value::Map({
9797    let mut m = indexmap::IndexMap::new();
9798    m
9799}));
9800        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".into()))));
9801
9802    Value::Null
9803} }
9804
9805    fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9806        // async-virtual: try the derived exchange first
9807        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 {
9808            if !matches!(__v, crate::Value::Null) { return __v; }
9809        }
9810
9811        let mut since = get_arg(optional_args, 0, Value::Null);
9812        let mut limit = get_arg(optional_args, 1, Value::Null);
9813        let mut params = get_arg(optional_args, 2, Value::Map({
9814    let mut m = indexmap::IndexMap::new();
9815    m
9816}));
9817        /*
9818         * @method
9819         * @name exchange#fetchPositionHistory
9820         * @description fetches the history of margin added or reduced from contract isolated positions
9821         * @param {string} [symbol] unified market symbol
9822         * @param {int} [since] timestamp in ms of the position
9823         * @param {int} [limit] the maximum amount of candles to fetch, default=1000
9824         * @param {object} params extra parameters specific to the exchange api endpoint
9825         * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
9826         */
9827        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)) {
9828            return self.fetch_positions_history(&[Value::from(vec![symbol]), since, limit, params]).await;
9829        }  else {
9830            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionHistory () is not supported yet".into()))));
9831        }
9832} }
9833
9834    fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9835        // async-virtual: try the derived exchange first
9836        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 {
9837            if !matches!(__v, crate::Value::Null) { return __v; }
9838        }
9839
9840        let mut symbols = get_arg(optional_args, 0, Value::Null);
9841        let mut since = get_arg(optional_args, 1, Value::Null);
9842        let mut limit = get_arg(optional_args, 2, Value::Null);
9843        let mut params = get_arg(optional_args, 3, Value::Map({
9844    let mut m = indexmap::IndexMap::new();
9845    m
9846}));
9847        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsHistory () is not supported yet".into()))));
9848
9849    Value::Null
9850} }
9851
9852    fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9853        let mut symbols = get_arg(optional_args, 0, Value::Null);
9854        let mut params = get_arg(optional_args, 1, Value::Map({
9855    let mut m = indexmap::IndexMap::new();
9856    m
9857}));
9858        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsRisk() is not supported yet".into()))));
9859
9860    Value::Null
9861} }
9862
9863    fn fetch_positions_for_symbol(&mut self, mut symbol: 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        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9869
9870    Value::Null
9871} }
9872
9873    fn fetch_positions_for_symbol_ws(&mut self, mut symbol: 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        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9879
9880    Value::Null
9881} }
9882
9883    fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9884        let mut symbol = get_arg(optional_args, 0, Value::Null);
9885        let mut params = get_arg(optional_args, 1, Value::Map({
9886    let mut m = indexmap::IndexMap::new();
9887    m
9888}));
9889        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPosition() is not supported yet".into()))));
9890
9891    Value::Null
9892} }
9893
9894    fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9895        let mut since = get_arg(optional_args, 0, Value::Null);
9896        let mut limit = get_arg(optional_args, 1, Value::Null);
9897        let mut params = get_arg(optional_args, 2, Value::Map({
9898    let mut m = indexmap::IndexMap::new();
9899    m
9900}));
9901        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTradesForSymbols() is not supported yet".into()))));
9902
9903    Value::Null
9904} }
9905
9906    fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9907        let mut since = get_arg(optional_args, 0, Value::Null);
9908        let mut limit = get_arg(optional_args, 1, Value::Null);
9909        let mut params = get_arg(optional_args, 2, Value::Map({
9910    let mut m = indexmap::IndexMap::new();
9911    m
9912}));
9913        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTradesForSymbols() is not supported yet".into()))));
9914
9915    Value::Null
9916} }
9917
9918    fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9919        let mut symbols = get_arg(optional_args, 0, Value::Null);
9920        let mut params = get_arg(optional_args, 1, Value::Map({
9921    let mut m = indexmap::IndexMap::new();
9922    m
9923}));
9924        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBidsAsks() is not supported yet".into()))));
9925
9926    Value::Null
9927} }
9928
9929    fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9930        let mut params = get_arg(optional_args, 0, Value::Map({
9931    let mut m = indexmap::IndexMap::new();
9932    m
9933}));
9934        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)) {
9935            self.load_markets(&[]).await;
9936            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
9937            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
9938            let mut tickers: Value = self.fetch_mark_prices(&[Value::from(vec![symbolResolved.clone()]), params]).await;
9939            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
9940            if (ticker == Value::Null) {
9941                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)));
9942            }  else {
9943                return ticker;
9944            }
9945        }  else {
9946            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9947        }
9948
9949    Value::Null
9950} }
9951
9952    fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9953        let mut symbols = get_arg(optional_args, 0, Value::Null);
9954        let mut params = get_arg(optional_args, 1, Value::Map({
9955    let mut m = indexmap::IndexMap::new();
9956    m
9957}));
9958        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9959
9960    Value::Null
9961} }
9962
9963    fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9964        let mut symbols = get_arg(optional_args, 0, Value::Null);
9965        let mut params = get_arg(optional_args, 1, Value::Map({
9966    let mut m = indexmap::IndexMap::new();
9967    m
9968}));
9969        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBidsAsks() is not supported yet".into()))));
9970
9971    Value::Null
9972} }
9973
9974    fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9975        let mut params = get_arg(optional_args, 0, Value::Map({
9976    let mut m = indexmap::IndexMap::new();
9977    m
9978}));
9979        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrice () is not supported yet".into()))));
9980
9981    Value::Null
9982} }
9983
9984    fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9985        let mut symbols = get_arg(optional_args, 0, Value::Null);
9986        let mut params = get_arg(optional_args, 1, Value::Map({
9987    let mut m = indexmap::IndexMap::new();
9988    m
9989}));
9990        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrices () is not supported yet".into()))));
9991
9992    Value::Null
9993} }
9994
9995    fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9996        let mut limit = get_arg(optional_args, 0, Value::Null);
9997        let mut params = get_arg(optional_args, 1, Value::Map({
9998    let mut m = indexmap::IndexMap::new();
9999    m
10000}));
10001        panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchL3OrderBook() is not supported yet".into()))));
10002
10003    Value::Null
10004} }
10005
10006    fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10007        let mut limit = get_arg(optional_args, 0, Value::Null);
10008        let mut params = get_arg(optional_args, 1, Value::Map({
10009    let mut m = indexmap::IndexMap::new();
10010    m
10011}));
10012        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBookForSymbols() is not supported yet".into()))));
10013
10014    Value::Null
10015} }
10016
10017    fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10018        let mut since = get_arg(optional_args, 0, Value::Null);
10019        let mut limit = get_arg(optional_args, 1, Value::Null);
10020        let mut params = get_arg(optional_args, 2, Value::Map({
10021    let mut m = indexmap::IndexMap::new();
10022    m
10023}));
10024        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrdersForSymbols() is not supported yet".into()))));
10025
10026    Value::Null
10027} }
10028
10029    fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10030        let mut symbol = get_arg(optional_args, 0, Value::Null);
10031        let mut params = get_arg(optional_args, 1, Value::Map({
10032    let mut m = indexmap::IndexMap::new();
10033    m
10034}));
10035        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersWs() is not supported yet".into()))));
10036
10037    Value::Null
10038} }
10039
10040    fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10041        let mut symbol = get_arg(optional_args, 0, Value::Null);
10042        let mut params = get_arg(optional_args, 1, Value::Map({
10043    let mut m = indexmap::IndexMap::new();
10044    m
10045}));
10046        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrderWs() is not supported yet".into()))));
10047
10048    Value::Null
10049} }
10050
10051    fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10052        let mut symbol = get_arg(optional_args, 0, Value::Null);
10053        let mut params = get_arg(optional_args, 1, Value::Map({
10054    let mut m = indexmap::IndexMap::new();
10055    m
10056}));
10057        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersWs() is not supported yet".into()))));
10058
10059    Value::Null
10060} }
10061
10062    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 {
10063        let mut params = get_arg(optional_args, 0, Value::Map({
10064    let mut m = indexmap::IndexMap::new();
10065    m
10066}));
10067        return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
10068
10069    Value::Null
10070} }
10071
10072    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 {
10073        let mut params = get_arg(optional_args, 0, Value::Map({
10074    let mut m = indexmap::IndexMap::new();
10075    m
10076}));
10077        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
10078
10079    Value::Null
10080} }
10081
10082    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 {
10083        let mut params = get_arg(optional_args, 0, Value::Map({
10084    let mut m = indexmap::IndexMap::new();
10085    m
10086}));
10087        return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
10088
10089    Value::Null
10090} }
10091
10092    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 {
10093        let mut params = get_arg(optional_args, 0, Value::Map({
10094    let mut m = indexmap::IndexMap::new();
10095    m
10096}));
10097        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
10098
10099    Value::Null
10100} }
10101
10102    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 {
10103        let mut params = get_arg(optional_args, 0, Value::Map({
10104    let mut m = indexmap::IndexMap::new();
10105    m
10106}));
10107        /*
10108         * @method
10109         * @name createMarketOrderWithCostWs
10110         * @description create a market order by providing the symbol, side and cost
10111         * @param {string} symbol unified symbol of the market to create an order in
10112         * @param {string} side 'buy' or 'sell'
10113         * @param {float} cost how much you want to trade in units of the quote currency
10114         * @param {object} [params] extra parameters specific to the exchange API endpoint
10115         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10116         */
10117        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)))) {
10118            return self.create_order_ws(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
10119        }
10120        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCostWs() is not supported yet".into()))));
10121
10122    Value::Null
10123} }
10124
10125    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 {
10126        let mut price = get_arg(optional_args, 0, Value::Null);
10127        let mut params = get_arg(optional_args, 1, Value::Map({
10128    let mut m = indexmap::IndexMap::new();
10129    m
10130}));
10131        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
10132
10133    Value::Null
10134} }
10135
10136    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 {
10137        let mut params = get_arg(optional_args, 0, Value::Map({
10138    let mut m = indexmap::IndexMap::new();
10139    m
10140}));
10141        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
10142
10143    Value::Null
10144} }
10145
10146    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 {
10147        let mut price = get_arg(optional_args, 0, Value::Null);
10148        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
10149        let mut stopLoss = 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 createOrderWithTakeProfitAndStopLossWs
10157         * @description create an order with a stop loss or take profit attached (type 3)
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 the number of contracts
10162         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10163         * @param {float} [takeProfit] the take profit price, in units of the quote currency
10164         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
10165         * @param {object} [params] extra parameters specific to the exchange API endpoint
10166         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
10167         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
10168         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
10169         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
10170         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
10171         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
10172         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
10173         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
10174         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10175         */
10176        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()]);
10177        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)) {
10178            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsValue]).await;
10179        }
10180        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".into()))));
10181
10182    Value::Null
10183} }
10184
10185    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 {
10186        let mut price = get_arg(optional_args, 0, Value::Null);
10187        let mut params = get_arg(optional_args, 1, Value::Map({
10188    let mut m = indexmap::IndexMap::new();
10189    m
10190}));
10191        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWs() is not supported yet".into()))));
10192
10193    Value::Null
10194} }
10195
10196    fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10197        let mut params = get_arg(optional_args, 0, Value::Map({
10198    let mut m = indexmap::IndexMap::new();
10199    m
10200}));
10201        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrdersWs () is not supported yet".into()))));
10202
10203    Value::Null
10204} }
10205
10206    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 {
10207        let mut price = get_arg(optional_args, 0, Value::Null);
10208        let mut params = get_arg(optional_args, 1, Value::Map({
10209    let mut m = indexmap::IndexMap::new();
10210    m
10211}));
10212        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)) {
10213            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrderWs() is not supported yet".into()))));
10214        }
10215        let mut query: Value = self.extend(params, &[Value::Map({
10216            let mut m = indexmap::IndexMap::new();
10217                m.insert("postOnly".to_string(), Value::Bool(true));
10218            m
10219        })]);
10220        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10221
10222    Value::Null
10223} }
10224
10225    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 {
10226        let mut price = get_arg(optional_args, 0, Value::Null);
10227        let mut params = get_arg(optional_args, 1, Value::Map({
10228    let mut m = indexmap::IndexMap::new();
10229    m
10230}));
10231        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)) {
10232            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrderWs() is not supported yet".into()))));
10233        }
10234        let mut query: Value = self.extend(params, &[Value::Map({
10235            let mut m = indexmap::IndexMap::new();
10236                m.insert("reduceOnly".to_string(), Value::Bool(true));
10237            m
10238        })]);
10239        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10240
10241    Value::Null
10242} }
10243
10244    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 {
10245        let mut params = get_arg(optional_args, 0, Value::Map({
10246    let mut m = indexmap::IndexMap::new();
10247    m
10248}));
10249        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)) {
10250            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrderWs() is not supported yet".into()))));
10251        }
10252        let mut query: Value = self.extend(params, &[Value::Map({
10253            let mut m = indexmap::IndexMap::new();
10254                m.insert("stopPrice".to_string(), triggerPrice);
10255            m
10256        })]);
10257        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
10258
10259    Value::Null
10260} }
10261
10262    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 {
10263        let mut price = get_arg(optional_args, 0, Value::Null);
10264        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10265        let mut params = get_arg(optional_args, 2, Value::Map({
10266    let mut m = indexmap::IndexMap::new();
10267    m
10268}));
10269        /*
10270         * @method
10271         * @name createStopLossOrderWs
10272         * @description create a trigger stop loss order (type 2)
10273         * @param {string} symbol unified symbol of the market to create an order in
10274         * @param {string} type 'market' or 'limit'
10275         * @param {string} side 'buy' or 'sell'
10276         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10277         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10278         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
10279         * @param {object} [params] extra parameters specific to the exchange API endpoint
10280         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10281         */
10282        if (stopLossPrice == Value::Null) {
10283            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".into()))));
10284        }
10285        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10286            let mut m = indexmap::IndexMap::new();
10287                m.insert("stopLossPrice".to_string(), stopLossPrice);
10288            m
10289        })]);
10290        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)) {
10291            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10292        }
10293        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() is not supported yet".into()))));
10294
10295    Value::Null
10296} }
10297
10298    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 {
10299        let mut params = get_arg(optional_args, 0, Value::Map({
10300    let mut m = indexmap::IndexMap::new();
10301    m
10302}));
10303        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)) {
10304            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrderWs() is not supported yet".into()))));
10305        }
10306        let mut query: Value = self.extend(params, &[Value::Map({
10307            let mut m = indexmap::IndexMap::new();
10308                m.insert("stopPrice".to_string(), triggerPrice);
10309            m
10310        })]);
10311        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
10312
10313    Value::Null
10314} }
10315
10316    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 {
10317        let mut price = get_arg(optional_args, 0, Value::Null);
10318        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10319        let mut params = get_arg(optional_args, 2, Value::Map({
10320    let mut m = indexmap::IndexMap::new();
10321    m
10322}));
10323        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)) {
10324            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() is not supported yet".into()))));
10325        }
10326        if (triggerPrice == Value::Null) {
10327            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() requires a stopPrice argument".into()))));
10328        }
10329        let mut query: Value = self.extend(params, &[Value::Map({
10330            let mut m = indexmap::IndexMap::new();
10331                m.insert("stopPrice".to_string(), triggerPrice);
10332            m
10333        })]);
10334        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10335
10336    Value::Null
10337} }
10338
10339    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 {
10340        let mut price = get_arg(optional_args, 0, Value::Null);
10341        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10342        let mut params = get_arg(optional_args, 2, Value::Map({
10343    let mut m = indexmap::IndexMap::new();
10344    m
10345}));
10346        /*
10347         * @method
10348         * @name createTakeProfitOrderWs
10349         * @description create a trigger take profit order (type 2)
10350         * @param {string} symbol unified symbol of the market to create an order in
10351         * @param {string} type 'market' or 'limit'
10352         * @param {string} side 'buy' or 'sell'
10353         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10354         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10355         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
10356         * @param {object} [params] extra parameters specific to the exchange API endpoint
10357         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10358         */
10359        if (takeProfitPrice == Value::Null) {
10360            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".into()))));
10361        }
10362        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10363            let mut m = indexmap::IndexMap::new();
10364                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
10365            m
10366        })]);
10367        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)) {
10368            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10369        }
10370        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() is not supported yet".into()))));
10371
10372    Value::Null
10373} }
10374
10375    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 {
10376        let mut price = get_arg(optional_args, 0, Value::Null);
10377        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10378        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10379        let mut params = get_arg(optional_args, 3, Value::Map({
10380    let mut m = indexmap::IndexMap::new();
10381    m
10382}));
10383        /*
10384         * @method
10385         * @name createTrailingAmountOrderWs
10386         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
10387         * @param {string} symbol unified symbol of the market to create an order in
10388         * @param {string} type 'market' or 'limit'
10389         * @param {string} side 'buy' or 'sell'
10390         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10391         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10392         * @param {float} trailingAmount the quote amount to trail away from the current market price
10393         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10394         * @param {object} [params] extra parameters specific to the exchange API endpoint
10395         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10396         */
10397        if (trailingAmount == Value::Null) {
10398            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".into()))));
10399        }
10400        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10401        if (trailingTriggerPrice != Value::Null) {
10402            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10403        }
10404        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)) {
10405            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10406        }
10407        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() is not supported yet".into()))));
10408
10409    Value::Null
10410} }
10411
10412    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 {
10413        let mut price = get_arg(optional_args, 0, Value::Null);
10414        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10415        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10416        let mut params = get_arg(optional_args, 3, Value::Map({
10417    let mut m = indexmap::IndexMap::new();
10418    m
10419}));
10420        /*
10421         * @method
10422         * @name createTrailingPercentOrderWs
10423         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
10424         * @param {string} symbol unified symbol of the market to create an order in
10425         * @param {string} type 'market' or 'limit'
10426         * @param {string} side 'buy' or 'sell'
10427         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10428         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10429         * @param {float} trailingPercent the percent to trail away from the current market price
10430         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10431         * @param {object} [params] extra parameters specific to the exchange API endpoint
10432         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10433         */
10434        if (trailingPercent == Value::Null) {
10435            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".into()))));
10436        }
10437        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10438        if (trailingTriggerPrice != Value::Null) {
10439            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10440        }
10441        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)) {
10442            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10443        }
10444        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() is not supported yet".into()))));
10445
10446    Value::Null
10447} }
10448
10449    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 {
10450        let mut price = get_arg(optional_args, 0, Value::Null);
10451        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10452        let mut params = get_arg(optional_args, 2, Value::Map({
10453    let mut m = indexmap::IndexMap::new();
10454    m
10455}));
10456        /*
10457         * @method
10458         * @name createTriggerOrderWs
10459         * @description create a trigger stop order (type 1)
10460         * @param {string} symbol unified symbol of the market to create an order in
10461         * @param {string} type 'market' or 'limit'
10462         * @param {string} side 'buy' or 'sell'
10463         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10464         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10465         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10466         * @param {object} [params] extra parameters specific to the exchange API endpoint
10467         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10468         */
10469        if (triggerPrice == Value::Null) {
10470            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".into()))));
10471        }
10472        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10473            let mut m = indexmap::IndexMap::new();
10474                m.insert("triggerPrice".to_string(), triggerPrice);
10475            m
10476        })]);
10477        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)) {
10478            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10479        }
10480        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() is not supported yet".into()))));
10481
10482    Value::Null
10483} }
10484
10485    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 {
10486        let mut amount = get_arg(optional_args, 0, Value::Null);
10487        let mut price = get_arg(optional_args, 1, Value::Null);
10488        let mut params = get_arg(optional_args, 2, Value::Map({
10489    let mut m = indexmap::IndexMap::new();
10490    m
10491}));
10492        self.cancel_order_ws(id, &[symbol.clone()]).await;
10493        return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10494
10495    Value::Null
10496} }
10497
10498    fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10499        let mut symbol = get_arg(optional_args, 0, Value::Null);
10500        let mut since = get_arg(optional_args, 1, Value::Null);
10501        let mut limit = get_arg(optional_args, 2, Value::Null);
10502        let mut params = get_arg(optional_args, 3, Value::Map({
10503    let mut m = indexmap::IndexMap::new();
10504    m
10505}));
10506        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)) {
10507            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10508            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
10509        }
10510        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrdersWs() is not supported yet".into()))));
10511
10512    Value::Null
10513} }
10514
10515    fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10516        let mut symbol = get_arg(optional_args, 0, Value::Null);
10517        let mut since = get_arg(optional_args, 1, Value::Null);
10518        let mut limit = get_arg(optional_args, 2, Value::Null);
10519        let mut params = get_arg(optional_args, 3, Value::Map({
10520    let mut m = indexmap::IndexMap::new();
10521    m
10522}));
10523        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTradesWs() is not supported yet".into()))));
10524
10525    Value::Null
10526} }
10527
10528    fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10529        let mut symbol = get_arg(optional_args, 0, Value::Null);
10530        let mut since = get_arg(optional_args, 1, Value::Null);
10531        let mut limit = get_arg(optional_args, 2, Value::Null);
10532        let mut params = get_arg(optional_args, 3, Value::Map({
10533    let mut m = indexmap::IndexMap::new();
10534    m
10535}));
10536        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)) {
10537            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10538            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
10539        }
10540        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrdersWs() is not supported yet".into()))));
10541
10542    Value::Null
10543} }
10544
10545    fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10546        let mut limit = get_arg(optional_args, 0, Value::Null);
10547        let mut params = get_arg(optional_args, 1, Value::Map({
10548    let mut m = indexmap::IndexMap::new();
10549    m
10550}));
10551        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBookWs() is not supported yet".into()))));
10552
10553    Value::Null
10554} }
10555
10556    fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10557        let mut symbol = get_arg(optional_args, 0, Value::Null);
10558        let mut params = get_arg(optional_args, 1, Value::Map({
10559    let mut m = indexmap::IndexMap::new();
10560    m
10561}));
10562        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderWs() is not supported yet".into()))));
10563
10564    Value::Null
10565} }
10566
10567    fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10568        let mut symbol = get_arg(optional_args, 0, Value::Null);
10569        let mut since = get_arg(optional_args, 1, Value::Null);
10570        let mut limit = get_arg(optional_args, 2, Value::Null);
10571        let mut params = get_arg(optional_args, 3, Value::Map({
10572    let mut m = indexmap::IndexMap::new();
10573    m
10574}));
10575        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersWs() is not supported yet".into()))));
10576
10577    Value::Null
10578} }
10579
10580    fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10581        let mut params = get_arg(optional_args, 0, Value::Map({
10582    let mut m = indexmap::IndexMap::new();
10583    m
10584}));
10585        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionWs() is not supported yet".into()))));
10586
10587    Value::Null
10588} }
10589
10590    fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10591        let mut symbols = get_arg(optional_args, 0, Value::Null);
10592        let mut params = get_arg(optional_args, 1, Value::Map({
10593    let mut m = indexmap::IndexMap::new();
10594    m
10595}));
10596        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10597
10598    Value::Null
10599} }
10600
10601    fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10602        let mut params = get_arg(optional_args, 0, Value::Map({
10603    let mut m = indexmap::IndexMap::new();
10604    m
10605}));
10606        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)) {
10607            self.load_markets(&[]).await;
10608            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
10609            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10610            let mut tickers: Value = self.fetch_tickers_ws(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10611            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10612            if (ticker == Value::Null) {
10613                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)));
10614            }  else {
10615                return ticker;
10616            }
10617        }  else {
10618            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() is not supported yet".into()))));
10619        }
10620
10621    Value::Null
10622} }
10623
10624    fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10625        let mut symbols = get_arg(optional_args, 0, Value::Null);
10626        let mut params = get_arg(optional_args, 1, Value::Map({
10627    let mut m = indexmap::IndexMap::new();
10628    m
10629}));
10630        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickersWs() is not supported yet".into()))));
10631
10632    Value::Null
10633} }
10634
10635    fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10636        let mut since = get_arg(optional_args, 0, Value::Null);
10637        let mut limit = get_arg(optional_args, 1, Value::Null);
10638        let mut params = get_arg(optional_args, 2, Value::Map({
10639    let mut m = indexmap::IndexMap::new();
10640    m
10641}));
10642        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradesWs() is not supported yet".into()))));
10643
10644    Value::Null
10645} }
10646
10647
10648    fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10649        // async-virtual: try the derived exchange first
10650        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 {
10651            if !matches!(__v, crate::Value::Null) { return __v; }
10652        }
10653
10654        let mut since = get_arg(optional_args, 0, Value::Null);
10655        let mut limit = get_arg(optional_args, 1, Value::Null);
10656        let mut params = get_arg(optional_args, 2, 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(" fetchTrades() is not supported yet".into()))));
10661
10662    Value::Null
10663} }
10664
10665    fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10666        let mut since = get_arg(optional_args, 0, Value::Null);
10667        let mut limit = get_arg(optional_args, 1, Value::Null);
10668        let mut params = get_arg(optional_args, 2, Value::Map({
10669    let mut m = indexmap::IndexMap::new();
10670    m
10671}));
10672        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTrades() is not supported yet".into()))));
10673
10674    Value::Null
10675} }
10676
10677    fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10678        // async-virtual: try the derived exchange first
10679        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 {
10680            if !matches!(__v, crate::Value::Null) { return __v; }
10681        }
10682
10683        let mut limit = get_arg(optional_args, 0, Value::Null);
10684        let mut params = get_arg(optional_args, 1, Value::Map({
10685    let mut m = indexmap::IndexMap::new();
10686    m
10687}));
10688        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() is not supported yet".into()))));
10689
10690    Value::Null
10691} }
10692
10693    fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10694        let mut limit = get_arg(optional_args, 0, Value::Null);
10695        let mut params = get_arg(optional_args, 1, Value::Map({
10696    let mut m = indexmap::IndexMap::new();
10697    m
10698}));
10699        let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".into()), Value::Str("maxRetries".into()), &[Value::Int(3)]);
10700        {
10701                        let mut i: Value = Value::Int(0);
10702            let mut __for_first_182: bool = true;
10703            while { if !__for_first_182 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_182 = false; i.as_f64().unwrap_or(f64::NAN) < fetchSnapshotMaxRetries.as_f64().unwrap_or(f64::NAN) } {
10704            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10705                let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10706                return orderBook;
10707             #[allow(unreachable_code)] { Value::Null }})).await;
10708match _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); 
10709                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) {
10710                    panic!("{}", e);
10711                }
10712             } }
10713        }
10714        }
10715        return Value::Null;
10716
10717    Value::Null
10718} }
10719
10720    fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10721        let mut limit = get_arg(optional_args, 0, Value::Null);
10722        let mut params = get_arg(optional_args, 1, Value::Map({
10723    let mut m = indexmap::IndexMap::new();
10724    m
10725}));
10726        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBook() is not supported yet".into()))));
10727
10728    Value::Null
10729} }
10730
10731    fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10732        // async-virtual: try the derived exchange first
10733        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 {
10734            if !matches!(__v, crate::Value::Null) { return __v; }
10735        }
10736
10737        let mut params = get_arg(optional_args, 0, Value::Map({
10738    let mut m = indexmap::IndexMap::new();
10739    m
10740}));
10741        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)) {
10742            let mut openInterests: Value = self.fetch_open_interests(&[Value::from(vec![symbol.clone()]), params]).await;
10743            let mut openInterest: Value = self.safe_dict(openInterests, symbol, &[]);
10744            return openInterest;
10745        }  else {
10746            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterest() is not supported yet".into()))));
10747        }
10748
10749    Value::Null
10750} }
10751
10752    fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10753        let mut limit = get_arg(optional_args, 0, Value::Null);
10754        let mut params = get_arg(optional_args, 1, Value::Map({
10755    let mut m = indexmap::IndexMap::new();
10756    m
10757}));
10758        let mut orderbook: Value = self.fetch_order_book(symbol, &[limit, params]).await;
10759        return self.extend(orderbook.clone(), &[Value::Map({
10760    let mut m = indexmap::IndexMap::new();
10761        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), &[]));
10762        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)]));
10763    m
10764})]);
10765
10766    Value::Null
10767} }
10768
10769    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 {
10770        let mut price = get_arg(optional_args, 0, Value::Null);
10771        let mut params = get_arg(optional_args, 1, Value::Map({
10772    let mut m = indexmap::IndexMap::new();
10773    m
10774}));
10775        return self.edit_limit_order(id, symbol, Value::Str("buy".into()), amount, &[price, params]).await;
10776
10777    Value::Null
10778} }
10779
10780    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 {
10781        let mut price = get_arg(optional_args, 0, Value::Null);
10782        let mut params = get_arg(optional_args, 1, Value::Map({
10783    let mut m = indexmap::IndexMap::new();
10784    m
10785}));
10786        return self.edit_limit_order(id, symbol, Value::Str("sell".into()), amount, &[price, params]).await;
10787
10788    Value::Null
10789} }
10790
10791    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 {
10792        let mut price = get_arg(optional_args, 0, Value::Null);
10793        let mut params = get_arg(optional_args, 1, Value::Map({
10794    let mut m = indexmap::IndexMap::new();
10795    m
10796}));
10797        return self.edit_order(id, symbol, Value::Str("limit".into()), side, &[amount, price, params]).await;
10798
10799    Value::Null
10800} }
10801
10802    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 {
10803        // async-virtual: try the derived exchange first
10804        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 {
10805            if !matches!(__v, crate::Value::Null) { return __v; }
10806        }
10807
10808        let mut amount = get_arg(optional_args, 0, Value::Null);
10809        let mut price = get_arg(optional_args, 1, Value::Null);
10810        let mut params = get_arg(optional_args, 2, Value::Map({
10811    let mut m = indexmap::IndexMap::new();
10812    m
10813}));
10814        self.cancel_order(id, &[symbol.clone()]).await;
10815        return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10816
10817    Value::Null
10818} }
10819
10820    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 {
10821        let mut amount = get_arg(optional_args, 0, Value::Null);
10822        let mut price = get_arg(optional_args, 1, Value::Null);
10823        let mut params = get_arg(optional_args, 2, Value::Map({
10824    let mut m = indexmap::IndexMap::new();
10825    m
10826}));
10827        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10828            let mut m = indexmap::IndexMap::new();
10829                m.insert("clientOrderId".to_string(), clientOrderId);
10830            m
10831        })]);
10832        return self.edit_order(Value::Str("".into()), symbol, type_var, side, &[amount, price, extendedParams]).await;
10833
10834    Value::Null
10835} }
10836
10837    fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10838        // async-virtual: try the derived exchange first
10839        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 {
10840            if !matches!(__v, crate::Value::Null) { return __v; }
10841        }
10842
10843        let mut params = get_arg(optional_args, 0, Value::Map({
10844    let mut m = indexmap::IndexMap::new();
10845    m
10846}));
10847        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPosition() is not supported yet".into()))));
10848
10849    Value::Null
10850} }
10851
10852    fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10853        let mut symbols = get_arg(optional_args, 0, Value::Null);
10854        let mut since = get_arg(optional_args, 1, Value::Null);
10855        let mut limit = get_arg(optional_args, 2, Value::Null);
10856        let mut params = get_arg(optional_args, 3, Value::Map({
10857    let mut m = indexmap::IndexMap::new();
10858    m
10859}));
10860        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPositions() is not supported yet".into()))));
10861
10862    Value::Null
10863} }
10864
10865    fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10866        let mut symbols = get_arg(optional_args, 0, Value::Null);
10867        let mut since = get_arg(optional_args, 1, Value::Null);
10868        let mut limit = get_arg(optional_args, 2, Value::Null);
10869        let mut params = get_arg(optional_args, 3, Value::Map({
10870    let mut m = indexmap::IndexMap::new();
10871    m
10872}));
10873        return self.watch_positions(&[symbols, since, limit, params]).await;
10874
10875    Value::Null
10876} }
10877
10878    fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10879        // async-virtual: try the derived exchange first
10880        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 {
10881            if !matches!(__v, crate::Value::Null) { return __v; }
10882        }
10883
10884        let mut symbols = get_arg(optional_args, 0, Value::Null);
10885        let mut params = get_arg(optional_args, 1, Value::Map({
10886    let mut m = indexmap::IndexMap::new();
10887    m
10888}));
10889        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10890
10891    Value::Null
10892} }
10893
10894    fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10895        // async-virtual: try the derived exchange first
10896        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 {
10897            if !matches!(__v, crate::Value::Null) { return __v; }
10898        }
10899
10900        let mut params = get_arg(optional_args, 0, Value::Map({
10901    let mut m = indexmap::IndexMap::new();
10902    m
10903}));
10904        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)) {
10905            self.load_markets(&[]).await;
10906            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
10907            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10908            let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10909            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10910            if (ticker == Value::Null) {
10911                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)));
10912            }  else {
10913                return ticker;
10914            }
10915        }  else {
10916            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() is not supported yet".into()))));
10917        }
10918
10919    Value::Null
10920} }
10921
10922    fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10923        let mut params = get_arg(optional_args, 0, Value::Map({
10924    let mut m = indexmap::IndexMap::new();
10925    m
10926}));
10927        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTicker() is not supported yet".into()))));
10928
10929    Value::Null
10930} }
10931
10932    fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10933        // async-virtual: try the derived exchange first
10934        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 {
10935            if !matches!(__v, crate::Value::Null) { return __v; }
10936        }
10937
10938        let mut symbols = get_arg(optional_args, 0, Value::Null);
10939        let mut params = get_arg(optional_args, 1, Value::Map({
10940    let mut m = indexmap::IndexMap::new();
10941    m
10942}));
10943        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() is not supported yet".into()))));
10944
10945    Value::Null
10946} }
10947
10948    fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10949        let mut symbols = get_arg(optional_args, 0, Value::Null);
10950        let mut params = get_arg(optional_args, 1, Value::Map({
10951    let mut m = indexmap::IndexMap::new();
10952    m
10953}));
10954        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTickers() is not supported yet".into()))));
10955
10956    Value::Null
10957} }
10958
10959    fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10960        // async-virtual: try the derived exchange first
10961        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 {
10962            if !matches!(__v, crate::Value::Null) { return __v; }
10963        }
10964
10965        let mut symbol = get_arg(optional_args, 0, Value::Null);
10966        let mut params = get_arg(optional_args, 1, Value::Map({
10967    let mut m = indexmap::IndexMap::new();
10968    m
10969}));
10970        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() is not supported yet".into()))));
10971
10972    Value::Null
10973} }
10974
10975/*
10976 * @method
10977 * @name fetchOrderWithClientOrderId
10978 * @description create a market order by providing the symbol, side and cost
10979 * @param {string} clientOrderId client order Id
10980 * @param {string} symbol unified symbol of the market to create an order in
10981 * @param {object} [params] extra parameters specific to the exchange API endpoint
10982 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10983 */
10984    fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10985        let mut symbol = get_arg(optional_args, 0, Value::Null);
10986        let mut params = get_arg(optional_args, 1, Value::Map({
10987    let mut m = indexmap::IndexMap::new();
10988    m
10989}));
10990        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10991            let mut m = indexmap::IndexMap::new();
10992                m.insert("clientOrderId".to_string(), clientOrderId);
10993            m
10994        })]);
10995        return self.fetch_order(Value::Str("".into()), &[symbol, extendedParams]).await;
10996
10997    Value::Null
10998} }
10999
11000    fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11001        let mut symbol = get_arg(optional_args, 0, Value::Null);
11002        let mut params = get_arg(optional_args, 1, Value::Map({
11003    let mut m = indexmap::IndexMap::new();
11004    m
11005}));
11006        // TODO: TypeScript: change method signature by replacing
11007        // Promise<string> with Promise<Order['status']>.
11008        let mut order: Value = self.fetch_order(id, &[symbol, params]).await;
11009        return self.safe_string_k(order, "status", &[]);
11010
11011    Value::Null
11012} }
11013
11014    fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11015        let mut params = get_arg(optional_args, 0, Value::Map({
11016    let mut m = indexmap::IndexMap::new();
11017    m
11018}));
11019        return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11020
11021    Value::Null
11022} }
11023
11024    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 {
11025        // async-virtual: try the derived exchange first
11026        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 {
11027            if !matches!(__v, crate::Value::Null) { return __v; }
11028        }
11029
11030        let mut price = get_arg(optional_args, 0, Value::Null);
11031        let mut params = get_arg(optional_args, 1, Value::Map({
11032    let mut m = indexmap::IndexMap::new();
11033    m
11034}));
11035        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() is not supported yet".into()))));
11036
11037    Value::Null
11038} }
11039
11040    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 {
11041        let mut price = get_arg(optional_args, 0, Value::Null);
11042        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
11043        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
11044        let mut params = get_arg(optional_args, 3, Value::Map({
11045    let mut m = indexmap::IndexMap::new();
11046    m
11047}));
11048        /*
11049         * @method
11050         * @name createTrailingAmountOrder
11051         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
11052         * @param {string} symbol unified symbol of the market to create an order in
11053         * @param {string} type 'market' or 'limit'
11054         * @param {string} side 'buy' or 'sell'
11055         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
11056         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
11057         * @param {float} trailingAmount the quote amount to trail away from the current market price
11058         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
11059         * @param {object} [params] extra parameters specific to the exchange API endpoint
11060         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11061         */
11062        if (trailingAmount == Value::Null) {
11063            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".into()))));
11064        }
11065        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
11066        if (trailingTriggerPrice != Value::Null) {
11067            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
11068        }
11069        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)) {
11070            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
11071        }
11072        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() is not supported yet".into()))));
11073
11074    Value::Null
11075} }
11076
11077    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 {
11078        let mut price = get_arg(optional_args, 0, Value::Null);
11079        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
11080        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
11081        let mut params = get_arg(optional_args, 3, Value::Map({
11082    let mut m = indexmap::IndexMap::new();
11083    m
11084}));
11085        /*
11086         * @method
11087         * @name createTrailingPercentOrder
11088         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
11089         * @param {string} symbol unified symbol of the market to create an order in
11090         * @param {string} type 'market' or 'limit'
11091         * @param {string} side 'buy' or 'sell'
11092         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
11093         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
11094         * @param {float} trailingPercent the percent to trail away from the current market price
11095         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
11096         * @param {object} [params] extra parameters specific to the exchange API endpoint
11097         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11098         */
11099        if (trailingPercent == Value::Null) {
11100            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".into()))));
11101        }
11102        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
11103        if (trailingTriggerPrice != Value::Null) {
11104            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
11105        }
11106        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)) {
11107            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
11108        }
11109        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() is not supported yet".into()))));
11110
11111    Value::Null
11112} }
11113
11114    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 {
11115        let mut params = get_arg(optional_args, 0, Value::Map({
11116    let mut m = indexmap::IndexMap::new();
11117    m
11118}));
11119        /*
11120         * @method
11121         * @name createMarketOrderWithCost
11122         * @description create a market order by providing the symbol, side and cost
11123         * @param {string} symbol unified symbol of the market to create an order in
11124         * @param {string} side 'buy' or 'sell'
11125         * @param {float} cost how much you want to trade in units of the quote currency
11126         * @param {object} [params] extra parameters specific to the exchange API endpoint
11127         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11128         */
11129        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)))) {
11130            return self.create_order(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
11131        }
11132        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCost() is not supported yet".into()))));
11133
11134    Value::Null
11135} }
11136
11137    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 {
11138        let mut params = get_arg(optional_args, 0, Value::Map({
11139    let mut m = indexmap::IndexMap::new();
11140    m
11141}));
11142        /*
11143         * @method
11144         * @name createMarketBuyOrderWithCost
11145         * @description create a market buy order by providing the symbol and cost
11146         * @param {string} symbol unified symbol of the market to create an order in
11147         * @param {float} cost how much you want to trade in units of the quote currency
11148         * @param {object} [params] extra parameters specific to the exchange API endpoint
11149         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11150         */
11151        if ((match &(self.options.as_map().and_then(|__m| __m.get("createMarketBuyOrderRequiresPrice")).cloned().unwrap_or(Value::Null)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) })) || ((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))) {
11152            return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Int(1), params]).await;
11153        }
11154        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() is not supported yet".into()))));
11155
11156    Value::Null
11157} }
11158
11159    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 {
11160        let mut params = get_arg(optional_args, 0, Value::Map({
11161    let mut m = indexmap::IndexMap::new();
11162    m
11163}));
11164        /*
11165         * @method
11166         * @name createMarketSellOrderWithCost
11167         * @description create a market sell order by providing the symbol and cost
11168         * @param {string} symbol unified symbol of the market to create an order in
11169         * @param {float} cost how much you want to trade in units of the quote currency
11170         * @param {object} [params] extra parameters specific to the exchange API endpoint
11171         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11172         */
11173        if ((match &(self.options.as_map().and_then(|__m| __m.get("createMarketSellOrderRequiresPrice")).cloned().unwrap_or(Value::Null)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) })) || ((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))) {
11174            return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), cost, &[Value::Int(1), params]).await;
11175        }
11176        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketSellOrderWithCost() is not supported yet".into()))));
11177
11178    Value::Null
11179} }
11180
11181    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 {
11182        let mut price = get_arg(optional_args, 0, Value::Null);
11183        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11184        let mut params = get_arg(optional_args, 2, Value::Map({
11185    let mut m = indexmap::IndexMap::new();
11186    m
11187}));
11188        /*
11189         * @method
11190         * @name createTriggerOrder
11191         * @description create a trigger stop order (type 1)
11192         * @param {string} symbol unified symbol of the market to create an order in
11193         * @param {string} type 'market' or 'limit'
11194         * @param {string} side 'buy' or 'sell'
11195         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11196         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11197         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
11198         * @param {object} [params] extra parameters specific to the exchange API endpoint
11199         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11200         */
11201        if (triggerPrice == Value::Null) {
11202            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() requires a triggerPrice argument".into()))));
11203        }
11204        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11205            let mut m = indexmap::IndexMap::new();
11206                m.insert("triggerPrice".to_string(), triggerPrice);
11207            m
11208        })]);
11209        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)) {
11210            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11211        }
11212        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() is not supported yet".into()))));
11213
11214    Value::Null
11215} }
11216
11217    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 {
11218        let mut price = get_arg(optional_args, 0, Value::Null);
11219        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
11220        let mut params = get_arg(optional_args, 2, Value::Map({
11221    let mut m = indexmap::IndexMap::new();
11222    m
11223}));
11224        /*
11225         * @method
11226         * @name createStopLossOrder
11227         * @description create a trigger stop loss order (type 2)
11228         * @param {string} symbol unified symbol of the market to create an order in
11229         * @param {string} type 'market' or 'limit'
11230         * @param {string} side 'buy' or 'sell'
11231         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11232         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11233         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
11234         * @param {object} [params] extra parameters specific to the exchange API endpoint
11235         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11236         */
11237        if (stopLossPrice == Value::Null) {
11238            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() requires a stopLossPrice argument".into()))));
11239        }
11240        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11241            let mut m = indexmap::IndexMap::new();
11242                m.insert("stopLossPrice".to_string(), stopLossPrice);
11243            m
11244        })]);
11245        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)) {
11246            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11247        }
11248        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() is not supported yet".into()))));
11249
11250    Value::Null
11251} }
11252
11253    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 {
11254        let mut price = get_arg(optional_args, 0, Value::Null);
11255        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
11256        let mut params = get_arg(optional_args, 2, Value::Map({
11257    let mut m = indexmap::IndexMap::new();
11258    m
11259}));
11260        /*
11261         * @method
11262         * @name createTakeProfitOrder
11263         * @description create a trigger take profit order (type 2)
11264         * @param {string} symbol unified symbol of the market to create an order in
11265         * @param {string} type 'market' or 'limit'
11266         * @param {string} side 'buy' or 'sell'
11267         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11268         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11269         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
11270         * @param {object} [params] extra parameters specific to the exchange API endpoint
11271         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11272         */
11273        if (takeProfitPrice == Value::Null) {
11274            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".into()))));
11275        }
11276        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11277            let mut m = indexmap::IndexMap::new();
11278                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
11279            m
11280        })]);
11281        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)) {
11282            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11283        }
11284        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() is not supported yet".into()))));
11285
11286    Value::Null
11287} }
11288
11289    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 {
11290        let mut price = get_arg(optional_args, 0, Value::Null);
11291        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
11292        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
11293        let mut params = get_arg(optional_args, 3, Value::Map({
11294    let mut m = indexmap::IndexMap::new();
11295    m
11296}));
11297        /*
11298         * @method
11299         * @name createOrderWithTakeProfitAndStopLoss
11300         * @description create an order with a stop loss or take profit attached (type 3)
11301         * @param {string} symbol unified symbol of the market to create an order in
11302         * @param {string} type 'market' or 'limit'
11303         * @param {string} side 'buy' or 'sell'
11304         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11305         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11306         * @param {float} [takeProfit] the take profit price, in units of the quote currency
11307         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
11308         * @param {object} [params] extra parameters specific to the exchange API endpoint
11309         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
11310         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
11311         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
11312         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
11313         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
11314         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
11315         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
11316         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
11317         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11318         */
11319        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()]);
11320        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)) {
11321            return self.create_order(symbol, type_var, side, amount, &[price, paramsValue]).await;
11322        }
11323        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".into()))));
11324
11325    Value::Null
11326} }
11327
11328    fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11329        // async-virtual: try the derived exchange first
11330        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 {
11331            if !matches!(__v, crate::Value::Null) { return __v; }
11332        }
11333
11334        let mut params = get_arg(optional_args, 0, Value::Map({
11335    let mut m = indexmap::IndexMap::new();
11336    m
11337}));
11338        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrders() is not supported yet".into()))));
11339
11340    Value::Null
11341} }
11342
11343    fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11344        // async-virtual: try the derived exchange first
11345        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 {
11346            if !matches!(__v, crate::Value::Null) { return __v; }
11347        }
11348
11349        let mut symbol = get_arg(optional_args, 0, Value::Null);
11350        let mut params = get_arg(optional_args, 1, Value::Map({
11351    let mut m = indexmap::IndexMap::new();
11352    m
11353}));
11354        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() is not supported yet".into()))));
11355
11356    Value::Null
11357} }
11358
11359/*
11360 * @method
11361 * @name cancelOrderWithClientOrderId
11362 * @description create a market order by providing the symbol, side and cost
11363 * @param {string} clientOrderId client order Id
11364 * @param {string} symbol unified symbol of the market to create an order in
11365 * @param {object} [params] extra parameters specific to the exchange API endpoint
11366 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11367 */
11368    fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11369        let mut symbol = get_arg(optional_args, 0, Value::Null);
11370        let mut params = get_arg(optional_args, 1, Value::Map({
11371    let mut m = indexmap::IndexMap::new();
11372    m
11373}));
11374        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11375            let mut m = indexmap::IndexMap::new();
11376                m.insert("clientOrderId".to_string(), clientOrderId);
11377            m
11378        })]);
11379        return self.cancel_order(Value::Str("".into()), &[symbol, extendedParams]).await;
11380
11381    Value::Null
11382} }
11383
11384    fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11385        // async-virtual: try the derived exchange first
11386        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 {
11387            if !matches!(__v, crate::Value::Null) { return __v; }
11388        }
11389
11390        let mut symbol = get_arg(optional_args, 0, Value::Null);
11391        let mut params = get_arg(optional_args, 1, Value::Map({
11392    let mut m = indexmap::IndexMap::new();
11393    m
11394}));
11395        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() is not supported yet".into()))));
11396
11397    Value::Null
11398} }
11399
11400/*
11401 * @method
11402 * @name cancelOrdersWithClientOrderIds
11403 * @description create a market order by providing the symbol, side and cost
11404 * @param {string[]} clientOrderIds client order Ids
11405 * @param {string} symbol unified symbol of the market to create an order in
11406 * @param {object} [params] extra parameters specific to the exchange API endpoint
11407 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11408 */
11409    fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11410        let mut symbol = get_arg(optional_args, 0, Value::Null);
11411        let mut params = get_arg(optional_args, 1, Value::Map({
11412    let mut m = indexmap::IndexMap::new();
11413    m
11414}));
11415        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11416            let mut m = indexmap::IndexMap::new();
11417                m.insert("clientOrderIds".to_string(), clientOrderIds);
11418            m
11419        })]);
11420        return self.cancel_orders(Value::from(vec![]), &[symbol, extendedParams]).await;
11421
11422    Value::Null
11423} }
11424
11425    fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11426        // async-virtual: try the derived exchange first
11427        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 {
11428            if !matches!(__v, crate::Value::Null) { return __v; }
11429        }
11430
11431        let mut symbol = get_arg(optional_args, 0, Value::Null);
11432        let mut params = get_arg(optional_args, 1, Value::Map({
11433    let mut m = indexmap::IndexMap::new();
11434    m
11435}));
11436        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() is not supported yet".into()))));
11437
11438    Value::Null
11439} }
11440
11441    fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11442        let mut params = get_arg(optional_args, 0, Value::Map({
11443    let mut m = indexmap::IndexMap::new();
11444    m
11445}));
11446        return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11447
11448    Value::Null
11449} }
11450
11451    fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11452        // async-virtual: try the derived exchange first
11453        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 {
11454            if !matches!(__v, crate::Value::Null) { return __v; }
11455        }
11456
11457        let mut symbol = get_arg(optional_args, 0, Value::Null);
11458        let mut since = get_arg(optional_args, 1, Value::Null);
11459        let mut limit = get_arg(optional_args, 2, Value::Null);
11460        let mut params = get_arg(optional_args, 3, Value::Map({
11461    let mut m = indexmap::IndexMap::new();
11462    m
11463}));
11464        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))) {
11465            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".into()))));
11466        }
11467        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet".into()))));
11468
11469    Value::Null
11470} }
11471
11472    fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11473        let mut symbol = get_arg(optional_args, 0, Value::Null);
11474        let mut since = get_arg(optional_args, 1, Value::Null);
11475        let mut limit = get_arg(optional_args, 2, Value::Null);
11476        let mut params = get_arg(optional_args, 3, Value::Map({
11477    let mut m = indexmap::IndexMap::new();
11478    m
11479}));
11480        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderTrades() is not supported yet".into()))));
11481
11482    Value::Null
11483} }
11484
11485    fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11486        let mut symbol = get_arg(optional_args, 0, Value::Null);
11487        let mut since = get_arg(optional_args, 1, Value::Null);
11488        let mut limit = get_arg(optional_args, 2, Value::Null);
11489        let mut params = get_arg(optional_args, 3, Value::Map({
11490    let mut m = indexmap::IndexMap::new();
11491    m
11492}));
11493        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrders() is not supported yet".into()))));
11494
11495    Value::Null
11496} }
11497
11498    fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11499        // async-virtual: try the derived exchange first
11500        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 {
11501            if !matches!(__v, crate::Value::Null) { return __v; }
11502        }
11503
11504        let mut symbol = get_arg(optional_args, 0, Value::Null);
11505        let mut since = get_arg(optional_args, 1, Value::Null);
11506        let mut limit = get_arg(optional_args, 2, Value::Null);
11507        let mut params = get_arg(optional_args, 3, Value::Map({
11508    let mut m = indexmap::IndexMap::new();
11509    m
11510}));
11511        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)) {
11512            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11513            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
11514        }
11515        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() is not supported yet".into()))));
11516
11517    Value::Null
11518} }
11519
11520    fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11521        // async-virtual: try the derived exchange first
11522        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 {
11523            if !matches!(__v, crate::Value::Null) { return __v; }
11524        }
11525
11526        let mut symbol = get_arg(optional_args, 0, Value::Null);
11527        let mut since = get_arg(optional_args, 1, Value::Null);
11528        let mut limit = get_arg(optional_args, 2, Value::Null);
11529        let mut params = get_arg(optional_args, 3, Value::Map({
11530    let mut m = indexmap::IndexMap::new();
11531    m
11532}));
11533        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)) {
11534            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11535            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
11536        }
11537        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrders() is not supported yet".into()))));
11538
11539    Value::Null
11540} }
11541
11542    fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11543        let mut symbol = get_arg(optional_args, 0, Value::Null);
11544        let mut since = get_arg(optional_args, 1, Value::Null);
11545        let mut limit = get_arg(optional_args, 2, Value::Null);
11546        let mut params = get_arg(optional_args, 3, Value::Map({
11547    let mut m = indexmap::IndexMap::new();
11548    m
11549}));
11550        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledOrders() is not supported yet".into()))));
11551
11552    Value::Null
11553} }
11554
11555    fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11556        // async-virtual: try the derived exchange first
11557        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 {
11558            if !matches!(__v, crate::Value::Null) { return __v; }
11559        }
11560
11561        let mut symbol = get_arg(optional_args, 0, Value::Null);
11562        let mut since = get_arg(optional_args, 1, Value::Null);
11563        let mut limit = get_arg(optional_args, 2, Value::Null);
11564        let mut params = get_arg(optional_args, 3, Value::Map({
11565    let mut m = indexmap::IndexMap::new();
11566    m
11567}));
11568        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() is not supported yet".into()))));
11569
11570    Value::Null
11571} }
11572
11573    fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11574        let mut symbol = get_arg(optional_args, 0, Value::Null);
11575        let mut since = get_arg(optional_args, 1, Value::Null);
11576        let mut limit = get_arg(optional_args, 2, Value::Null);
11577        let mut params = get_arg(optional_args, 3, Value::Map({
11578    let mut m = indexmap::IndexMap::new();
11579    m
11580}));
11581        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTrades() is not supported yet".into()))));
11582
11583    Value::Null
11584} }
11585
11586    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 {
11587        let mut params = get_arg(optional_args, 0, Value::Map({
11588    let mut m = indexmap::IndexMap::new();
11589    m
11590}));
11591        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
11592
11593    Value::Null
11594} }
11595
11596    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 {
11597        let mut price = get_arg(optional_args, 0, Value::Null);
11598        let mut params = get_arg(optional_args, 1, Value::Map({
11599    let mut m = indexmap::IndexMap::new();
11600    m
11601}));
11602        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
11603
11604    Value::Null
11605} }
11606
11607    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 {
11608        let mut params = get_arg(optional_args, 0, Value::Map({
11609    let mut m = indexmap::IndexMap::new();
11610    m
11611}));
11612        return self.create_order(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
11613
11614    Value::Null
11615} }
11616
11617    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 {
11618        let mut params = get_arg(optional_args, 0, Value::Map({
11619    let mut m = indexmap::IndexMap::new();
11620    m
11621}));
11622        return self.create_order(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
11623
11624    Value::Null
11625} }
11626
11627    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 {
11628        let mut params = get_arg(optional_args, 0, Value::Map({
11629    let mut m = indexmap::IndexMap::new();
11630    m
11631}));
11632        return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
11633
11634    Value::Null
11635} }
11636
11637    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 {
11638        let mut params = get_arg(optional_args, 0, Value::Map({
11639    let mut m = indexmap::IndexMap::new();
11640    m
11641}));
11642        return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
11643
11644    Value::Null
11645} }
11646
11647    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 {
11648        let mut price = get_arg(optional_args, 0, Value::Null);
11649        let mut params = get_arg(optional_args, 1, Value::Map({
11650    let mut m = indexmap::IndexMap::new();
11651    m
11652}));
11653        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)) {
11654            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrder() is not supported yet".into()))));
11655        }
11656        let mut query: Value = self.extend(params, &[Value::Map({
11657            let mut m = indexmap::IndexMap::new();
11658                m.insert("postOnly".to_string(), Value::Bool(true));
11659            m
11660        })]);
11661        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11662
11663    Value::Null
11664} }
11665
11666    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 {
11667        let mut price = get_arg(optional_args, 0, Value::Null);
11668        let mut params = get_arg(optional_args, 1, Value::Map({
11669    let mut m = indexmap::IndexMap::new();
11670    m
11671}));
11672        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)) {
11673            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrder() is not supported yet".into()))));
11674        }
11675        let mut query: Value = self.extend(params, &[Value::Map({
11676            let mut m = indexmap::IndexMap::new();
11677                m.insert("reduceOnly".to_string(), Value::Bool(true));
11678            m
11679        })]);
11680        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11681
11682    Value::Null
11683} }
11684
11685    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 {
11686        let mut price = get_arg(optional_args, 0, Value::Null);
11687        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11688        let mut params = get_arg(optional_args, 2, Value::Map({
11689    let mut m = indexmap::IndexMap::new();
11690    m
11691}));
11692        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)) {
11693            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrder() is not supported yet".into()))));
11694        }
11695        if (triggerPrice == Value::Null) {
11696            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" create_stop_order() requires a stopPrice argument".into()))));
11697        }
11698        let mut query: Value = self.extend(params, &[Value::Map({
11699            let mut m = indexmap::IndexMap::new();
11700                m.insert("stopPrice".to_string(), triggerPrice);
11701            m
11702        })]);
11703        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11704
11705    Value::Null
11706} }
11707
11708    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 {
11709        let mut params = get_arg(optional_args, 0, Value::Map({
11710    let mut m = indexmap::IndexMap::new();
11711    m
11712}));
11713        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)) {
11714            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrder() is not supported yet".into()))));
11715        }
11716        let mut query: Value = self.extend(params, &[Value::Map({
11717            let mut m = indexmap::IndexMap::new();
11718                m.insert("stopPrice".to_string(), triggerPrice);
11719            m
11720        })]);
11721        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
11722
11723    Value::Null
11724} }
11725
11726    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 {
11727        let mut params = get_arg(optional_args, 0, Value::Map({
11728    let mut m = indexmap::IndexMap::new();
11729    m
11730}));
11731        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)) {
11732            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrder() is not supported yet".into()))));
11733        }
11734        let mut query: Value = self.extend(params, &[Value::Map({
11735            let mut m = indexmap::IndexMap::new();
11736                m.insert("stopPrice".to_string(), triggerPrice);
11737            m
11738        })]);
11739        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
11740
11741    Value::Null
11742} }
11743
11744    fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11745        // async-virtual: try the derived exchange first
11746        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 {
11747            if !matches!(__v, crate::Value::Null) { return __v; }
11748        }
11749
11750        let mut params = get_arg(optional_args, 0, Value::Map({
11751    let mut m = indexmap::IndexMap::new();
11752    m
11753}));
11754        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)) {
11755            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFee() is not supported yet".into()))));
11756        }
11757        let mut fees: Value = self.fetch_trading_fees(&[params]).await;
11758        let mut fee: Value = self.safe_dict(fees, symbol, &[]);
11759        return fee;
11760
11761    Value::Null
11762} }
11763    /// Base-method fall-through for a core's `call_dynamic`.
11764    fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11765        -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11766    {
11767        Box::pin(async move {
11768            match method {
11769            "account" => self.account(),
11770            "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)),
11771            "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,
11772            "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)),
11773            "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11774            "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())..]),
11775            "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,
11776            "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,
11777            "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,
11778            "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11779            "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())..]),
11780            "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())..]),
11781            "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())..]),
11782            "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11783            "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args[..]).await,
11784            "cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
11785            "cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11786            "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args[..]).await,
11787            "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args[..]).await,
11788            "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11789            "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11790            "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,
11791            "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11792            "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11793            "cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11794            "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,
11795            "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11796            "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11797            "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11798            "check_address" => self.check_address(&args[..]),
11799            "check_proxy_settings" => self.check_proxy_settings(&args[..]),
11800            "check_proxy_url_settings" => self.check_proxy_url_settings(&args[..]),
11801            "check_required_credentials" => self.check_required_credentials(&args[..]),
11802            "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11803            "close_all_positions" => self.close_all_positions(&args[..]).await,
11804            "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11805            "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11806            "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11807            "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11808            "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11809            "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())..]),
11810            "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())..]),
11811            "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11812            "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)),
11813            "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args[..]),
11814            "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11815            "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,
11816            "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11817            "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11818            "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,
11819            "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,
11820            "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,
11821            "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,
11822            "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,
11823            "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,
11824            "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,
11825            "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,
11826            "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,
11827            "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,
11828            "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,
11829            "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,
11830            "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,
11831            "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,
11832            "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,
11833            "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,
11834            "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)),
11835            "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,
11836            "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,
11837            "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,
11838            "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,
11839            "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11840            "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11841            "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,
11842            "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,
11843            "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,
11844            "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,
11845            "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11846            "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,
11847            "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,
11848            "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,
11849            "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,
11850            "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,
11851            "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,
11852            "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,
11853            "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,
11854            "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11855            "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,
11856            "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,
11857            "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,
11858            "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,
11859            "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,
11860            "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,
11861            "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,
11862            "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,
11863            "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,
11864            "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11865            "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11866            "currency_ids" => self.currency_ids(&args[..]),
11867            "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())..]),
11868            "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11869            "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,
11870            "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,
11871            "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,
11872            "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,
11873            "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,
11874            "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,
11875            "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11876            "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11877            "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())..]),
11878            "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())..]),
11879            "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)),
11880            "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11881            "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11882            "fetch_accounts" => self.fetch_accounts(&args[..]).await,
11883            "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11884            "fetch_all_greeks" => self.fetch_all_greeks(&args[..]).await,
11885            "fetch_balance" => self.fetch_balance(&args[..]).await,
11886            "fetch_balance_ws" => self.fetch_balance_ws(&args[..]).await,
11887            "fetch_bids_asks" => self.fetch_bids_asks(&args[..]).await,
11888            "fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
11889            "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,
11890            "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
11891            "fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
11892            "fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
11893            "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args[..]).await,
11894            "fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11895            "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11896            "fetch_contract_tickers" => self.fetch_contract_tickers(&args[..]).await,
11897            "fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
11898            "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,
11899            "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11900            "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
11901            "fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11902            "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args[..]).await,
11903            "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11904            "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args[..]).await,
11905            "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,
11906            "fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11907            "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
11908            "fetch_deposits" => self.fetch_deposits(&args[..]).await,
11909            "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
11910            "fetch_deposits_ws" => self.fetch_deposits_ws(&args[..]).await,
11911            "fetch_free_balance" => self.fetch_free_balance(&args[..]).await,
11912            "fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
11913            "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11914            "fetch_funding_intervals" => self.fetch_funding_intervals(&args[..]).await,
11915            "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11916            "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
11917            "fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
11918            "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11919            "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11920            "fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11921            "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args[..]).await,
11922            "fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11923            "fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11924            "fetch_last_prices" => self.fetch_last_prices(&args[..]).await,
11925            "fetch_ledger" => self.fetch_ledger(&args[..]).await,
11926            "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11927            "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11928            "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args[..]).await,
11929            "fetch_leverages" => self.fetch_leverages(&args[..]).await,
11930            "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11931            "fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11932            "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args[..]).await,
11933            "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args[..]).await,
11934            "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11935            "fetch_margin_modes" => self.fetch_margin_modes(&args[..]).await,
11936            "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11937            "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11938            "fetch_mark_prices" => self.fetch_mark_prices(&args[..]).await,
11939            "fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11940            "fetch_my_liquidations" => self.fetch_my_liquidations(&args[..]).await,
11941            "fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
11942            "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args[..]).await,
11943            "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11944            "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11945            "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11946            "fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11947            "fetch_open_interests" => self.fetch_open_interests(&args[..]).await,
11948            "fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
11949            "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args[..]).await,
11950            "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11951            "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11952            "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11953            "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11954            "fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11955            "fetch_order_books" => self.fetch_order_books(&args[..]).await,
11956            "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11957            "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11958            "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,
11959            "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11960            "fetch_orders" => self.fetch_orders(&args[..]).await,
11961            "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,
11962            "fetch_orders_ws" => self.fetch_orders_ws(&args[..]).await,
11963            "fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11964            "fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11965            "fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11966            "fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11967            "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11968            "fetch_payment_methods" => self.fetch_payment_methods(&args[..]).await,
11969            "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11970            "fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11971            "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11972            "fetch_position_mode" => self.fetch_position_mode(&args[..]).await,
11973            "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11974            "fetch_positions" => self.fetch_positions(&args[..]).await,
11975            "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args[..]).await,
11976            "fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11977            "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,
11978            "fetch_positions_history" => self.fetch_positions_history(&args[..]).await,
11979            "fetch_positions_risk" => self.fetch_positions_risk(&args[..]).await,
11980            "fetch_positions_ws" => self.fetch_positions_ws(&args[..]).await,
11981            "fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11982            "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,
11983            "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11984            "fetch_spot_tickers" => self.fetch_spot_tickers(&args[..]).await,
11985            "fetch_status" => self.fetch_status(&args[..]).await,
11986            "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11987            "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11988            "fetch_tickers" => self.fetch_tickers(&args[..]).await,
11989            "fetch_tickers_ws" => self.fetch_tickers_ws(&args[..]).await,
11990            "fetch_time" => self.fetch_time(&args[..]).await,
11991            "fetch_total_balance" => self.fetch_total_balance(&args[..]).await,
11992            "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11993            "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11994            "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11995            "fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
11996            "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args[..]).await,
11997            "fetch_trading_limits" => self.fetch_trading_limits(&args[..]).await,
11998            "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11999            "fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
12000            "fetch_transactions" => self.fetch_transactions(&args[..]).await,
12001            "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12002            "fetch_transfers" => self.fetch_transfers(&args[..]).await,
12003            "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12004            "fetch_used_balance" => self.fetch_used_balance(&args[..]).await,
12005            "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,
12006            "fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
12007            "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args[..]).await,
12008            "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())..]),
12009            "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())..]),
12010            "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())..]),
12011            "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())..]),
12012            "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())..]),
12013            "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())..]),
12014            "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12015            "filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12016            "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12017            "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())..]),
12018            "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())..]),
12019            "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())..]),
12020            "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())..]),
12021            "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)),
12022            "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)),
12023            "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)),
12024            "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12025            "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12026            "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)),
12027            "get_default_options" => self.get_default_options(),
12028            "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)),
12029            "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)),
12030            "get_market_from_symbols" => self.get_market_from_symbols(&args[..]),
12031            "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12032            "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args[..]),
12033            "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)),
12034            "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())..]),
12035            "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())..]),
12036            "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())..]),
12037            "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12038            "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())..]),
12039            "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())..]),
12040            "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())..]),
12041            "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())..]),
12042            "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())..]),
12043            "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())..]),
12044            "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())..]),
12045            "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())..]),
12046            "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())..]),
12047            "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())..]),
12048            "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())..]),
12049            "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())..]),
12050            "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())..]),
12051            "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())..]),
12052            "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())..]),
12053            "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())..]),
12054            "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())..]),
12055            "handle_time_in_force" => self.handle_time_in_force(&args[..]),
12056            "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12057            "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())..]),
12058            "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())..]),
12059            "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())..]),
12060            "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12061            "incrementing_nonce" => self.incrementing_nonce(),
12062            "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12063            "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12064            "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12065            "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12066            "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())..]),
12067            "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12068            "is_significant_precision" => self.is_significant_precision(),
12069            "is_tick_precision" => self.is_tick_precision(),
12070            "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12071            "is_uta_enabled" => self.is_uta_enabled(&args[..]).await,
12072            "load_accounts" => self.load_accounts(&args[..]).await,
12073            "load_markets" => self.load_markets(&args[..]).await,
12074            "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
12075            "load_time_difference" => self.load_time_difference(&args[..]).await,
12076            "load_trading_limits" => self.load_trading_limits(&args[..]).await,
12077            "market" => <Self as crate::exchange_generated::ExchangeBase>::market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12078            "market_codes" => self.market_codes(&args[..]),
12079            "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12080            "market_ids" => self.market_ids(&args[..]),
12081            "market_non_virtual" => self.market_non_virtual(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12082            "market_or_null" => self.market_or_null(&args[..]),
12083            "market_symbols" => self.market_symbols(&args[..]),
12084            "markets_for_symbols" => self.markets_for_symbols(&args[..]),
12085            "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)),
12086            "network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12087            "network_id_to_code" => self.network_id_to_code(&args[..]),
12088            "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
12089            "oath" => self.oath(),
12090            "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12091            "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12092            "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12093            "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())..]),
12094            "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12095            "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12096            "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12097            "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())..]),
12098            "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12099            "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())..]),
12100            "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)),
12101            "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())..]),
12102            "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12103            "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12104            "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12105            "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())..]),
12106            "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12107            "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())..]),
12108            "parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12109            "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12110            "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())..]),
12111            "parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12112            "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())..]),
12113            "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12114            "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())..]),
12115            "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())..]),
12116            "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12117            "parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12118            "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12119            "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())..]),
12120            "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12121            "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12122            "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())..]),
12123            "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())..]),
12124            "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12125            "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12126            "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())..]),
12127            "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12128            "parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12129            "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())..]),
12130            "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())..]),
12131            "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12132            "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())..]),
12133            "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12134            "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12135            "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())..]),
12136            "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12137            "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12138            "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())..]),
12139            "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())..]),
12140            "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12141            "parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12142            "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12143            "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12144            "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())..]),
12145            "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())..]),
12146            "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())..]),
12147            "parse_order_book_bid_ask_l3" => self.parse_order_book_bid_ask_l3(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12148            "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())..]),
12149            "parse_order_book_bids_asks_l3" => self.parse_order_book_bids_asks_l3(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12150            "parse_order_book_l3" => self.parse_order_book_l3(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
12151            "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12152            "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())..]),
12153            "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12154            "parse_precision" => self.parse_precision(&args[..]),
12155            "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())..]),
12156            "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12157            "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12158            "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12159            "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())..]),
12160            "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12161            "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())..]),
12162            "parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12163            "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())..]),
12164            "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12165            "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())..]),
12166            "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12167            "parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12168            "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12169            "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12170            "parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12171            "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12172            "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12173            "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12174            "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)),
12175            "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12176            "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,
12177            "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)),
12178            "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())..]),
12179            "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12180            "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,
12181            "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,
12182            "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,
12183            "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12184            "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12185            "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
12186            "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12187            "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())..]),
12188            "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())..]),
12189            "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())..]),
12190            "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12191            "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12192            "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12193            "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12194            "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())..]),
12195            "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())..]),
12196            "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())..]),
12197            "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())..]),
12198            "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12199            "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12200            "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())..]),
12201            "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())..]),
12202            "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())..]),
12203            "safe_market" => self.safe_market(&args[..]),
12204            "safe_market_structure" => self.safe_market_structure(&args[..]),
12205            "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12206            "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())..]),
12207            "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())..]),
12208            "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())..]),
12209            "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())..]),
12210            "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12211            "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12212            "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12213            "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12214            "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12215            "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12216            "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())..]),
12217            "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12218            "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12219            "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,
12220            "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12221            "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12222            "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12223            "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12224            "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())..]),
12225            "sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12226            "sign_in" => self.sign_in(&args[..]).await,
12227            "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12228            "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12229            "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12230            "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12231            "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,
12232            "un_watch_bids_asks" => self.un_watch_bids_asks(&args[..]).await,
12233            "un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12234            "un_watch_funding_rates" => self.un_watch_funding_rates(&args[..]).await,
12235            "un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12236            "un_watch_mark_prices" => self.un_watch_mark_prices(&args[..]).await,
12237            "un_watch_my_trades" => self.un_watch_my_trades(&args[..]).await,
12238            "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12239            "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,
12240            "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12241            "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,
12242            "un_watch_orders" => self.un_watch_orders(&args[..]).await,
12243            "un_watch_positions" => self.un_watch_positions(&args[..]).await,
12244            "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12245            "un_watch_tickers" => self.un_watch_tickers(&args[..]).await,
12246            "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12247            "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,
12248            "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12249            "watch_balance" => self.watch_balance(&args[..]).await,
12250            "watch_bids_asks" => self.watch_bids_asks(&args[..]).await,
12251            "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12252            "watch_funding_rates" => self.watch_funding_rates(&args[..]).await,
12253            "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,
12254            "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12255            "watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12256            "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12257            "watch_mark_prices" => self.watch_mark_prices(&args[..]).await,
12258            "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12259            "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,
12260            "watch_my_trades" => self.watch_my_trades(&args[..]).await,
12261            "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,
12262            "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12263            "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12264            "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12265            "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,
12266            "watch_orders" => self.watch_orders(&args[..]).await,
12267            "watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12268            "watch_position" => self.watch_position(&args[..]).await,
12269            "watch_position_for_symbols" => self.watch_position_for_symbols(&args[..]).await,
12270            "watch_positions" => self.watch_positions(&args[..]).await,
12271            "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12272            "watch_tickers" => self.watch_tickers(&args[..]).await,
12273            "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12274            "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12275            "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,
12276            "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,
12277                // Implicit-API endpoints (`publicGetX`) exist only as inherent
12278                // methods on the venue's `<id>_api.rs`, which no name-based
12279                // dispatch arm covers — a static-request test named after one
12280                // (bingx's accountV1PrivateGetAccountApiRestrictions) otherwise
12281                // computes a null url. Route them the way those wrappers do.
12282                // Guarded on the api block so a genuinely unknown name still
12283                // returns Null rather than panicking inside call_method.
12284                //
12285                // Returning Null keeps an optional probe cheap, but a dynamic
12286                // re-entry (`fetchPaginatedCall*` / `fetchWebEndpoint`, which
12287                // reach here via `method_name_to_snake_case`) must not silently
12288                // see an empty page — so record the miss for
12289                // `crate::exchange::call_dynamic_required` to raise on.
12290                _ => {
12291                    if self.internals.implicit_api.is_empty() {
12292                        self.build_implicit_api();
12293                    }
12294                    if self.internals.implicit_api.contains_key(method) {
12295                        self.call_method(crate::Value::Str(method.to_string().into()), &args[..]).await
12296                    } else {
12297                        self.internals.dynamic_dispatch_miss = Some(method.to_string());
12298                        crate::Value::Null
12299                    }
12300                }
12301            }
12302        })
12303    }
12304}