// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct WooCore {
pub exchange: crate::exchange::Exchange,
}
impl WooCore {
pub fn new(config: Option<crate::Value>) -> Self {
let mut s = Self { exchange: crate::exchange::Exchange::new(config) };
s.init();
s
}
pub fn init(&mut self) {
let described = WooCore::describe(self);
self.initialize_properties(described);
// compatibility for sandbox/testnet options in userConfig
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for WooCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_order(self, order, &[market])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_position(self, position, &[market])
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_funding_rate(self, rate, &[market])
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_deposit_address(self, depositAddress, &[currency])
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_ledger_entry(self, entry, &[currency])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_transfer(self, transfer, &[currency])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_currency(self, currency)
}
fn parse_account(&self, account: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_account(self, account)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_transaction(self, transaction, &[currency])
}
fn parse_adl_rank(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_adl_rank(self, info, &[market])
}
fn parse_income(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_income(self, info, &[market])
}
fn parse_conversion(&self, conversion: crate::Value, from_currency: crate::Value, to_currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_conversion(self, conversion, &[from_currency, to_currency])
}
fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::parse_leverage(self, leverage, &[market])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::sign(self, path, &[api, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on WooCore.
WooCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for WooCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"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,
"cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
"cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"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,
"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,
"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,
"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,
"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,
"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,
"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,
"fetch_accounts" => self.fetch_accounts(&args[..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
"fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
"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,
"fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
"fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
"fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
"fetch_ledger" => self.fetch_ledger(&args[..]).await,
"fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders" => self.fetch_orders(&args[..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_positions" => self.fetch_positions(&args[..]).await,
"fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args[..]).await,
"fetch_status" => self.fetch_status(&args[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_time" => self.fetch_time(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"fetch_transfers" => self.fetch_transfers(&args[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
"get_asset_history_rows" => self.get_asset_history_rows(&args[..]).await,
"get_currency_from_chaincode" => self.get_currency_from_chaincode(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"get_dedicated_network_id" => self.get_dedicated_network_id(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"handle_errors" => self.handle_errors(args.get(0).cloned().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)),
"modify_margin_helper" => self.modify_margin_helper(args.get(0).cloned().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,
"nonce" => self.nonce(),
"parse_account" => self.parse_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_adl_rank" => self.parse_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_conversion" => self.parse_conversion(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_income" => self.parse_income(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_leverage" => self.parse_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_margin_loan" => self.parse_margin_loan(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_position" => self.parse_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_time_in_force" => self.parse_time_in_force(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_token_and_fee_temp" => self.parse_token_and_fee_temp(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null)),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trading_fee" => self.parse_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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,
"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,
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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,
"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,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for WooCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for WooCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl WooCore {
pub fn describe(&self) -> Value {
return self.deep_extend(self.super_describe(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("woo".into()));
m.insert("name".to_string(), Value::Str("WOO X".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("KY".into())]));
m.insert("rateLimit".to_string(), Value::Int(100));
m.insert("version".to_string(), Value::Str("v1".into()));
m.insert("certified".to_string(), Value::Bool(false));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("hostname".to_string(), Value::Str("woox.io".into()));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(true));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(true));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelAllOrdersAfter".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelWithdraw".to_string(), Value::Bool(false));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createConvertTrade".to_string(), Value::Bool(true));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrder".to_string(), Value::Bool(false));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(true));
m.insert("createStopLimitOrder".to_string(), Value::Bool(false));
m.insert("createStopLossOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(false));
m.insert("createStopOrder".to_string(), Value::Bool(false));
m.insert("createTakeProfitOrder".to_string(), Value::Bool(true));
m.insert("createTrailingAmountOrder".to_string(), Value::Bool(true));
m.insert("createTrailingPercentOrder".to_string(), Value::Bool(true));
m.insert("createTriggerOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(false));
m.insert("fetchClosedOrder".to_string(), Value::Bool(false));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchConvertCurrencies".to_string(), Value::Bool(true));
m.insert("fetchConvertQuote".to_string(), Value::Bool(true));
m.insert("fetchConvertTrade".to_string(), Value::Bool(true));
m.insert("fetchConvertTradeHistory".to_string(), Value::Bool(true));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingInterval".to_string(), Value::Bool(true));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(true));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingRates".to_string(), Value::Bool(true));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(true));
m.insert("fetchLeverage".to_string(), Value::Bool(true));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenOrder".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositionADLRank".to_string(), Value::Bool(true));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsADLRank".to_string(), Value::Bool(true));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchStatus".to_string(), Value::Bool(true));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(true));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Str("emulated".into()));
m.insert("fetchTransfers".to_string(), Value::Bool(true));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(true));
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("setLeverage".to_string(), Value::Bool(true));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(true));
m.insert("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("15m".to_string(), Value::Str("15m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1h".into()));
m.insert("4h".to_string(), Value::Str("4h".into()));
m.insert("12h".to_string(), Value::Str("12h".into()));
m.insert("1d".to_string(), Value::Str("1d".into()));
m.insert("1w".to_string(), Value::Str("1w".into()));
m.insert("1M".to_string(), Value::Str("1mon".into()));
m.insert("1y".to_string(), Value::Str("1y".into()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pub".to_string(), Value::Str("https://api-pub.woox.io".into()));
m.insert("public".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("private".to_string(), Value::Str("https://api.{hostname}".into()));
m
}));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pub".to_string(), Value::Str("https://api-pub.staging.woox.io".into()));
m.insert("public".to_string(), Value::Str("https://api.staging.woox.io".into()));
m.insert("private".to_string(), Value::Str("https://api.staging.woox.io".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://woox.io/".into()));
m.insert("doc".to_string(), Value::from(vec![Value::Str("https://developer.woox.io/".into()), Value::Str("https://docs.woox.io/".into())]));
m.insert("fees".to_string(), Value::from(vec![Value::Str("https://support.woox.io/hc/en-001/articles/4404611795353--Trading-Fees".into())]));
m.insert("referral".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), Value::Str("https://woox.io/register?ref=DIJT0CNL".into()));
m.insert("discount".to_string(), Value::Float(0.35));
m
}));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v1".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pub".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("hist/kline".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("hist/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m
}));
m
}));
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("system_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market_trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("token".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("token_network".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("funding_rates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("funding_rate/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("funding_rate_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orderbook/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("kline".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client/token".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/{oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("client/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("client/trade/{tid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/{oid}/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("client/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("client/hist_trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("staking/yield_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("client/holding".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("asset/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("sub_account/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("sub_account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("sub_account/asset_detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("sub_account/ip_restriction".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("asset/main_sub_transfer_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("token_interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("token_interest/{token}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("interest/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("interest/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("funding_fee/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(3.33));
m
}));
m.insert("position/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(3.33));
m
}));
m.insert("client/transaction_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("client/futures_leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/cancel_all_after".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/ltv".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("asset/internal_withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("interest/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("client/account_mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(120));
m
}));
m.insert("client/position_mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("client/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(120));
m
}));
m.insert("client/futures_leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("client/isolated_margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("client/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(120));
m
}));
m
}));
m
}));
m
}));
m.insert("v3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("systemInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("token".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tokenNetwork".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tokenInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("marketTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("marketTradesHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("kline".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("klineHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fundingRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fundingRateHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("insuranceFund".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trade/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("trade/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/algoOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/transaction".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/transactionHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("trade/tradingFee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("account/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("account/tokenConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/symbolConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/subAccounts/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("account/referral/summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("account/referral/rewardHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("account/credentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("asset/balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/token/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("asset/transfer/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("asset/wallet/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("asset/wallet/deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("asset/staking/yieldHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("futures/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(3.33));
m
}));
m.insert("futures/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("futures/defaultMarginMode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("futures/fundingFee/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("spotMargin/interestRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("spotMargin/interestHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("spotMargin/maxMargin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("algo/order/{oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("algo/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(3.33));
m
}));
m.insert("buypower".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/assetInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/rfq".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("convert/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trade/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("trade/algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("trade/cancelAllAfter".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/tradingMode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(120));
m
}));
m.insert("account/listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("asset/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("asset/wallet/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("spotMargin/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(120));
m
}));
m.insert("spotMargin/interestRepay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("futures/defaultMarginMode/reset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("isolatedMargin/margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("algo/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("convert/rft".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trade/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("trade/algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("futures/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("futures/positionMode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(120));
m
}));
m.insert("futures/defaultMarginMode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("futures/defaultMarginMode/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("order/{oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/client/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("algo/order/{oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("algo/order/client/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trade/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/algoOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("algo/order/{order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("algo/orders/pending".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("algo/orders/pending/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/pending".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/wallet/withdraw/{withdrawId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0002".into()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0005".into()), &[]));
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timeDifference".to_string(), Value::Int(0));
m.insert("adjustForTimeDifference".to_string(), Value::Bool(false));
m.insert("sandboxMode".to_string(), Value::Bool(false));
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(true));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRC20".to_string(), Value::Str("TRX".into()));
m.insert("ERC20".to_string(), Value::Str("ETH".into()));
m.insert("BEP20".to_string(), Value::Str("BSC".into()));
m.insert("ARBITRUM".to_string(), Value::Str("Arbitrum".into()));
m.insert("BASE".to_string(), Value::Str("BASE".into()));
m.insert("AVAXC".to_string(), Value::Str("AVAXC".into()));
m.insert("OP".to_string(), Value::Str("OP".into()));
m.insert("OPTIMISM".to_string(), Value::Str("OP".into()));
m.insert("MATIC".to_string(), Value::Str("MATIC".into()));
m.insert("SONIC".to_string(), Value::Str("S".into()));
m.insert("HYPEREVM".to_string(), Value::Str("HyperEVM".into()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRX".to_string(), Value::Str("TRC20".into()));
m.insert("TRON".to_string(), Value::Str("TRC20".into()));
m.insert("OP".to_string(), Value::Str("OP".into()));
m
}));
m.insert("defaultNetworkCodeForCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fillResponseFromRequest".to_string(), Value::Bool(true));
m
}));
m.insert("brokerId".to_string(), Value::Str("bc830de7-50f3-460b-9ee0-f430f83f9dad".into()));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("default".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("last".to_string(), Value::Bool(true));
m.insert("mark".to_string(), Value::Bool(true));
m.insert("index".to_string(), Value::Bool(false));
m
}));
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(true));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(true));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(true));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(500));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("untilDays".to_string(), Value::Int(10000));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(500));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(true));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(500));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(true));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(500));
m.insert("daysBack".to_string(), Value::Null);
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(true));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(1000));
m
}));
m
}));
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m
}));
m.insert("forSwap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("hedged".to_string(), Value::Bool(true));
m
}));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forSwap".into()));
m
}));
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1000".to_string(), Value::Str("OperationFailed".into()).clone());
m.insert("-1001".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-1002".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-1003".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("-1004".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1005".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1006".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1007".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1008".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-1009".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1012".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1101".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-1102".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-1103".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-1104".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-1105".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317136".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317137".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317138".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317139".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317140".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317141".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317142".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317143".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317144".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317145".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317146".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317147".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317148".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("317149".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("317150".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317151".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317152".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("317153".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("317154".to_string(), Value::Str("OperationFailed".into()).clone());
m.insert("317155".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("317156".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("317157".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317158".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317159".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("317160".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317161".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317162".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("317163".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317164".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317165".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317166".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317167".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317168".to_string(), Value::Str("OperationFailed".into()).clone());
m.insert("317169".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317170".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317171".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("317172".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("317173".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("317174".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317176".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317177".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317178".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("317179".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("317184".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("317206".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("317207".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302001".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302002".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302003".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("302004".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("302005".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302101".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("302102".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302103".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302104".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302109".to_string(), Value::Str("OperationFailed".into()).clone());
m.insert("302110".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302111".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302112".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302113".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302114".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302115".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302117".to_string(), Value::Str("DuplicateOrderId".into()).clone());
m.insert("302118".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302119".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302120".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302121".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302122".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302123".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302125".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302126".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302127".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302128".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302129".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("302130".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302131".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302132".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302133".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302134".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("302135".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("302136".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("302137".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302138".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302140".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302141".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302142".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302143".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302144".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302145".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302147".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302148".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302149".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302150".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302151".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302152".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302154".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302155".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302156".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302157".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302159".to_string(), Value::Str("RequestTimeout".into()).clone());
m.insert("302160".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302162".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302163".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302164".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302165".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302166".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302167".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302168".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302169".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302170".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302171".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302172".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302177".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302178".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302185".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302186".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302188".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302189".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302190".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302191".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302192".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302193".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302194".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302195".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302196".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302197".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302198".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302199".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302301".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302303".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302305".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302306".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("302307".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("302308".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302309".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302310".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("302311".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302312".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302313".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("302314".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("302999".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("311001".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("311002".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("311004".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("311999".to_string(), Value::Str("OperationFailed".into()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Can not place".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("maintenance".to_string(), Value::Str("OnMaintenance".into()).clone());
m.insert("symbol must not be blank".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("The token is not supported".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("Your order and symbol are not valid or already canceled".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("Insufficient WOO. Please enable margin trading for leverage trading".to_string(), Value::Str("BadRequest".into()).clone());
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m
})]);
Value::Null
}
/*
* @method
* @name woo#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://developer.woox.io/api-reference/endpoint/public_data/systemInfo
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [status structure]{@link https://docs.ccxt.com/?id=exchange-status-structure}
*/
pub async fn fetch_status(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.v3_public_get_system_info(&[params]).await;
//
// {
// "success": true,
// "data": {
// "status": 0,
// "msg": "System is functioning properly.",
// "estimatedEndTime": 1749963600362
// },
// "timestamp": 1751442989564
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut status: Value = self.safe_string_k(data, "status", &[]);
if (status == Value::Null) {
status = Value::Str("error".into());
} else if (status.as_str() == Some("0")) {
status = Value::Str("ok".into());
} else {
status = Value::Str("maintenance".into());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), status);
m.insert("updated".to_string(), Value::Null);
m.insert("eta".to_string(), Value::Null);
m.insert("url".to_string(), Value::Null);
m.insert("info".to_string(), response);
m
});
Value::Null
}
/*
* @method
* @name woo#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://developer.woox.io/api-reference/endpoint/public_data/systemInfo
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
pub async fn fetch_time(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.v3_public_get_system_info(&[params]).await;
return self.safe_integer_k(response, "timestamp", &[]);
Value::Null
}
/*
* @method
* @name woo#fetchMarkets
* @description retrieves data on all markets for woo
* @see https://developer.woox.io/api-reference/endpoint/public_data/instruments
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if matches!(self.safe_bool_k(self.options.clone(), "adjustForTimeDifference", &[Value::Bool(false)]), Value::Bool(true)) {
self.load_time_difference(&[]).await;
}
let mut response: Value = self.v3_public_get_instruments(&[params]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "SPOT_AAVE_USDT",
// "status": "TRADING",
// "baseAsset": "AAVE",
// "baseAssetMultiplier": 1,
// "quoteAsset": "USDT",
// "quoteMin": "0",
// "quoteMax": "100000",
// "quoteTick": "0.01",
// "baseMin": "0.005",
// "baseMax": "5000",
// "baseTick": "0.0001",
// "minNotional": "1",
// "bidCapRatio": "1.1",
// "bidFloorRatio": null,
// "askCapRatio": null,
// "askFloorRatio": "0.9",
// "orderMode": "NORMAL",
// "impactNotional": null,
// "isAllowedRpi": false,
// "tickGranularity": null
// }
// ]
// },
// "timestamp": 1751512951338
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
return self.parse_markets(rows);
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[Value::Str("".into())]);
let mut parts: Value = split(&marketId, &Value::Str("_".into()));
let mut first: Option<String> = self.safe_string(parts.clone(), Value::Int(0), &[]).as_str().map(str::to_owned);
let mut marketType: Value = Value::Null;
let mut spot: Value = Value::Bool(false);
let mut swap: Value = Value::Bool(false);
if (first.as_deref() == Some("SPOT")) {
spot = Value::Bool(true);
marketType = Value::Str("spot".into());
} else if (first.as_deref() == Some("PERP")) {
swap = Value::Bool(true);
marketType = Value::Str("swap".into());
}
let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(1), &[]);
let mut quoteId: Value = self.safe_string(parts.clone(), Value::Int(2), &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
return Value::Null;
}
let mut settleId: Value = Value::Null;
let mut settle: Value = Value::Null;
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
let mut contractSize: Value = Value::Null;
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
let mut margin: Value = Value::Bool(true);
let mut contract: Value = swap.clone();
if is_true(&contract) {
margin = Value::Bool(false);
settleId = self.safe_string(parts, Value::Int(2), &[]);
settle = self.safe_currency_code(settleId.clone(), &[]);
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()), Value::Str(":".into())).into()), settle).into());
contractSize = self.parse_number(Value::Str("1".into()), &[]);
linear = Value::Bool(true);
inverse = Value::Bool(false);
}
let mut active: Value = Value::Bool(self.safe_string_k(market.clone(), "status", &[]).as_str() == Some("TRADING"));
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), settle);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), marketType);
m.insert("spot".to_string(), spot);
m.insert("margin".to_string(), margin);
m.insert("swap".to_string(), swap);
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active);
m.insert("contract".to_string(), contract);
m.insert("linear".to_string(), linear);
m.insert("inverse".to_string(), inverse);
m.insert("contractSize".to_string(), contractSize);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.safe_number_k(market.clone(), "baseTick", &[]));
m.insert("price".to_string(), self.safe_number_k(market.clone(), "quoteTick", &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "baseMin", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "baseMax", &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "quoteMin", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "quoteMax", &[]));
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minNotional", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market);
m
})]);
Value::Null
}
/*
* @method
* @name woo#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://developer.woox.io/api-reference/endpoint/public_data/marketTrades
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let __ws_arg_0 = self.extend(request, &[params]);
let mut response: Value = self.v3_public_get_market_trades(&[__ws_arg_0]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "SPOT_BTC_USDT",
// "side": "SELL",
// "source": 0,
// "executedPrice": "108741.01",
// "executedQuantity": "0.02477",
// "executedTimestamp": 1751513940144
// }
// ]
// },
// "timestamp": 1751513988543
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
return self.parse_trades(rows, &[market, since, limit]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// public/market_trades
//
// {
// "symbol": "SPOT_BTC_USDT",
// "side": "SELL",
// "source": 0,
// "executedPrice": "108741.01",
// "executedQuantity": "0.02477",
// "executedTimestamp": 1751513940144
// }
//
// fetchOrderTrades, fetchOrder
//
// {
// "id": 1734947821,
// "symbol": "SPOT_LTC_USDT",
// "orderId": 60780383217,
// "executedPrice": 87.86,
// "executedQuantity": 0.1,
// "fee": 0.0001,
// "realizedPnl": null,
// "feeAsset": "LTC",
// "orderTag": "default",
// "side": "BUY",
// "executedTimestamp": "1752055173.630",
// "isMaker": 0
// }
//
let mut isFromFetchOrder: bool = matches!(&trade, Value::Dict(__d) if __d.contains_key("id"));
let mut timestampString: Value = self.safe_string2(trade.clone(), Value::Str("executed_timestamp".into()), Value::Str("executedTimestamp".into()), &[]);
let mut timestamp: Value = Value::Null;
if (timestampString != Value::Null) {
if Value::Int(timestampString.as_str().and_then(|__s| __s.find(".")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64) {
timestamp = self.safe_timestamp2(trade.clone(), Value::Str("executed_timestamp".into()), Value::Str("executedTimestamp".into()), &[]);
} else {
timestamp = self.safe_integer_k(trade.clone(), "executedTimestamp", &[]);
}
}
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market]);
let mut symbol: Value = marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
let mut price: Value = self.safe_string2(trade.clone(), Value::Str("executed_price".into()), Value::Str("executedPrice".into()), &[]);
let mut amount: Value = self.safe_string2(trade.clone(), Value::Str("executed_quantity".into()), Value::Str("executedQuantity".into()), &[]);
let mut order_id: Value = self.safe_string2(trade.clone(), Value::Str("order_id".into()), Value::Str("orderId".into()), &[]);
let mut fee: Value = self.parse_token_and_fee_temp(trade.clone(), Value::from(vec![Value::Str("fee_asset".into()), Value::Str("feeAsset".into())]), Value::from(vec![Value::Str("fee".into())]));
let mut feeCost: Value = self.safe_string_k(fee.clone(), "cost", &[]);
if (fee != Value::Null) && (feeCost != Value::Null) {
if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("cost".into(), feeCost); }
}
let mut cost: Value = crate::precise::Precise::stringMul(&price, &amount);
let mut side: Value = self.safe_string_lower_k(trade.clone(), "side", &[]);
let mut id: Value = self.safe_string_k(trade.clone(), "id", &[]);
let mut takerOrMaker: Value = Value::Null;
if isFromFetchOrder {
let mut isMaker: bool = self.safe_string2(trade.clone(), Value::Str("is_maker".into()), Value::Str("isMaker".into()), &[]).as_str() == Some("1");
takerOrMaker = (if isMaker { Value::Str("maker".into()) } else { Value::Str("taker".into()) });
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), symbol);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), cost);
m.insert("order".to_string(), order_id);
m.insert("takerOrMaker".to_string(), takerOrMaker);
m.insert("type".to_string(), Value::Null);
m.insert("fee".to_string(), fee);
m.insert("info".to_string(), trade);
m
}), &[marketResolved]);
Value::Null
}
pub fn parse_token_and_fee_temp(&self, mut item: Value, mut feeTokenKeys: Value, mut feeAmountKeys: Value) -> Value {
let mut feeCost: Value = self.safe_string_n(item.clone(), feeAmountKeys, &[]);
let mut fee: Value = Value::Null;
if (feeCost != Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_n(item, feeTokenKeys, &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrencyId, &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost);
m.insert("currency".to_string(), feeCurrencyCode);
m
});
}
return fee;
Value::Null
}
pub fn parse_trading_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(fee.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), symbol);
m.insert("maker".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&self.safe_string_k(fee.clone(), "makerFee", &[]), &Value::Str("100".into())), &[]));
m.insert("taker".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&self.safe_string_k(fee, "takerFee", &[]), &Value::Str("100".into())), &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name woo#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://developer.woox.io/api-reference/endpoint/trading/get_tradingFee
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_1 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_get_trade_trading_fee(&[__ws_arg_1]).await;
//
// {
// "success": true,
// "data": {
// "symbol": "SPOT_BTC_USDT",
// "takerFee": "10",
// "makerFee": "8"
// },
// "timestamp": 1751858977368
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_trading_fee(data, &[market]);
Value::Null
}
/*
* @method
* @name woo#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://developer.woox.io/api-reference/endpoint/account/get_account_info
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v3_private_get_account_info(&[params]).await;
//
// {
// "success": true,
// "data": {
// "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0",
// "account": "carlos_jose_lima@yahoo.com",
// "alias": "carlos_jose_lima@yahoo.com",
// "otpauth": true,
// "accountMode": "FUTURES",
// "positionMode": "ONE_WAY",
// "leverage": 0,
// "makerFeeRate": 0,
// "takerFeeRate": 0,
// "marginRatio": "10",
// "openMarginRatio": "10",
// "initialMarginRatio": "10",
// "maintenanceMarginRatio": "0.03",
// "totalCollateral": "165.55629469",
// "freeCollateral": "165.55629469",
// "totalAccountValue": "167.32418611",
// "totalTradingValue": "167.32418611",
// "totalVaultValue": "0",
// "totalStakingValue": "0",
// "totalLaunchpadValue": "0",
// "totalEarnValue": "0",
// "referrerID": null,
// "accountType": "Main"
// },
// "timestamp": 1752062807915
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut maker: Value = self.safe_string_k(data.clone(), "makerFeeRate", &[]);
let mut taker: Value = self.safe_string_k(data, "takerFeeRate", &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbols: Value = self.symbols.clone();
if (symbols == Value::Null) {
return result;
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_1140: bool = true;
while { if !__for_first_1140 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1140 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
let mut symbol: Value = 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);
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&maker, &Value::Str("10000".into())), &[]));
m.insert("taker".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&taker, &Value::Str("10000".into())), &[]));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m
})); }
}
}
return result;
Value::Null
}
/*
* @method
* @name woo#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://docs.woox.io/#available-token-public
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut tokenResponsePromise: Value = self.v1_public_get_token(&[params.clone()]).await;
//
// {
// "rows": [
// {
// "token": "ETH_USDT",
// "fullname": "Tether",
// "network": "ETH",
// "decimals": "6",
// "delisted": false,
// "balance_token": "USDT",
// "created_time": "1710123398",
// "updated_time": "1746528481",
// "can_collateral": true,
// "can_short": true
// },
// {
// "token": "BSC_USDT",
// "fullname": "Tether",
// "network": "BSC",
// "decimals": "18",
// "delisted": false,
// "balance_token": "USDT",
// "created_time": "1710123395",
// "updated_time": "1746528601",
// "can_collateral": true,
// "can_short": true
// },
// {
// "token": "ALGO",
// "fullname": "Algorand",
// "network": "ALGO",
// "decimals": "6",
// "delisted": false,
// "balance_token": "ALGO",
// "created_time": "1710123394",
// "updated_time": "1723087518",
// "can_collateral": true,
// "can_short": true
// },
// ...
// ],
// "success": true
// }
//
// only make one request for currencies...
let mut tokenNetworkResponsePromise: Value = self.v1_public_get_token_network(&[params]).await;
//
// {
// "rows": [
// {
// "protocol": "ERC20",
// "network": "ETH",
// "token": "USDT",
// "name": "Ethereum (ERC20)",
// "minimum_withdrawal": "10.00000000",
// "withdrawal_fee": "2.00000000",
// "allow_deposit": "1",
// "allow_withdraw": "1"
// },
// {
// "protocol": "TRC20",
// "network": "TRX",
// "token": "USDT",
// "name": "Tron (TRC20)",
// "minimum_withdrawal": "10.00000000",
// "withdrawal_fee": "4.50000000",
// "allow_deposit": "1",
// "allow_withdraw": "1"
// },
// ...
// ],
// "success": true
// }
//
let mut tokenResponsetokenNetworkResponseVariable = promise_all(&Value::from(vec![tokenResponsePromise, tokenNetworkResponsePromise])).await;
let mut tokenResponse: Value = tokenResponsetokenNetworkResponseVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut tokenNetworkResponse: Value = tokenResponsetokenNetworkResponseVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut tokenRows: Value = self.safe_list_k(tokenResponse, "rows", &[Value::from(vec![])]);
let mut tokenNetworkRows: Value = self.safe_list_k(tokenNetworkResponse, "rows", &[Value::from(vec![])]);
let mut networksById: Value = self.group_by(tokenNetworkRows, Value::Str("token".into()), &[]);
let mut tokensById: Value = self.group_by(tokenRows, Value::Str("balance_token".into()), &[]);
let mut currencyIds: Value = object_keys(&tokensById);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1141: bool = true;
while { if !__for_first_1141 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1141 = false; i.as_f64().unwrap_or(f64::NAN) < ((currencyIds.len() as i64) as f64) } {
let mut id: Value = currencyIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut customCurrency: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("_coin_id".to_string(), id.clone());
m.insert("_tokens_by_id".to_string(), tokensById.as_map().and_then(|__m| id.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null));
m.insert("_networks_by_id".to_string(), networksById.as_map().and_then(|__m| id.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null));
m
});
let mut parsed: Value = self.parse_currency(customCurrency);
let mut code: Value = self.safe_string_k(parsed.clone(), "code", &[]);
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), parsed); }
}
}
}
return result;
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut currencyId: Value = self.safe_string_k(rawCurrency.clone(), "_coin_id", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut tokensByNetworkId: Value = self.index_by(rawCurrency.as_map().and_then(|__m| __m.get("_tokens_by_id")).cloned().unwrap_or(Value::Null), Value::Str("network".into()));
let mut chainsByNetworkId: Value = self.index_by(rawCurrency.as_map().and_then(|__m| __m.get("_networks_by_id")).cloned().unwrap_or(Value::Null), Value::Str("network".into()));
let mut keys: Value = object_keys(&chainsByNetworkId);
let mut resultingNetworks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut j: Value = Value::Int(0);
let mut __for_first_1142: bool = true;
while { if !__for_first_1142 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1142 = false; j.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
let mut networkId: Value = keys.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);
let mut tokenEntry: Value = self.safe_dict(tokensByNetworkId.clone(), networkId.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut networkEntry: Value = self.safe_dict(chainsByNetworkId.clone(), networkId.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
let mut specialNetworkId: Value = self.safe_string_k(tokenEntry.clone(), "token", &[]);
if (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut resultingNetworks { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&networkCode), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), networkId);
m.insert("currencyNetworkId".to_string(), specialNetworkId);
m.insert("network".to_string(), networkCode.clone());
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Bool(self.safe_string_k(networkEntry.clone(), "allow_deposit", &[]).as_str() == Some("1")));
m.insert("withdraw".to_string(), Value::Bool(self.safe_string_k(networkEntry.clone(), "allow_withdraw", &[]).as_str() == Some("1")));
m.insert("fee".to_string(), self.safe_number_k(networkEntry.clone(), "withdrawal_fee", &[]));
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(tokenEntry.clone(), "decimals", &[])]), &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(networkEntry.clone(), "minimum_withdrawal", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("network".to_string(), networkEntry);
m.insert("token".to_string(), tokenEntry);
m
}));
m
})); }
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), currencyId);
m.insert("name".to_string(), Value::Null);
m.insert("code".to_string(), code);
m.insert("precision".to_string(), Value::Null);
m.insert("active".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("networks".to_string(), resultingNetworks);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("crypto".into()));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("info".to_string(), rawCurrency);
m
}));
Value::Null
}
/*
* @method
* @name woo#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://developer.woox.io/api-reference/endpoint/trading/post_order
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_buy_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() supports spot orders only".into()))));
}
return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Int(1), params]).await;
Value::Null
}
/*
* @method
* @name woo#createMarketSellOrderWithCost
* @description create a market sell order by providing the symbol and cost
* @see https://developer.woox.io/api-reference/endpoint/trading/post_order
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_sell_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketSellOrderWithCost() supports spot orders only".into()))));
}
return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), cost, &[Value::Int(1), params]).await;
Value::Null
}
/*
* @method
* @name woo#createTrailingAmountOrder
* @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
* @see https://developer.woox.io/api-reference/endpoint/trading/post_algo_order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency, or number of contracts
* @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
* @param {float} trailingAmount the quote amount to trail away from the current market price
* @param {float} trailingTriggerPrice the price to activate a trailing order, default uses the price argument
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_trailing_amount_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (trailingAmount == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".into()))));
}
if (trailingTriggerPrice == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingTriggerPrice argument".into()))));
}
if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
Value::Null
}
/*
* @method
* @name woo#createTrailingPercentOrder
* @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
* @see https://developer.woox.io/api-reference/endpoint/trading/post_algo_order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency, or number of contracts
* @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
* @param {float} trailingPercent the percent to trail away from the current market price
* @param {float} trailingTriggerPrice the price to activate a trailing order, default uses the price argument
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_trailing_percent_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (trailingPercent == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".into()))));
}
if (trailingTriggerPrice == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingTriggerPrice argument".into()))));
}
if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
Value::Null
}
/*
* @method
* @name woo#createOrder
* @description create a trade order
* @see https://developer.woox.io/api-reference/endpoint/trading/post_order
* @see https://developer.woox.io/api-reference/endpoint/trading/post_algo_order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated', default 'cross'
* @param {float} [params.triggerPrice] The price a trigger order is triggered at
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
* @param {float} [params.algoType] 'STOP' or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
* @param {string} [params.position_side] 'SHORT' or 'LONG' - if position mode is HEDGE_MODE and the trading involves futures, then is required, otherwise this parameter is not required
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut reduceOnly: Value = self.safe_bool2(params.clone(), Value::Str("reduceOnly".into()), Value::Str("reduce_only".into()), &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("reduceOnly".into()), Value::Str("reduce_only".into())]), &[]);
let mut orderType: Value = to_upper(&type_var);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut orderSide: Value = to_upper(&side);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("side".to_string(), orderSide.clone());
m
});
let mut marginModeparamsMarginModeVariable = self.handle_margin_mode_and_params(Value::Str("createOrder".into()), &[paramsOmitted]);
let mut marginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (marginMode != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginMode".into(), self.encode_margin_mode(marginMode).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
}
let mut triggerPrice: Value = self.safe_string2(paramsMarginMode.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
let mut stopLoss: Value = self.safe_value_k(paramsMarginMode.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_value_k(paramsMarginMode.clone(), "takeProfit", &[]);
let mut hasStopLoss: bool = stopLoss != Value::Null;
let mut hasTakeProfit: bool = takeProfit != Value::Null;
let mut algoType: Option<String> = self.safe_string_k(paramsMarginMode.clone(), "algoType", &[]).as_str().map(str::to_owned);
let mut trailingTriggerPrice: Value = self.safe_string2(paramsMarginMode.clone(), Value::Str("trailingTriggerPrice".into()), Value::Str("activatedPrice".into()), &[self.number_to_string(price.clone())]);
let mut trailingAmount: Value = self.safe_string2(paramsMarginMode.clone(), Value::Str("trailingAmount".into()), Value::Str("callbackValue".into()), &[]);
let mut trailingPercent: Value = self.safe_string2(paramsMarginMode.clone(), Value::Str("trailingPercent".into()), Value::Str("callbackRate".into()), &[]);
let mut isTrailingAmountOrder: bool = trailingAmount != Value::Null;
let mut isTrailingPercentOrder: bool = trailingPercent != Value::Null;
let mut isTrailing: bool = isTrailingAmountOrder || isTrailingPercentOrder;
let mut isConditional: bool = isTrailing || (triggerPrice != Value::Null) || hasStopLoss || hasTakeProfit || (self.safe_value_k(paramsMarginMode.clone(), "childOrders", &[]) != Value::Null);
let mut isMarket: Value = Value::Bool(orderType.as_str() == Some("MARKET"));
let mut timeInForce: Option<String> = self.safe_string_lower_k(paramsMarginMode.clone(), "timeInForce", &[]).as_str().map(str::to_owned);
let mut postOnly: Value = self.is_post_only(isMarket.clone(), Value::Null, &[paramsMarginMode.clone()]);
let mut clientOrderIdKey: Value = Value::Str("clientOrderId".into());
if isConditional {
clientOrderIdKey = Value::Str("clientAlgoOrderId".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), orderType); }; // LIMIT/MARKET/IOC/FOK/POST_ONLY/ASK/BID
if !isConditional {
if is_true(&postOnly) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str("POST_ONLY".into())); }
} else if (timeInForce.as_deref() == Some("fok")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str("FOK".into())); }
} else if (timeInForce.as_deref() == Some("ioc")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str("IOC".into())); }
}
}
if (reduceOnly.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("reduceOnly".into(), reduceOnly); }
}
if !(matches!(&isMarket, Value::Bool(true))) && (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price.clone())); }
}
let mut isMarketNotConditional: bool = matches!(&isMarket, Value::Bool(true)) && !isConditional;
let mut paramsCost: Value = paramsMarginMode.clone();
if isMarketNotConditional {
paramsCost = self.omit(paramsMarginMode.clone(), Value::from(vec![Value::Str("cost".into()), Value::Str("order_amount".into()), Value::Str("orderAmount".into())]), &[]);
}
if isMarketNotConditional {
// for market buy it requires the amount of quote currency to spend
let mut cost: Value = self.safe_string_n(paramsMarginMode, Value::from(vec![Value::Str("cost".into()), Value::Str("order_amount".into()), Value::Str("orderAmount".into())]), &[]);
let mut isPriceProvided: bool = price != Value::Null;
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) && (isPriceProvided || (cost != Value::Null)) {
let mut quoteAmount: Value = Value::Null;
if (cost != Value::Null) {
quoteAmount = self.cost_to_precision(symbol.clone(), cost);
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price);
let mut costRequest: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
quoteAmount = self.cost_to_precision(symbol.clone(), costRequest);
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), quoteAmount); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quantity".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
}
} else if (algoType.as_deref() != Some("POSITIONAL_TP_SL")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quantity".into(), self.amount_to_precision(symbol.clone(), amount)); }
}
let mut clientOrderId: Value = self.safe_string_n(paramsCost.clone(), Value::from(vec![Value::Str("clOrdID".into()), Value::Str("clientOrderId".into()), Value::Str("client_order_id".into())]), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&clientOrderIdKey), clientOrderId); }
}
if isTrailing {
if (trailingTriggerPrice == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a trailingTriggerPrice parameter for trailing orders".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("activatedPrice".into(), self.price_to_precision(symbol.clone(), trailingTriggerPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("algoType".into(), Value::Str("TRAILING_STOP".into())); }
if isTrailingAmountOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("callbackValue".into(), trailingAmount); }
} else if isTrailingPercentOrder {
let mut convertedTrailingPercent: Value = crate::precise::Precise::stringDiv(&trailingPercent, &Value::Str("100".into()));
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("callbackRate".into(), convertedTrailingPercent); }
}
} else if (triggerPrice != Value::Null) {
if (algoType.as_deref() != Some("TRAILING_STOP")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), triggerPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("algoType".into(), Value::Str("STOP".into())); }
}
} else if hasStopLoss || hasTakeProfit {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("algoType".into(), Value::Str("BRACKET".into())); }
let mut outterOrder: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("reduceOnly".to_string(), Value::Bool(false));
m.insert("algoType".to_string(), Value::Str("POSITIONAL_TP_SL".into()));
m.insert("childOrders".to_string(), Value::from(vec![]));
m
});
let mut childOrders: Value = match &outterOrder { Value::Dict(__m15) => __m15.get("childOrders").cloned().unwrap_or(Value::Null), _ => Value::Null };
let mut closeSide: Value = Value::Str("BUY".into());
if (orderSide.as_str() == Some("BUY")) {
closeSide = Value::Str("SELL".into());
}
if hasStopLoss {
let mut stopLossPrice: Value = self.safe_string_k(stopLoss.clone(), "triggerPrice", &[stopLoss.clone()]);
let mut stopLossOrder: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("side".to_string(), closeSide.clone());
m.insert("algoType".to_string(), Value::Str("STOP_LOSS".into()));
m.insert("triggerPrice".to_string(), self.price_to_precision(symbol.clone(), stopLossPrice));
m.insert("type".to_string(), Value::Str("CLOSE_POSITION".into()));
m.insert("reduceOnly".to_string(), Value::Bool(true));
m
});
append_to_array(&mut childOrders, stopLossOrder);
}
if hasTakeProfit {
let mut takeProfitPrice: Value = self.safe_string_k(takeProfit.clone(), "triggerPrice", &[takeProfit.clone()]);
let mut takeProfitOrder: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("side".to_string(), closeSide);
m.insert("algoType".to_string(), Value::Str("TAKE_PROFIT".into()));
m.insert("triggerPrice".to_string(), self.price_to_precision(symbol, takeProfitPrice));
m.insert("type".to_string(), Value::Str("CLOSE_POSITION".into()));
m.insert("reduceOnly".to_string(), Value::Bool(true));
m
});
append_to_array(&mut childOrders, takeProfitOrder);
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("childOrders".into(), Value::from(vec![outterOrder])); }
}
let mut paramsRequest: Value = self.omit(paramsCost, Value::from(vec![Value::Str("clOrdID".into()), Value::Str("clientOrderId".into()), Value::Str("client_order_id".into()), Value::Str("postOnly".into()), Value::Str("timeInForce".into()), Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), Value::Str("stopLoss".into()), Value::Str("takeProfit".into()), Value::Str("trailingPercent".into()), Value::Str("trailingAmount".into()), Value::Str("trailingTriggerPrice".into())]), &[]);
let mut response: Value = Value::Null;
if isConditional {
let __ws_arg_2 = self.extend(request.clone(), &[paramsRequest.clone()]);
response = self.v3_private_post_trade_algo_order(&[__ws_arg_2]).await;
} else {
let __ws_arg_3 = self.extend(request, &[paramsRequest]);
response = self.v3_private_post_trade_order(&[__ws_arg_3]).await;
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
data = self.safe_dict(self.safe_list_k(data.clone(), "rows", &[]), Value::Int(0), &[data.clone()]);
add_element_to_object(&mut data, &Value::Str("timestamp".into()), self.safe_string_k(response, "timestamp", &[]));
return self.parse_order(data, &[market]);
Value::Null
}
pub fn encode_margin_mode(&self, mut mode: Value) -> Option<String> {
let mut modes: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), Value::Str("CROSS".into()));
m.insert("isolated".to_string(), Value::Str("ISOLATED".into()));
m
});
return self.safe_string(modes, mode.clone(), &[mode.clone()]).as_str().map(str::to_owned);
}
/*
* @method
* @name woo#editOrder
* @description edit a trade order
* @see https://developer.woox.io/api-reference/endpoint/trading/edit_order
* @see https://developer.woox.io/api-reference/endpoint/trading/edit_algo_order
* @param {string} id order id
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] client order id of the order to edit, used instead of the id argument
* @param {boolean} [params.trigger] whether the order is a trigger/algo order, set to true to edit an algo order without passing trigger parameters
* @param {float} [params.triggerPrice] The price a trigger order is triggered at
* @param {float} [params.stopLossPrice] price to trigger stop-loss orders
* @param {float} [params.takeProfitPrice] price to trigger take-profit orders
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price.clone())); }
}
if (amount != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quantity".into(), self.amount_to_precision(symbol.clone(), amount)); }
}
let mut clientOrderIdUnified: Value = self.safe_string2(params.clone(), Value::Str("clOrdID".into()), Value::Str("clientOrderId".into()), &[]);
let mut clientOrderIdExchangeSpecific: Value = self.safe_string_k(params.clone(), "client_order_id", &[clientOrderIdUnified]);
let mut isByClientOrder: bool = clientOrderIdExchangeSpecific != Value::Null;
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), Value::Str("takeProfitPrice".into()), Value::Str("stopLossPrice".into())]), &[]);
if (triggerPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), triggerPrice.clone())); }
}
let mut trailingTriggerPrice: Value = self.safe_string2(params.clone(), Value::Str("trailingTriggerPrice".into()), Value::Str("activatedPrice".into()), &[self.number_to_string(price)]);
let mut trailingAmount: Value = self.safe_string2(params.clone(), Value::Str("trailingAmount".into()), Value::Str("callbackValue".into()), &[]);
let mut trailingPercent: Value = self.safe_string2(params.clone(), Value::Str("trailingPercent".into()), Value::Str("callbackRate".into()), &[]);
let mut isTrailingAmountOrder: bool = trailingAmount != Value::Null;
let mut isTrailingPercentOrder: bool = trailingPercent != Value::Null;
let mut isTrailing: bool = isTrailingAmountOrder || isTrailingPercentOrder;
if isTrailing {
if (trailingTriggerPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("activatedPrice".into(), self.price_to_precision(symbol, trailingTriggerPrice)); }
}
if isTrailingAmountOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("callbackValue".into(), trailingAmount); }
} else if isTrailingPercentOrder {
let mut convertedTrailingPercent: Value = crate::precise::Precise::stringDiv(&trailingPercent, &Value::Str("100".into()));
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("callbackRate".into(), convertedTrailingPercent); }
}
}
let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[Value::Bool(false)]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("clOrdID".into()), Value::Str("clientOrderId".into()), Value::Str("client_order_id".into()), Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), Value::Str("takeProfitPrice".into()), Value::Str("stopLossPrice".into()), Value::Str("trailingTriggerPrice".into()), Value::Str("trailingAmount".into()), Value::Str("trailingPercent".into()), Value::Str("trigger".into()), Value::Str("stop".into())]), &[]);
let mut isConditional: bool = (isTrigger.as_bool() == Some(true)) || isTrailing || (triggerPrice != Value::Null) || (self.safe_value_k(paramsOmitted.clone(), "childOrders", &[]) != Value::Null);
let mut response: Value = Value::Null;
if isConditional {
if isByClientOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientAlgoOrderId".into(), clientOrderIdExchangeSpecific.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("algoOrderId".into(), id.clone()); }
}
let __ws_arg_4 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.v3_private_put_trade_algo_order(&[__ws_arg_4]).await;
} else {
if isByClientOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOrderId".into(), clientOrderIdExchangeSpecific.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderId".into(), id.clone()); }
}
let __ws_arg_5 = self.extend(request, &[paramsOmitted]);
response = self.v3_private_put_trade_order(&[__ws_arg_5]).await;
}
//
// {
// "success": true,
// "data": {
// "status": "EDIT_SENT"
// },
// "timestamp": 1786038156772
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut order: Value = self.extend(response, &[data]);
if isByClientOrder {
add_element_to_object(&mut order, &Value::Str("clientOrderId".into()), clientOrderIdExchangeSpecific);
} else {
add_element_to_object(&mut order, &Value::Str("orderId".into()), id);
}
return self.parse_order(order, &[market]);
Value::Null
}
/*
* @method
* @name woo#cancelOrder
* @see https://developer.woox.io/api-reference/endpoint/trading/cancel_order
* @see https://developer.woox.io/api-reference/endpoint/trading/cancel_algo_order
* @description cancels an open order
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] whether the order is a trigger/algo order
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[Value::Bool(false)]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("trigger".into()), Value::Str("stop".into())]), &[]);
if (isTrigger.as_bool() != Some(true)) && (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut clientOrderIdUnified: Value = self.safe_string2(paramsOmitted.clone(), Value::Str("clOrdID".into()), Value::Str("clientOrderId".into()), &[]);
let mut clientOrderIdExchangeSpecific: Value = self.safe_string_k(paramsOmitted.clone(), "client_order_id", &[clientOrderIdUnified]);
let mut paramsOmitted2: Value = self.omit(paramsOmitted, Value::from(vec![Value::Str("clOrdID".into()), Value::Str("clientOrderId".into()), Value::Str("client_order_id".into())]), &[]);
let mut isByClientOrder: bool = clientOrderIdExchangeSpecific != Value::Null;
let mut response: Value = Value::Null;
if (isTrigger.as_bool() == Some(true)) {
if isByClientOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientAlgoOrderId".into(), clientOrderIdExchangeSpecific.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("algoOrderId".into(), id.clone()); }
}
let __ws_arg_6 = self.extend(request.clone(), &[paramsOmitted2.clone()]);
response = self.v3_private_delete_trade_algo_order(&[__ws_arg_6]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.safe_string_k(market.clone(), "id", &[])); }
if isByClientOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOrderId".into(), clientOrderIdExchangeSpecific.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderId".into(), id.clone()); }
}
let __ws_arg_7 = self.extend(request, &[paramsOmitted2]);
response = self.v3_private_delete_trade_order(&[__ws_arg_7]).await;
}
//
// {
// "success": true,
// "data": {
// "status": "CANCEL_SENT"
// },
// "timestamp": 1751940315838
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(&mut data, &Value::Str("timestamp".into()), self.safe_string_k(response, "timestamp", &[]));
if isByClientOrder {
if let Value::Dict(__d) = &mut data { std::sync::Arc::make_mut(__d).insert("clientOrderId".into(), clientOrderIdExchangeSpecific); }
} else {
if let Value::Dict(__d) = &mut data { std::sync::Arc::make_mut(__d).insert("orderId".into(), id); }
}
return self.parse_order(data, &[market]);
Value::Null
}
/*
* @method
* @name woo#cancelAllOrders
* @see https://developer.woox.io/api-reference/endpoint/trading/cancel_orders_by_symbol
* @see https://developer.woox.io/api-reference/endpoint/trading/cancel_algo_orders
* @description cancel all open orders in a market
* @param {string} [symbol] unified market symbol, cancels orders in all markets when omitted
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] set to true to cancel only trigger/algo orders
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("stop".into()), Value::Str("trigger".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
let mut market: Value = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let mut response: Value = Value::Null;
if (trigger.as_bool() == Some(true)) {
response = self.v3_private_delete_trade_algo_orders(&[paramsOmitted.clone()]).await;
} else {
// cancels both regular and algo orders
let __ws_arg_8 = self.extend(request, &[paramsOmitted]);
response = self.v3_private_delete_trade_all_orders(&[__ws_arg_8]).await;
}
//
// {
// "success": true,
// "data": {
// "status": "CANCEL_ALL_SENT"
// },
// "timestamp": 1751941988134
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return Value::from(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), data);
m
}), &[])]);
Value::Null
}
/*
* @method
* @name woo#cancelAllOrdersAfter
* @description dead man's switch, cancel all orders after the given timeout
* @see https://developer.woox.io/api-reference/endpoint/trading/cancel_all_after
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} the api result
*/
pub async fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerAfter".to_string(), (if (timeout.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) { crate::runtime::Math::min(&timeout, &Value::Int(900000)) } else { Value::Int(0) }));
m
});
let __ws_arg_9 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_post_trade_cancel_all_after(&[__ws_arg_9]).await;
return response;
Value::Null
}
/*
* @method
* @name woo#fetchOrder
* @see https://developer.woox.io/api-reference/endpoint/trading/get_order
* @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_order
* @description fetches information on an order made by the user
* @param {string} id the order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] whether the order is a trigger/algo order
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("stop".into()), Value::Str("trigger".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut clientOrderId: Value = self.safe_string2(paramsOmitted.clone(), Value::Str("clOrdID".into()), Value::Str("clientOrderId".into()), &[]);
let mut response: Value = Value::Null;
if (trigger.as_bool() == Some(true)) {
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientAlgoOrderId".into(), id.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("algoOrderId".into(), id.clone()); }
}
let __ws_arg_10 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.v3_private_get_trade_algo_order(&[__ws_arg_10]).await;
} else {
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOrderId".into(), clientOrderId); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderId".into(), id); }
}
let __ws_arg_11 = self.extend(request, &[paramsOmitted]);
response = self.v3_private_get_trade_order(&[__ws_arg_11]).await;
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data, &[market]);
Value::Null
}
/*
* @method
* @name woo#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://developer.woox.io/api-reference/endpoint/trading/get_orders
* @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] whether the order is a trigger/algo order
* @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
* @param {string} [params.side] 'buy' or 'sell'
* @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(params, Value::Str("fetchOrders".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchOrders".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("page".into()), Value::Int(500)]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut trigger: Value = self.safe_bool2(paramsPaginate.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
let mut paramsOmitted: Value = self.omit(paramsPaginate, Value::from(vec![Value::Str("stop".into()), Value::Str("trigger".into())]), &[]);
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let mut until: Value = self.safe_integer_k(paramsOmitted.clone(), "until", &[]); // unified in milliseconds
let mut paramsOmitted2: Value = self.omit(paramsOmitted, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), until); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), crate::runtime::Math::min(&limit, &Value::Int(500))); }
}
let mut response: Value = Value::Null;
if (trigger.as_bool() == Some(true)) {
let __ws_arg_12 = self.extend(request.clone(), &[paramsOmitted2.clone()]);
response = self.v3_private_get_trade_algo_orders(&[__ws_arg_12]).await;
} else {
let __ws_arg_13 = self.extend(request, &[paramsOmitted2]);
response = self.v3_private_get_trade_orders(&[__ws_arg_13]).await;
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name woo#fetchOpenOrders
* @description fetches information on multiple orders made by the user
* @see https://developer.woox.io/api-reference/endpoint/trading/get_orders
* @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] whether the order is a trigger/algo order
* @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
* @param {string} [params.side] 'buy' or 'sell'
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
* @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut extendedParams: Value = self.extend(params, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("INCOMPLETE".into()));
m
})]);
return self.fetch_orders(&[symbol, since, limit, extendedParams]).await;
Value::Null
}
/*
* @method
* @name woo#fetchClosedOrders
* @description fetches information on multiple orders made by the user
* @see https://developer.woox.io/api-reference/endpoint/trading/get_orders
* @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] whether the order is a trigger/algo order
* @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
* @param {string} [params.side] 'buy' or 'sell'
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
* @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut extendedParams: Value = self.extend(params, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("COMPLETED".into()));
m
})]);
return self.fetch_orders(&[symbol, since, limit, extendedParams]).await;
Value::Null
}
pub fn parse_time_in_force(&self, mut timeInForce: Value) -> Value {
let mut timeInForces: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ioc".to_string(), Value::Str("IOC".into()));
m.insert("fok".to_string(), Value::Str("FOK".into()));
m.insert("post_only".to_string(), Value::Str("PO".into()));
m
});
return self.safe_string(timeInForces, timeInForce, &[]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder
// {
// "orderId": 60667653330,
// "clientOrderId": 0,
// "type": "LIMIT",
// "price": 60,
// "quantity": 0.1,
// "amount": null,
// "bidAskLevel": null,
// "timestamp": 1751871779855
// }
//
// createOrder - algo
// {
// "orderId": "1578938",
// "clientOrderId": "0",
// "algoType": "STOP_LOSS",
// "quantity": "0.1",
// "timestamp": "1686149372216"
// }
//
// fetchOrder
// {
// "orderId": 60780315704,
// "clientOrderId": 0,
// "symbol": "SPOT_LTC_USDT",
// "orderTag": "default",
// "side": "BUY",
// "quantity": 0.1,
// "amount": null,
// "type": "LIMIT",
// "status": "NEW",
// "price": 60,
// "executed": 0,
// "visible": 0.1,
// "averageExecutedPrice": 0,
// "totalFee": 0,
// "feeAsset": "LTC",
// "totalRebate": 0,
// "rebateAsset": "USDT",
// "reduceOnly": false,
// "createdTime": "1752049062.496",
// "realizedPnl": null,
// "positionSide": "BOTH",
// "bidAskLevel": null
// }
//
// fetchOrder - algo
// {
// "algoOrderId": 10399260,
// "clientAlgoOrderId": 0,
// "rootAlgoOrderId": 10399260,
// "parentAlgoOrderId": 0,
// "symbol": "SPOT_LTC_USDT",
// "algoOrderTag": "default",
// "algoType": "TAKE_PROFIT",
// "side": "BUY",
// "quantity": 0.1,
// "isTriggered": false,
// "triggerPrice": 65,
// "triggerStatus": "USELESS",
// "type": "LIMIT",
// "rootAlgoStatus": "NEW",
// "algoStatus": "NEW",
// "triggerPriceType": "MARKET_PRICE",
// "price": 60,
// "triggerTime": "0",
// "totalExecutedQuantity": 0,
// "visibleQuantity": 0.1,
// "averageExecutedPrice": 0,
// "totalFee": 0,
// "feeAsset": "",
// "totalRebate": 0,
// "rebateAsset": "",
// "reduceOnly": false,
// "createdTime": "1752049747.732",
// "updatedTime": "1752049747.732",
// "positionSide": "BOTH"
// }
//
let mut timestamp: Value = Value::Null;
let mut timestrampString: Value = self.safe_string_k(order.clone(), "createdTime", &[]);
if (timestrampString != Value::Null) {
if Value::Int(timestrampString.as_str().and_then(|__s| __s.find(".")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
timestamp = self.safe_timestamp_k(order.clone(), "createdTime", &[]); // algo orders
} else {
timestamp = self.safe_integer_k(order.clone(), "createdTime", &[]); // regular orders
}
}
if (timestamp == Value::Null) {
timestamp = self.safe_integer_k(order.clone(), "timestamp", &[]);
}
let mut orderId: Value = self.safe_string2(order.clone(), Value::Str("orderId".into()), Value::Str("algoOrderId".into()), &[]);
let mut clientOrderId: Value = self.omit_zero(self.safe_string2(order.clone(), Value::Str("clientOrderId".into()), Value::Str("clientAlgoOrderId".into()), &[])); // Somehow, this always returns 0 for limit order
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market]);
let mut symbol: Value = marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "quantity", &[]); // This is base amount
let mut orderType: Value = self.safe_string_lower_k(order.clone(), "type", &[]);
let mut status: Value = self.safe_string2(order.clone(), Value::Str("status".into()), Value::Str("algoStatus".into()), &[]);
let mut side: Value = self.safe_string_lower_k(order.clone(), "side", &[]);
let mut filled: Value = self.safe_string2(order.clone(), Value::Str("executed".into()), Value::Str("totalExecutedQuantity".into()), &[]);
let mut average: Value = self.omit_zero(self.safe_string_k(order.clone(), "averageExecutedPrice", &[]));
// const remaining = Precise.stringSub (cost, filled);
let mut fee: Value = self.safe_number_k(order.clone(), "totalFee", &[]);
let mut feeCurrency: Value = self.safe_string_k(order.clone(), "feeAsset", &[]);
let mut triggerPrice: Value = self.safe_number_k(order.clone(), "triggerPrice", &[]);
let mut lastUpdateTimestampString: Value = self.safe_string_k(order.clone(), "updatedTime", &[]);
let mut lastUpdateTimestamp: Value = Value::Null;
if (lastUpdateTimestampString != Value::Null) {
if Value::Int(lastUpdateTimestampString.as_str().and_then(|__s| __s.find(".")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
lastUpdateTimestamp = self.safe_timestamp_k(order.clone(), "updatedTime", &[]); // algo orders
} else {
lastUpdateTimestamp = self.safe_integer_k(order.clone(), "updatedTime", &[]); // regular orders
}
}
let mut postOnly: Value = Value::Null;
if (orderType != Value::Null) {
postOnly = (Value::Bool(orderType.as_str() == Some("post_only")));
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), orderId);
m.insert("clientOrderId".to_string(), clientOrderId);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp);
m.insert("status".to_string(), self.parse_order_status(status));
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), orderType.clone());
m.insert("timeInForce".to_string(), self.parse_time_in_force(orderType));
m.insert("postOnly".to_string(), postOnly);
m.insert("reduceOnly".to_string(), self.safe_bool_k(order.clone(), "reduceOnly", &[]));
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("triggerPrice".to_string(), triggerPrice);
m.insert("takeProfitPrice".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("average".to_string(), average);
m.insert("amount".to_string(), amount);
m.insert("filled".to_string(), filled);
m.insert("remaining".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), fee);
m.insert("currency".to_string(), feeCurrency);
m
}));
m.insert("info".to_string(), order);
m
}), &[marketResolved]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
if (status != Value::Null) {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("NEW".to_string(), Value::Str("open".into()));
m.insert("FILLED".to_string(), Value::Str("closed".into()));
m.insert("EDIT_SENT".to_string(), Value::Str("open".into()));
m.insert("CANCEL_SENT".to_string(), Value::Str("canceled".into()));
m.insert("CANCEL_ALL_SENT".to_string(), Value::Str("canceled".into()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".into()));
m.insert("PARTIAL_FILLED".to_string(), Value::Str("open".into()));
m.insert("REJECTED".to_string(), Value::Str("rejected".into()));
m.insert("INCOMPLETE".to_string(), Value::Str("open".into()));
m.insert("COMPLETED".to_string(), Value::Str("closed".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]);
}
return Value::Null;
Value::Null
}
/*
* @method
* @name woo#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://developer.woox.io/api-reference/endpoint/public_data/orderbook
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("maxLevel".into(), limit); }
}
let __ws_arg_14 = self.extend(request, &[params]);
let mut response: Value = self.v3_public_get_orderbook(&[__ws_arg_14]).await;
//
// }
// {
// "success": true,
// "timestamp": 1751620923344,
// "data": {
// "asks": [
// {
// "price": "108924.86",
// "quantity": "0.032126"
// }
// ],
// "bids": [
// {
// "price": "108924.85",
// "quantity": "1.714147"
// }
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.safe_integer_k(response, "timestamp", &[]);
return self.parse_order_book(data, symbol, &[timestamp, Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("price".into()), Value::Str("quantity".into())]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "PERP_BTC_USDT",
// "indexPrice": "63049",
// "markPrice": "63028",
// "estFundingRate": "0.00008868",
// "lastFundingRate": "0.00008545",
// "openInterest": "221.3498",
// "24hOpen": "63880",
// "24hClose": "63020",
// "24hHigh": "64000",
// "24hLow": "62800",
// "24hVolume": "12000",
// "24hAmount": "756000000",
// "nextFundingTime": 1786694400000
// }
//
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market]);
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "timestamp", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "24hHigh", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "24hLow", &[]));
m.insert("bid".to_string(), Value::Null);
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), Value::Null);
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "24hOpen", &[]));
m.insert("close".to_string(), self.safe_string_k(ticker.clone(), "24hClose", &[]));
m.insert("last".to_string(), self.safe_string_k(ticker.clone(), "24hClose", &[]));
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string_k(ticker.clone(), "24hVolume", &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(ticker.clone(), "24hAmount", &[]));
m.insert("indexPrice".to_string(), self.safe_string_k(ticker.clone(), "indexPrice", &[]));
m.insert("markPrice".to_string(), self.safe_string_k(ticker.clone(), "markPrice", &[]));
m.insert("info".to_string(), ticker);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name woo#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market, swap markets only
* @see https://developer.woox.io/api-reference/endpoint/public_data/futures
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() supports swap markets only, there is no spot ticker endpoint".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_15 = self.extend(request, &[params]);
let mut response: Value = self.v3_public_get_futures(&[__ws_arg_15]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "PERP_BTC_USDT",
// "indexPrice": "63049",
// "markPrice": "63028",
// "estFundingRate": "0.00008868",
// "lastFundingRate": "0.00008545",
// "openInterest": "221.3498",
// "24hOpen": "63880",
// "24hClose": "63020",
// "24hHigh": "64000",
// "24hLow": "62800",
// "24hVolume": "12000",
// "24hAmount": "756000000",
// "nextFundingTime": 1786694400000
// }
// ]
// },
// "timestamp": 1786690534921
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(rows, Value::Int(0), &[]);
if (first == Value::Null) {
panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() could not find ticker data for ".into())).into()), symbol)));
}
let __ws_arg_16 = self.safe_integer_k(response, "timestamp", &[]);
let mut ticker: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timestamp".to_string(), __ws_arg_16);
m
}), &[first]);
return self.parse_ticker(ticker, &[market]);
Value::Null
}
/*
* @method
* @name woo#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market, only swap markets are supported
* @see https://developer.woox.io/api-reference/endpoint/public_data/futures
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, swap markets only, all swap tickers are returned when not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] market type, must be 'swap' when no symbols are provided
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
if (symbols != Value::Null) {
let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
if symbolsLength > ((0i64) as f64) {
// the type gate throws NotSupported rather than letting marketSymbols raise
// BadRequest, so callers (and the live test harness) can tell "wrong market
// type" apart from a malformed request, marketSymbols still enforces that the
// rest of the list matches
let mut firstMarket: Value = self.market(symbols.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
if (firstMarket.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() supports swap markets only".into()))));
}
}
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols, Value::Str("swap".into()), Value::Bool(true), Value::Bool(true)]);
let mut paramsRequest: Value = params.clone();
if (symbolsNormalized == Value::Null) {
let mut marketTypeparamsMarketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchTickers".into()), &[Value::Null, params, Value::Str("swap".into())]);
let mut marketType: Value = marketTypeparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = marketTypeparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (marketType.as_str() != Some("swap")) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() supports swap markets only".into()))));
}
paramsRequest = paramsMarketType;
}
let mut response: Value = self.v3_public_get_futures(&[paramsRequest]).await;
//
// same as fetchTicker, with multiple rows
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
let mut timestamp: Value = self.safe_integer_k(response, "timestamp", &[]);
let mut result: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1143: bool = true;
while { if !__for_first_1143 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1143 = false; i.as_f64().unwrap_or(f64::NAN) < ((rows.len() as i64) as f64) } {
let mut row: Value = rows.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(row.clone(), "symbol", &[]);
if (marketId == Value::Null) {
continue;
}
if (self.markets_by_id.clone() == Value::Null) || !(in_op(&self.markets_by_id, &marketId)) {
continue;
}
let mut ticker: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timestamp".to_string(), timestamp.clone());
m
}), &[row]);
append_to_array(&mut result, self.parse_ticker(ticker, &[]));
}
}
return self.filter_by_array_tickers(result, Value::Str("symbol".into()), &[symbolsNormalized]);
Value::Null
}
/*
* @method
* @name woo#fetchOHLCV
* @see https://developer.woox.io/api-reference/endpoint/public_data/klineHistory
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] max=1000, max=100 when since is defined and is less than (now - (999 * (timeframe in ms)))
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch entries for
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("type".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), crate::runtime::Math::min(&limit, &Value::Int(1000))); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("after".into(), (match (&(since), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }; // #27793
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(params, Value::Str("until".into()), &[]);
if (until != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("before".into(), until); }
}
let __ws_arg_17 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.v3_public_get_kline_history(&[__ws_arg_17]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "SPOT_BTC_USDT",
// "open": "108994.16",
// "close": "108994.16",
// "high": "108994.16",
// "low": "108994.16",
// "volume": "0",
// "amount": "0",
// "type": "1m",
// "startTimestamp": 1751622120000,
// "endTimestamp": 1751622180000
// }
// ]
// },
// "timestamp": 1751622205410
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
return self.parse_ohlc_vs(rows, &[market, timeframe, since, limit]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::from(vec![self.safe_integer_k(ohlcv.clone(), "startTimestamp", &[]), self.safe_number_k(ohlcv.clone(), "open", &[]), self.safe_number_k(ohlcv.clone(), "high", &[]), self.safe_number_k(ohlcv.clone(), "low", &[]), self.safe_number_k(ohlcv.clone(), "close", &[]), self.safe_number_k(ohlcv, "volume", &[])]);
Value::Null
}
/*
* @method
* @name woo#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://docs.woox.io/#get-trades
* @param {string} id order id
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("oid".to_string(), id);
m
});
let __ws_arg_18 = self.extend(request, &[params.clone()]);
let mut response: Value = self.v1_private_get_order_oid_trades(&[__ws_arg_18]).await;
// {
// "success": true,
// "rows": [
// {
// "id": "99111647",
// "symbol": "SPOT_WOO_USDT",
// "fee": "0.0024",
// "side": "BUY",
// "executed_timestamp": "1641482113.084",
// "order_id": "87541111",
// "order_tag": "default",
// "executed_price": "1",
// "executed_quantity": "12",
// "fee_asset": "WOO",
// "is_maker": "1"
// }
// ]
// }
let mut trades: Value = self.safe_list_k(response, "rows", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit, params]);
Value::Null
}
/*
* @method
* @name woo#fetchMyTrades
* @description fetch all trades made by the user
* @see https://developer.woox.io/api-reference/endpoint/trading/get_transactions
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] set to true if you want to fetch trades with pagination
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(params, Value::Str("fetchMyTrades".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchMyTrades".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("page".into()), Value::Int(500)]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let mut until: Value = self.safe_integer_k(paramsPaginate.clone(), "until", &[]); // unified in milliseconds
let mut paramsOmitted: Value = self.omit(paramsPaginate, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), until); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let __ws_arg_19 = self.extend(request, &[paramsOmitted.clone()]);
let mut response: Value = self.v3_private_get_trade_transaction_history(&[__ws_arg_19]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "id": 1734947821,
// "symbol": "SPOT_LTC_USDT",
// "orderId": 60780383217,
// "executedPrice": 87.86,
// "executedQuantity": 0.1,
// "fee": 0.0001,
// "realizedPnl": null,
// "feeAsset": "LTC",
// "orderTag": "default",
// "side": "BUY",
// "executedTimestamp": "1752055173.630",
// "isMaker": 0
// }
// ],
// "meta": {
// "total": 1,
// "recordsPerPage": 100,
// "currentPage": 1
// }
// },
// "timestamp": 1752055545121
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut trades: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit, paramsOmitted]);
Value::Null
}
/*
* @method
* @name woo#fetchAccounts
* @description fetch all the accounts associated with a profile
* @see https://developer.woox.io/api-reference/endpoint/account/get_account_info
* @see https://developer.woox.io/api-reference/endpoint/account/sub_accounts
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/?id=account-structure} indexed by the account type
*/
pub async fn fetch_accounts(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut mainAccountPromise: Value = self.v3_private_get_account_info(&[params.clone()]).await;
//
// {
// "success": true,
// "data": {
// "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0",
// "account": "carlos_jose_lima@yahoo.com",
// "alias": "carlos_jose_lima@yahoo.com",
// "otpauth": true,
// "accountMode": "FUTURES",
// "positionMode": "ONE_WAY",
// "leverage": 0,
// "marginRatio": "10",
// "openMarginRatio": "10",
// "initialMarginRatio": "10",
// "maintenanceMarginRatio": "0.03",
// "totalCollateral": "165.55629469",
// "freeCollateral": "165.55629469",
// "totalAccountValue": "167.32418611",
// "totalTradingValue": "167.32418611",
// "totalVaultValue": "0",
// "totalStakingValue": "0",
// "totalLaunchpadValue": "0",
// "totalEarnValue": "0",
// "referrerID": null,
// "accountType": "Main"
// },
// "timestamp": 1752062807915
// }
//
let mut subAccountPromise: Value = self.v3_private_get_account_sub_accounts_all(&[params.clone()]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "applicationId": "6b43de5c-0955-4887-9862-d84e4689f9fe",
// "name": "sub_account_2",
// "createdTime": "1606897264.994"
// },
// ]
// },
// "timestamp": 1721295317627
// }
//
let mut mainAccountResponsesubAccountResponseVariable = promise_all(&Value::from(vec![mainAccountPromise, subAccountPromise])).await;
let mut mainAccountResponse: Value = mainAccountResponsesubAccountResponseVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut subAccountResponse: Value = mainAccountResponsesubAccountResponseVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut mainData: Value = self.safe_dict_k(mainAccountResponse, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut mainRows: Value = Value::from(vec![mainData]);
let mut subData: Value = self.safe_dict_k(subAccountResponse, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut subRows: Value = self.safe_list_k(subData, "rows", &[Value::from(vec![])]);
let mut rows: Value = self.array_concat(mainRows, subRows);
return self.parse_accounts(rows, &[params]);
Value::Null
}
pub fn parse_account(&self, mut account: Value) -> Value {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), account.clone());
m.insert("id".to_string(), self.safe_string_k(account.clone(), "applicationId", &[]));
m.insert("name".to_string(), self.safe_string_n(account.clone(), Value::from(vec![Value::Str("name".into()), Value::Str("account".into()), Value::Str("alias".into())]), &[]));
m.insert("code".to_string(), Value::Null);
m.insert("type".to_string(), self.safe_string_lower_k(account, "accountType", &[Value::Str("subaccount".into())]));
m
});
Value::Null
}
/*
* @method
* @name woo#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://developer.woox.io/api-reference/endpoint/assets/get_balances
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v3_private_get_asset_balances(&[params]).await;
//
// {
// "success": true,
// "data": {
// "holding": [
// {
// "token": "0_token",
// "holding": 1,
// "frozen": 0,
// "staked": 0,
// "unbonding": 0,
// "vault": 0,
// "interest": 0,
// "pendingShortQty": 0,
// "pendingLongQty": 0,
// "availableBalance": 0,
// "updatedTime": 312321.121
// }
// ]
// },
// "timestamp": 1673323746259
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[]);
return self.parse_balance(data);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
let mut balances: Value = self.safe_list_k(response, "holding", &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1144: bool = true;
while { if !__for_first_1144 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1144 = false; i.as_f64().unwrap_or(f64::NAN) < ((balances.len() as i64) as f64) } {
let mut balance: Value = self.safe_dict(balances.clone(), i.clone(), &[]);
let mut code: Value = self.safe_currency_code(self.safe_string_k(balance.clone(), "token", &[]), &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string_k(balance.clone(), "holding", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(balance, "availableBalance", &[])); }
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
return self.safe_balance(result);
Value::Null
}
/*
* @method
* @name woo#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_deposit
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// this method is TODO because of networks unification
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code);
let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(params);
let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("token".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("network".to_string(), self.network_code_to_id(networkCode, &[self.safe_string_k(currency.clone(), "code", &[])]));
m
});
let __ws_arg_20 = self.extend(request.clone(), &[paramsNetworkCode]);
let mut response: Value = self.v3_private_get_asset_wallet_deposit(&[__ws_arg_20]).await;
//
// {
// "success": true,
// "data": {
// "address": "0x31d64B3230f8baDD91dE1710A65DF536aF8f7cDa",
// "extra": ""
// },
// "timestamp": 1721300689532
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let __ws_arg_21 = self.extend(data, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("network".to_string(), self.safe_string_k(request, "network", &[]));
m
})]);
return self.parse_deposit_address(__ws_arg_21, &[currency]);
Value::Null
}
pub fn get_dedicated_network_id(&self, mut currency: Value, mut params: Value) -> Value {
let mut networkCodeRawparamsNetworkCodeVariable = self.handle_network_code_and_params(params);
let mut networkCodeRaw: Value = networkCodeRawparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsNetworkCode: Value = networkCodeRawparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut networkCode: Value = self.network_id_to_code(&[networkCodeRaw, crate::value::get_value_k(¤cy, "code")]);
let mut networkEntry: Value = (if (networkCode == Value::Null) { Value::Null } else { self.safe_dict(crate::value::get_value_k(¤cy, "networks"), networkCode, &[]) });
if (networkEntry == Value::Null) {
let mut supportedNetworks: Value = object_keys(&crate::value::get_value_k(¤cy, "networks"));
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" can not determine a network code, please provide unified \"network\" param, one from the following: ".into())).into()), json_stringify(&supportedNetworks))));
}
let mut currentyNetworkId: Value = self.safe_string_k(networkEntry, "currencyNetworkId", &[]);
return Value::from(vec![currentyNetworkId, paramsNetworkCode]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositEntry: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let __currency_empty = indexmap::IndexMap::new();
let currency = currency.as_map().unwrap_or(&__currency_empty);
let mut address: Value = self.safe_string_k(depositEntry.clone(), "address", &[]);
self.check_address(&[address.clone()]);
let mut networkId: Value = self.safe_string_k(depositEntry.clone(), "network", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositEntry.clone());
m.insert("currency".to_string(), (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 }));
m.insert("network".to_string(), self.network_id_to_code(&[networkId, (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 })]));
m.insert("address".to_string(), address);
m.insert("tag".to_string(), self.safe_string_k(depositEntry, "extra", &[]));
m
});
Value::Null
}
pub async fn get_asset_history_rows(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("token".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(params);
let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("network".into(), self.network_code_to_id(networkCode, &[self.safe_string_k(currency.clone(), "code", &[])])); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), crate::runtime::Math::min(&limit, &Value::Int(1000))); }
}
let mut transactionType: Value = self.safe_string_k(paramsNetworkCode.clone(), "type", &[]);
let mut paramsOmitted: Value = self.omit(paramsNetworkCode, Value::Str("type".into()), &[]);
if (transactionType != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), transactionType); }
}
let __ws_arg_22 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.v3_private_get_asset_wallet_history(&[__ws_arg_22]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "createdTime": "1734964440.523",
// "updatedTime": "1734964614.081",
// "id": "24122314340000586",
// "externalId": "241223143600621",
// "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0",
// "token": "ARB_USDCNATIVE",
// "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635",
// "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4",
// "extra": "",
// "type": "BALANCE",
// "tokenSide": "WITHDRAW",
// "amount": "10.00000000",
// "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6",
// "feeToken": "USDC",
// "feeAmount": "2",
// "status": "COMPLETED",
// "confirmingThreshold": null,
// "confirmedNumber": null
// }
// ],
// "meta": {
// "total": 1,
// "records_per_page": 25,
// "current_page": 1
// }
// },
// "timestamp": 1752485344719
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return Value::from(vec![currency, self.safe_list_k(data, "rows", &[Value::from(vec![])])]);
Value::Null
}
/*
* @method
* @name woo#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered balance of the user
* @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
* @param {int} [limit] max number of ledger entries to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
*/
pub async fn fetch_ledger(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut currencyRows: Value = self.get_asset_history_rows(&[code, since.clone(), limit.clone(), params.clone()]).await;
let mut currency: Value = self.safe_value(currencyRows.clone(), Value::Int(0), &[]);
let mut rows: Value = self.safe_list(currencyRows, Value::Int(1), &[]);
return self.parse_ledger(rows, &[currency, since, limit, params]);
Value::Null
}
pub fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "createdTime": "1734964440.523",
// "updatedTime": "1734964614.081",
// "id": "24122314340000585",
// "externalId": "241223143600621",
// "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0",
// "token": "ARB_USDCNATIVE",
// "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635",
// "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4",
// "extra": "",
// "type": "BALANCE",
// "tokenSide": "WITHDRAW",
// "amount": "10.00000000",
// "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6",
// "feeToken": "USDC",
// "feeAmount": "2",
// "status": "COMPLETED",
// "confirmingThreshold": null,
// "confirmedNumber": null
// }
//
let mut networkizedCode: Value = self.safe_string_k(item.clone(), "token", &[]);
let mut code: Value = self.safe_currency_code(networkizedCode, &[currency.clone()]);
let mut currencyResolved: Value = self.safe_currency(code.clone(), &[currency]);
let mut amount: Value = self.safe_number_k(item.clone(), "amount", &[]);
let mut side: Option<String> = self.safe_string_k(item.clone(), "tokenSide", &[]).as_str().map(str::to_owned);
let mut direction: Value = Value::Str("out".into());
if (side.as_deref() == Some("DEPOSIT")) {
direction = Value::Str("in".into());
}
let mut timestamp: Value = self.safe_timestamp_k(item.clone(), "createdTime", &[]);
let mut fee: Value = self.parse_token_and_fee_temp(item.clone(), Value::from(vec![Value::Str("feeToken".into())]), Value::from(vec![Value::Str("feeAmount".into())]));
return self.safe_ledger_entry(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), item.clone());
m.insert("id".to_string(), self.safe_string_k(item.clone(), "id", &[]));
m.insert("currency".to_string(), code);
m.insert("account".to_string(), self.safe_string_k(item.clone(), "account", &[]));
m.insert("referenceAccount".to_string(), Value::Null);
m.insert("referenceId".to_string(), self.safe_string_k(item.clone(), "txId", &[]));
m.insert("status".to_string(), self.parse_transaction_status(self.safe_string_k(item.clone(), "status", &[])).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("amount".to_string(), amount);
m.insert("before".to_string(), Value::Null);
m.insert("after".to_string(), Value::Null);
m.insert("direction".to_string(), direction);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("type".to_string(), self.parse_ledger_entry_type(self.safe_string_k(item, "type", &[])).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("fee".to_string(), fee);
m
}), &[currencyResolved]);
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Option<String> {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BALANCE".to_string(), Value::Str("transaction".into()));
m.insert("COLLATERAL".to_string(), Value::Str("transfer".into()));
m
});
return self.safe_string(types, type_var.clone(), &[type_var.clone()]).as_str().map(str::to_owned);
}
pub fn get_currency_from_chaincode(&self, mut networkizedCode: Value, mut currency: Value) -> Value {
if (currency != Value::Null) {
return currency;
} else {
let mut parts: Value = split(&networkizedCode, &Value::Str("_".into()));
let mut partsLength: Value = get_array_length(&parts);
let mut firstPart: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
let mut currencyId: Value = self.safe_string(parts.clone(), Value::Int(1), &[firstPart]);
if partsLength.as_f64().unwrap_or(f64::NAN) > ((2i64) as f64) {
currencyId = Value::Str(format!("{}{}", currencyId, Value::Str(format!("{}{}", Value::Str("_".into()), self.safe_string(parts, Value::Int(2), &[])).into())).into());
}
return self.safe_currency(currencyId, &[]);
}
Value::Null
}
/*
* @method
* @name woo#fetchDeposits
* @description fetch all deposits made to an account
* @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tokenSide".to_string(), Value::Str("DEPOSIT".into()));
m
});
let __ws_arg_23 = self.extend(request, &[params]);
return self.fetch_deposits_withdrawals(&[code, since, limit, __ws_arg_23]).await;
Value::Null
}
/*
* @method
* @name woo#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tokenSide".to_string(), Value::Str("WITHDRAW".into()));
m
});
let __ws_arg_24 = self.extend(request, &[params]);
return self.fetch_deposits_withdrawals(&[code, since, limit, __ws_arg_24]).await;
Value::Null
}
/*
* @method
* @name woo#fetchDepositsWithdrawals
* @description fetch history of deposits and withdrawals
* @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("BALANCE".into()));
m
});
let __ws_arg_25 = self.extend(request, &[params.clone()]);
let mut currencyRows: Value = self.get_asset_history_rows(&[code, since.clone(), limit.clone(), __ws_arg_25]).await;
let mut currency: Value = self.safe_value(currencyRows.clone(), Value::Int(0), &[]);
let mut rows: Value = self.safe_list(currencyRows, Value::Int(1), &[Value::from(vec![])]);
return self.parse_transactions(rows, &[currency, since, limit, self.omit(params, Value::Str("tokenSide".into()), &[])]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "createdTime": "1734964440.523",
// "updatedTime": "1734964614.081",
// "id": "24122314340000585",
// "externalId": "241223143600621",
// "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0",
// "token": "ARB_USDCNATIVE",
// "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635",
// "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4",
// "extra": "",
// "type": "BALANCE",
// "tokenSide": "WITHDRAW",
// "amount": "10.00000000",
// "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6",
// "feeToken": "USDC",
// "feeAmount": "2",
// "status": "COMPLETED",
// "confirmingThreshold": null,
// "confirmedNumber": null
// }
//
let mut networkizedCode: Value = self.safe_string_k(transaction.clone(), "token", &[]);
let mut currencyDefined: Value = self.get_currency_from_chaincode(networkizedCode, currency);
let mut code: Value = crate::value::get_value_k(¤cyDefined, "code");
let mut movementDirection: Value = self.safe_string_lower_n(transaction.clone(), Value::from(vec![Value::Str("token_side".into()), Value::Str("tokenSide".into()), Value::Str("type".into())]), &[]);
if (movementDirection.as_str() == Some("withdraw")) {
movementDirection = Value::Str("withdrawal".into());
}
let mut fee: Value = self.parse_token_and_fee_temp(transaction.clone(), Value::from(vec![Value::Str("fee_token".into()), Value::Str("feeToken".into())]), Value::from(vec![Value::Str("fee_amount".into()), Value::Str("feeAmount".into())]));
let mut addressTo: Value = self.safe_string_n(transaction.clone(), Value::from(vec![Value::Str("target_address".into()), Value::Str("targetAddress".into()), Value::Str("addressTo".into())]), &[]);
let mut addressFrom: Value = self.safe_string2(transaction.clone(), Value::Str("source_address".into()), Value::Str("sourceAddress".into()), &[]);
let mut timestamp: Value = self.safe_timestamp_n(transaction.clone(), Value::from(vec![Value::Str("created_time".into()), Value::Str("createdTime".into())]), &[self.safe_integer_k(transaction.clone(), "timestamp", &[])]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), self.safe_string_n(transaction.clone(), Value::from(vec![Value::Str("id".into()), Value::Str("withdraw_id".into()), Value::Str("withdrawId".into())]), &[]));
m.insert("txid".to_string(), self.safe_string2(transaction.clone(), Value::Str("tx_id".into()), Value::Str("txId".into()), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("address".to_string(), Value::Null);
m.insert("addressFrom".to_string(), addressFrom);
m.insert("addressTo".to_string(), addressTo);
m.insert("tag".to_string(), self.safe_string2(transaction.clone(), Value::Str("extra".into()), Value::Str("tag".into()), &[]));
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("type".to_string(), movementDirection);
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), self.parse_transaction_status(self.safe_string_k(transaction.clone(), "status", &[])).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("updated".to_string(), self.safe_timestamp2(transaction.clone(), Value::Str("updated_time".into()), Value::Str("updatedTime".into()), &[]));
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), fee);
m.insert("network".to_string(), self.network_id_to_code(&[self.safe_string_k(transaction, "network", &[]), code]));
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("NEW".to_string(), Value::Str("pending".into()));
m.insert("CONFIRMING".to_string(), Value::Str("pending".into()));
m.insert("PROCESSING".to_string(), Value::Str("pending".into()));
m.insert("COMPLETED".to_string(), Value::Str("ok".into()));
m.insert("CANCELED".to_string(), Value::Str("canceled".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
/*
* @method
* @name woo#transfer
* @description transfer currency internally between wallets on the same account
* @see https://developer.woox.io/api-reference/endpoint/assets/transfer
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from
* @param {string} toAccount account to transfer to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn transfer(&mut self, mut code: Value, mut amount: Value, mut fromAccount: Value, mut toAccount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("token".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), self.parse_to_numeric(amount.clone()));
m.insert("from".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("applicationId".to_string(), fromAccount.clone());
m
}));
m.insert("to".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("applicationId".to_string(), toAccount.clone());
m
}));
m
});
let __ws_arg_26 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_post_asset_transfer(&[__ws_arg_26]).await;
//
// {
// "success": true,
// "id": 200
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(&mut data, &Value::Str("timestamp".into()), self.safe_integer_k(response, "timestamp", &[]));
if let Value::Dict(__d) = &mut data { std::sync::Arc::make_mut(__d).insert("token".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut data { std::sync::Arc::make_mut(__d).insert("status".into(), Value::Str("ok".into())); }
let mut transfer: Value = self.parse_transfer(data, &[currency]);
let mut transferOptions: Value = self.safe_dict_k(self.options.clone(), "transfer", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fillResponseFromRequest: Value = self.safe_bool_k(transferOptions, "fillResponseFromRequest", &[Value::Bool(true)]);
if (fillResponseFromRequest.as_bool() == Some(true)) {
add_element_to_object(&mut transfer, &Value::Str("amount".into()), amount);
add_element_to_object(&mut transfer, &Value::Str("fromAccount".into()), fromAccount);
add_element_to_object(&mut transfer, &Value::Str("toAccount".into()), toAccount);
}
return transfer;
Value::Null
}
/*
* @method
* @name woo#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://developer.woox.io/api-reference/endpoint/assets/get_transfer_history
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfers structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch entries for
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn fetch_transfers(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), limit.clone()); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]); // unified in milliseconds
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), until); }
}
let __ws_arg_27 = self.extend(request, &[paramsOmitted.clone()]);
let mut response: Value = self.v3_private_get_asset_transfer_history(&[__ws_arg_27]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "id": 225,
// "token": "USDT",
// "amount": "1000000",
// "status": "COMPLETED",
// "from": {
// "applicationId": "046b5c5c-5b44-4d27-9593-ddc32c0a08ae",
// "accountName": "Main"
// },
// "to": {
// "applicationId": "082ae5ae-e26a-4fb1-be5b-03e5b4867663",
// "accountName": "sub001"
// },
// "createdTime": "1642660941.534",
// "updatedTime": "1642660941.950"
// }
// ],
// "meta": {
// "total": 46,
// "recordsPerPage": 1,
// "currentPage": 1
// }
// },
// "timestamp": 1721295317627
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
return self.parse_transfers(rows, &[currency, since, limit, paramsOmitted]);
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchTransfers
// {
// "id": 46704,
// "token": "USDT",
// "amount": 30000.00000000,
// "status": "COMPLETED",
// "from_application_id": "0f1bd3cd-dba2-4563-b8bb-0adb1bfb83a3",
// "to_application_id": "c01e6940-a735-4022-9b6c-9d3971cdfdfa",
// "from_user": "LeverageLow",
// "to_user": "dev",
// "created_time": "1709022325.427",
// "updated_time": "1709022325.542"
// }
// {
// "id": 225,
// "token": "USDT",
// "amount": "1000000",
// "status": "COMPLETED",
// "from": {
// "applicationId": "046b5c5c-5b44-4d27-9593-ddc32c0a08ae",
// "accountName": "Main"
// },
// "to": {
// "applicationId": "082ae5ae-e26a-4fb1-be5b-03e5b4867663",
// "accountName": "sub001"
// },
// "createdTime": "1642660941.534",
// "updatedTime": "1642660941.950"
// }
//
// transfer
// {
// "success": true,
// "id": 200
// }
//
let mut code: Value = self.safe_currency_code(self.safe_string_k(transfer.clone(), "token", &[]), &[currency]);
let mut timestamp: Value = self.safe_timestamp2(transfer.clone(), Value::Str("createdTime".into()), Value::Str("timestamp".into()), &[]);
let mut success: Value = self.safe_bool_k(transfer.clone(), "success", &[]);
let mut status: Value = Value::Null;
if (success != Value::Null) {
status = (if success.as_bool() == Some(true) { Value::Str("ok".into()) } else { Value::Str("failed".into()) });
}
let mut fromAccount: Value = self.safe_dict_k(transfer.clone(), "from", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut toAccount: Value = self.safe_dict_k(transfer.clone(), "to", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(transfer.clone(), "id", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("currency".to_string(), code);
m.insert("amount".to_string(), self.safe_number_k(transfer.clone(), "amount", &[]));
m.insert("fromAccount".to_string(), self.safe_string_k(fromAccount, "applicationId", &[]));
m.insert("toAccount".to_string(), self.safe_string_k(toAccount, "applicationId", &[]));
m.insert("status".to_string(), self.parse_transaction_status(self.safe_string_k(transfer.clone(), "status", &[status])).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("info".to_string(), transfer);
m
});
Value::Null
}
/*
* @method
* @name woo#withdraw
* @description make a withdrawal
* @see https://developer.woox.io/api-reference/endpoint/assets/wallet_withdraw
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tag] memo / destination tag, required for currencies in options['withdrawTagRequiredCurrencies']
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut tagWithdrawTagparamsWithdrawTagVariable = self.handle_param_string(params, Value::Str("tag".into()), &[]);
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.check_address(&[address.clone(), code.clone(), tagWithdrawTag.clone()]);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amount.clone());
m.insert("address".to_string(), address.clone());
m
});
if (tagWithdrawTag != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("extra".into(), tagWithdrawTag.clone()); }
}
let mut network: Value = self.safe_string_k(paramsWithdrawTag.clone(), "network", &[]);
if (network == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" withdraw() requires a network parameter for ".into())).into()), code)));
}
let mut paramsOmitted: Value = self.omit(paramsWithdrawTag, Value::Str("network".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("token".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("network".into(), self.network_code_to_id(network.clone(), &[self.safe_string_k(currency.clone(), "code", &[])])); }
let __ws_arg_28 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.v3_private_post_asset_wallet_withdraw(&[__ws_arg_28]).await;
//
// {
// "success": true,
// "withdraw_id": "20200119145703654"
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let __ws_arg_29 = self.safe_string_k(data.clone(), "withdrawId", &[]);
let __ws_arg_30 = self.safe_integer_k(response, "timestamp", &[]);
let __ws_arg_31 = self.safe_string(self.networkAliases.clone(), network.clone(), &[network.clone()]);
let mut transactionData: Value = self.extend(data, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), __ws_arg_29);
m.insert("timestamp".to_string(), __ws_arg_30);
m.insert("currency".to_string(), code);
m.insert("amount".to_string(), amount);
m.insert("addressTo".to_string(), address);
m.insert("tag".to_string(), tagWithdrawTag);
m.insert("network".to_string(), __ws_arg_31);
m.insert("type".to_string(), Value::Str("withdrawal".into()));
m.insert("status".to_string(), Value::Str("pending".into()));
m
})]);
return self.parse_transaction(transactionData, &[currency]);
Value::Null
}
/*
* @method
* @name woo#repayMargin
* @description repay borrowed margin and interest
* @see https://docs.woox.io/#repay-interest
* @param {string} code unified currency code of the currency to repay
* @param {float} amount the amount to repay
* @param {string} symbol not used by woo.repayMargin ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbolResolved: Value = (if (symbol != Value::Null) { self.market(symbol).as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) } else { Value::Null });
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("token".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), self.currency_to_precision(code, amount.clone(), &[]));
m
});
let __ws_arg_32 = self.extend(request, &[params]);
let mut response: Value = self.v1_private_post_interest_repay(&[__ws_arg_32]).await;
//
// {
// "success": true,
// }
//
let mut transaction: Value = self.parse_margin_loan(response, &[currency]);
return self.extend(transaction, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amount);
m.insert("symbol".to_string(), symbolResolved);
m
})]);
Value::Null
}
pub fn parse_margin_loan(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Null);
m.insert("currency".to_string(), self.safe_currency_code(Value::Null, &[currency]));
m.insert("amount".to_string(), Value::Null);
m.insert("symbol".to_string(), Value::Null);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("info".to_string(), info);
m
});
Value::Null
}
pub fn nonce(&self) -> Value {
return (match (&(self.milliseconds()), &(self.safe_integer_k(self.options.clone(), "timeDifference", &[Value::Int(0)]))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (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::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut section = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut requestHeaders: Value = Value::Null;
let mut requestBody: Value = Value::Null;
let mut version: Value = self.safe_string(section.clone(), Value::Int(0), &[]);
let mut access: Value = self.safe_string(section, Value::Int(1), &[]);
let mut pathWithParams: Value = self.implode_params(path.clone(), params.clone());
let mut baseApiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), access.clone(), &[]);
if (baseApiUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = self.implode_hostname(baseApiUrl);
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("/".into()), version).into()), Value::Str("/".into())).into())).into());
let mut paramsSorted: Value = self.keysort(self.omit(params, self.extract_params(path.clone()), &[]), &[]);
if (access.as_str() == Some("public")) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("public/".into()), pathWithParams).into())).into());
if ((object_keys(¶msSorted).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(paramsSorted.clone(), &[])).into())).into());
}
} else if (access.as_str() == Some("pub")) {
url = Value::Str(format!("{}{}", url, pathWithParams).into());
if ((object_keys(¶msSorted).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(paramsSorted.clone(), &[])).into())).into());
}
} else {
self.check_required_credentials(&[]);
if (method.as_str() == Some("POST")) && ((path.as_str() == Some("trade/algoOrder")) || (path.as_str() == Some("trade/order"))) {
let mut isSandboxMode: Value = self.safe_bool_k(self.options.clone(), "sandboxMode", &[Value::Bool(false)]);
if (isSandboxMode.as_bool() != Some(true)) {
let mut applicationId: Value = Value::Str("bc830de7-50f3-460b-9ee0-f430f83f9dad".into());
let mut brokerId: Value = self.safe_string_k(self.options.clone(), "brokerId", &[applicationId]);
let mut isTrigger: bool = Value::Int(path.as_str().and_then(|__s| __s.find("algo")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64);
if isTrigger {
add_element_to_object(&mut paramsSorted, &Value::Str("brokerId".into()), brokerId.clone());
} else {
add_element_to_object(&mut paramsSorted, &Value::Str("broker_id".into()), brokerId);
}
}
}
let mut paramsSigned: Value = self.keysort(paramsSorted, &[]);
let mut auth: Value = Value::Str("".into());
let mut ts: Value = to_string_val(&self.nonce());
url = Value::Str(format!("{}{}", url, pathWithParams).into());
requestHeaders = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("x-api-key".to_string(), self.apiKey.clone());
m.insert("x-api-timestamp".to_string(), ts.clone());
m
});
if (version.as_str() == Some("v3")) {
auth = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", ts, method).into()), Value::Str("/".into())).into()), version).into()), Value::Str("/".into())).into()), pathWithParams).into());
if (method.as_str() == Some("POST")) || (method.as_str() == Some("PUT")) {
requestBody = json_stringify(¶msSigned);
auth = Value::Str(format!("{}{}", auth, requestBody).into());
add_element_to_object(&mut requestHeaders, &Value::Str("content-type".into()), Value::Str("application/json".into()));
} else {
if ((object_keys(¶msSigned).len() as i64) as f64) > ((0i64) as f64) {
let mut query: Value = self.urlencode(paramsSigned.clone(), &[]);
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), query).into())).into());
auth = Value::Str(format!("{}{}", auth, Value::Str(format!("{}{}", Value::Str("?".into()), query).into())).into());
}
}
} else {
auth = self.urlencode(paramsSigned.clone(), &[]);
if (method.as_str() == Some("POST")) || (method.as_str() == Some("PUT")) || (method.as_str() == Some("DELETE")) {
requestBody = auth.clone();
} else {
if ((object_keys(¶msSigned).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), auth).into())).into());
}
}
auth = Value::Str(format!("{}{}", auth, Value::Str(format!("{}{}", Value::Str("|".into()), ts).into())).into());
add_element_to_object(&mut requestHeaders, &Value::Str("content-type".into()), Value::Str("application/x-www-form-urlencoded".into()));
}
add_element_to_object(&mut requestHeaders, &Value::Str("x-api-signature".into()), self.hmac(self.encode(auth), self.encode(self.secret.clone()), Value::Str("sha256".into()), &[]));
}
let mut headersResult: Value = requestHeaders;
let mut bodyResult: Value = requestBody;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), bodyResult);
m.insert("headers".to_string(), headersResult);
m
});
Value::Null
}
pub fn handle_errors(&self, mut httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if (response == Value::Null) {
return Value::Null;
}
//
// 400 Bad Request {"success":false,"code":-1012,"message":"Amount is required for buy market orders when margin disabled."}
// {"code":"-1011","message":"The system is under maintenance.","success":false}
//
let mut success: Value = self.safe_bool_k(response.clone(), "success", &[]);
let mut errorCode: Value = self.safe_string_k(response.clone(), "code", &[]);
if (success.as_bool() != Some(true)) {
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), json_stringify(&response)).into());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), body, feedback.clone());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), errorCode, feedback);
}
return Value::Null;
Value::Null
}
pub fn parse_income(&self, mut income: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "id": 1286360,
// "symbol": "PERP_BTC_USDT",
// "fundingRate": -0.00001445,
// "markPrice": "26930.60000000",
// "fundingFee": "9.56021744",
// "fundingIntervalHours": 8,
// "paymentType": "Pay",
// "status": "COMPLETED",
// "createdTime": 1696060873259,
// "updatedTime": 1696060873286
// }
//
let mut marketId: Value = self.safe_string_k(income.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market]);
let mut amount: Value = self.safe_string_k(income.clone(), "fundingFee", &[]);
let mut code: Value = self.safe_currency_code(Value::Str("USD".into()), &[]);
let mut id: Value = self.safe_string_k(income.clone(), "id", &[]);
let mut timestamp: Value = self.safe_integer_k(income.clone(), "updatedTime", &[]);
let mut rate: Value = self.safe_number_k(income.clone(), "fundingRate", &[]);
let mut paymentType: Option<String> = self.safe_string_k(income.clone(), "paymentType", &[]).as_str().map(str::to_owned);
amount = (if (paymentType.as_deref() == Some("Pay")) { crate::precise::Precise::stringNeg(&amount) } else { amount.clone() });
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), income);
m.insert("symbol".to_string(), symbol);
m.insert("code".to_string(), code);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("id".to_string(), id);
m.insert("amount".to_string(), self.parse_number(amount, &[]));
m.insert("rate".to_string(), rate);
m
});
Value::Null
}
/*
* @method
* @name woo#fetchFundingHistory
* @description fetch the history of funding payments paid and received on this account
* @see https://developer.woox.io/api-reference/endpoint/futures/get_fundingFee_history
* @param {string} [symbol] unified market symbol
* @param {int} [since] the earliest time in ms to fetch funding history for
* @param {int} [limit] the maximum number of funding history structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/?id=funding-history-structure}
*/
pub async fn fetch_funding_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(params, Value::Str("fetchFundingHistory".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchFundingHistory".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("page".into()), Value::Int(500)]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let mut until: Value = self.safe_integer_k(paramsPaginate.clone(), "until", &[]); // unified in milliseconds
let mut paramsOmitted: Value = self.omit(paramsPaginate, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), until); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), crate::runtime::Math::min(&limit, &Value::Int(500))); }
}
let __ws_arg_33 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.v3_private_get_futures_funding_fee_history(&[__ws_arg_33]).await;
//
// {
// "success": true,
// "data": {
// "meta": {
// "total": 670,
// "recordsPerPage": 25,
// "currentPage": 1
// },
// "rows": [
// {
// "id": 1286360,
// "symbol": "PERP_BTC_USDT",
// "fundingRate": -0.00001445,
// "markPrice": "26930.60000000",
// "fundingFee": "9.56021744",
// "fundingIntervalHours": 8,
// "paymentType": "Pay",
// "status": "COMPLETED",
// "createdTime": 1696060873259,
// "updatedTime": 1696060873286
// }
// ]
// },
// "timestamp": 1721351502594
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
return self.parse_incomes(rows, &[market, since, limit]);
Value::Null
}
pub fn parse_funding_rate(&self, mut fundingRate: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "PERP_BTC_USDT",
// "estFundingRate": "-0.00000441",
// "estFundingRateTimestamp": 1751623979022,
// "lastFundingRate": "-0.00004953",
// "lastFundingRateTimestamp": 1751616000000,
// "nextFundingTime": 1751644800000,
// "lastFundingIntervalHours": 8,
// "estFundingIntervalHours": 8
// }
//
// watchFundingRate
//
// {
// "symbol": "PERP_BTC_USDT",
// "fundingRate": 0.0001,
// "fundingTs": 1771488000000
// }
//
let mut symbol: Value = self.safe_string_k(fundingRate.clone(), "symbol", &[]);
let mut marketResolved: Value = self.market(symbol);
let mut nextFundingTimestamp: Value = self.safe_integer2(fundingRate.clone(), Value::Str("nextFundingTime".into()), Value::Str("fundingTs".into()), &[]);
let mut estFundingRateTimestamp: Value = self.safe_integer_k(fundingRate.clone(), "estFundingRateTimestamp", &[]);
let mut lastFundingRateTimestamp: Value = self.safe_integer_k(fundingRate.clone(), "lastFundingRateTimestamp", &[]);
let mut intervalString: Value = self.safe_string_k(fundingRate.clone(), "estFundingIntervalHours", &[]);
let mut interval: Value = Value::Null;
if (intervalString != Value::Null) {
interval = Value::Str(format!("{}{}", intervalString, Value::Str("h".into())).into());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fundingRate.clone());
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("markPrice".to_string(), Value::Null);
m.insert("indexPrice".to_string(), Value::Null);
m.insert("interestRate".to_string(), self.parse_number(Value::Str("0".into()), &[]));
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), estFundingRateTimestamp.clone());
m.insert("datetime".to_string(), self.iso8601(estFundingRateTimestamp));
m.insert("fundingRate".to_string(), self.safe_number2(fundingRate.clone(), Value::Str("estFundingRate".into()), Value::Str("fundingRate".into()), &[]));
m.insert("fundingTimestamp".to_string(), nextFundingTimestamp.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(nextFundingTimestamp));
m.insert("nextFundingRate".to_string(), Value::Null);
m.insert("nextFundingTimestamp".to_string(), Value::Null);
m.insert("nextFundingDatetime".to_string(), Value::Null);
m.insert("previousFundingRate".to_string(), self.safe_number_k(fundingRate, "lastFundingRate", &[]));
m.insert("previousFundingTimestamp".to_string(), lastFundingRateTimestamp.clone());
m.insert("previousFundingDatetime".to_string(), self.iso8601(lastFundingRateTimestamp));
m.insert("interval".to_string(), interval);
m
});
Value::Null
}
/*
* @method
* @name woo#fetchFundingInterval
* @description fetch the current funding rate interval
* @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.fetch_funding_rate(symbol, &[params]).await;
Value::Null
}
/*
* @method
* @name woo#fetchFundingRate
* @description fetch the current funding rate
* @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_34 = self.extend(request, &[params]);
let mut response: Value = self.v3_public_get_funding_rate(&[__ws_arg_34]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "PERP_BTC_USDT",
// "estFundingRate": "-0.00000441",
// "estFundingRateTimestamp": 1751623979022,
// "lastFundingRate": "-0.00004953",
// "lastFundingRateTimestamp": 1751616000000,
// "nextFundingTime": 1751644800000,
// "lastFundingIntervalHours": 8,
// "estFundingIntervalHours": 8
// }
// ]
// },
// "timestamp": 1751624037798
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(rows, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_funding_rate(first, &[market]);
Value::Null
}
/*
* @method
* @name woo#fetchFundingRates
* @description fetch the funding rate for multiple markets
* @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rates-structure}, indexed by market symbols
*/
pub async fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
let mut response: Value = self.v3_public_get_funding_rate(&[params]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "PERP_BTC_USDT",
// "estFundingRate": "-0.00000441",
// "estFundingRateTimestamp": 1751623979022,
// "lastFundingRate": "-0.00004953",
// "lastFundingRateTimestamp": 1751616000000,
// "nextFundingTime": 1751644800000,
// "lastFundingIntervalHours": 8,
// "estFundingIntervalHours": 8
// }
// ]
// },
// "timestamp": 1751624037798
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
return self.parse_funding_rates(rows, &[symbolsNormalized]);
Value::Null
}
/*
* @method
* @name woo#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRateHistory
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest funding rate
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure}
*/
pub async fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(params, Value::Str("fetchFundingRateHistory".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchFundingRateHistory".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("page".into()), Value::Int(25)]).await;
}
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() requires a symbol argument".into()))));
}
let mut market: Value = self.market(symbol);
let mut symbolValue: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let mut requestUntilparamsUntilVariable = self.handle_until_option(Value::Str("endTime".into()), request, paramsPaginate, &[]);
let mut requestUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let __ws_arg_35 = self.extend(requestUntil, &[paramsUntil]);
let mut response: Value = self.v3_public_get_funding_rate_history(&[__ws_arg_35]).await;
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "PERP_BTC_USDT",
// "fundingRate": "-0.00004953",
// "fundingRateTimestamp": 1751616000000,
// "nextFundingTime": 1751644800000,
// "markPrice": "108708"
// }
// ],
// "meta": {
// "total": 11690,
// "recordsPerPage": 25,
// "currentPage": 1
// }
// },
// "timestamp": 1751632390031
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "rows", &[Value::from(vec![])]);
let mut rates: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1145: bool = true;
while { if !__for_first_1145 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1145 = false; i.as_f64().unwrap_or(f64::NAN) < ((rows.len() as i64) as f64) } {
let mut entry: Value = rows.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer_k(entry.clone(), "fundingRateTimestamp", &[]);
append_to_array(&mut rates, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[]));
m.insert("fundingRate".to_string(), self.safe_number_k(entry, "fundingRate", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
}));
}
}
let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
return self.filter_by_symbol_since_limit(sorted, &[symbolValue, since, limit]);
Value::Null
}
/*
* @method
* @name woo#setPositionMode
* @description set hedged to true or false for a market
* @see https://developer.woox.io/api-reference/endpoint/futures/position_mode
* @param {bool} hedged set to true to use HEDGE_MODE, false for ONE_WAY
* @param {string} symbol not used by woo setPositionMode
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
pub async fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut hedgeMode: Value = Value::Null;
if is_true(&hedged) {
hedgeMode = Value::Str("HEDGE_MODE".into());
} else {
hedgeMode = Value::Str("ONE_WAY".into());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("positionMode".to_string(), hedgeMode);
m
});
let __ws_arg_36 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_put_futures_position_mode(&[__ws_arg_36]).await;
return response;
Value::Null
}
/*
* @method
* @name woo#fetchLeverage
* @description fetch the set leverage for a market
* @see https://developer.woox.io/api-reference/endpoint/account/get_account_info
* @see https://developer.woox.io/api-reference/endpoint/futures/get_leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated'
* @param {string} [params.positionMode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE'
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/?id=leverage-structure}
*/
pub async fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut response: Value = Value::Null;
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
response = self.v3_private_get_account_info(&[params.clone()]).await;
} else if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut marginModeparamsMarginModeVariable = self.handle_margin_mode_and_params(Value::Str("fetchLeverage".into()), &[params, Value::Str("cross".into())]);
let mut marginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginMode".into(), self.encode_margin_mode(marginMode).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
let __ws_arg_37 = self.extend(request, &[paramsMarginMode]);
response = self.v3_private_get_futures_leverage(&[__ws_arg_37]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverage() is not supported for ".into())).into()), market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" markets".into()))));
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_leverage(data, &[market]);
Value::Null
}
pub fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(leverage.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market]);
let mut marginMode: Value = self.safe_string_lower_k(leverage.clone(), "marginMode", &[]);
let mut spotLeverage: Value = self.safe_integer_k(leverage.clone(), "leverage", &[]);
if (spotLeverage.as_f64() == Some(0.0)) {
spotLeverage = Value::Null;
}
let mut longLeverage: Value = spotLeverage.clone();
let mut shortLeverage: Value = spotLeverage;
let mut details: Value = self.safe_list_k(leverage.clone(), "details", &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1146: bool = true;
while { if !__for_first_1146 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1146 = false; i.as_f64().unwrap_or(f64::NAN) < ((details.len() as i64) as f64) } {
let mut position: Value = self.safe_dict(details.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut positionLeverage: Value = self.safe_integer_k(position.clone(), "leverage", &[]);
let mut side: Option<String> = self.safe_string_k(position, "positionSide", &[]).as_str().map(str::to_owned);
if (side.as_deref() == Some("BOTH")) {
longLeverage = positionLeverage.clone();
shortLeverage = positionLeverage.clone();
} else if (side.as_deref() == Some("LONG")) {
longLeverage = positionLeverage.clone();
} else if (side.as_deref() == Some("SHORT")) {
shortLeverage = positionLeverage;
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), leverage);
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("marginMode".to_string(), marginMode);
m.insert("longLeverage".to_string(), longLeverage);
m.insert("shortLeverage".to_string(), shortLeverage);
m
});
Value::Null
}
/*
* @method
* @name woo#setLeverage
* @description set the level of leverage for a market
* @see https://developer.woox.io/api-reference/endpoint/spot_margin/set_leverage
* @see https://developer.woox.io/api-reference/endpoint/futures/set_leverage
* @param {float} leverage the rate of leverage (1, 2, 3, 4 or 5 for spot markets, 1, 2, 3, 4, 5, 10, 15, 20 for swap markets)
* @param {string} [symbol] unified market symbol (is mandatory for swap markets)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated'
* @param {string} [params.positionMode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE'
* @returns {object} response from the exchange
*/
pub async fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), leverage);
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol.clone());
}
if (symbol == Value::Null) || matches!((self.safe_bool_k(market.clone(), "spot", &[Value::Bool(false)])), Value::Bool(true)) {
let __ws_arg_38 = self.extend(request.clone(), &[params.clone()]);
return self.v3_private_post_spot_margin_leverage(&[__ws_arg_38]).await;
} else if matches!(self.safe_bool_k(market.clone(), "swap", &[Value::Bool(false)]), Value::Bool(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.safe_string_k(market.clone(), "id", &[])); }
let mut marginModeparamsMarginModeVariable = self.handle_margin_mode_and_params(Value::Str("setLeverage".into()), &[params, Value::Str("cross".into())]);
let mut marginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginMode".into(), self.encode_margin_mode(marginMode).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
let __ws_arg_39 = self.extend(request, &[paramsMarginMode]);
return self.v3_private_put_futures_leverage(&[__ws_arg_39]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverage() is not supported for ".into())).into()), self.safe_string_k(market, "type", &[])).into()), Value::Str(" markets".into()))));
}
Value::Null
}
/*
* @method
* @name woo#addMargin
* @description add margin
* @see https://docs.woox.io/#update-isolated-margin-setting
* @param {string} symbol unified market symbol
* @param {float} amount amount of margin to add
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.position_side] 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.modify_margin_helper(symbol, amount, Value::Str("ADD".into()), &[params]).await;
Value::Null
}
/*
* @method
* @name woo#reduceMargin
* @description remove margin from a position
* @see https://docs.woox.io/#update-isolated-margin-setting
* @param {string} symbol unified market symbol
* @param {float} amount amount of margin to remove
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.position_side] 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.modify_margin_helper(symbol, amount, Value::Str("REDUCE".into()), &[params]).await;
Value::Null
}
pub async fn modify_margin_helper(&mut self, mut symbol: Value, mut amount: Value, mut type_var: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("adjust_token".to_string(), Value::Str("USDT".into()));
m.insert("adjust_amount".to_string(), amount);
m.insert("action".to_string(), type_var);
m
});
let __ws_arg_40 = self.extend(request, &[params]);
return self.v1_private_post_client_isolated_margin(&[__ws_arg_40]).await;
Value::Null
}
/*
* @method
* @name woo#fetchPosition
* @description fetch data on an open position
* @see https://developer.woox.io/api-reference/endpoint/futures/get_positions
* @param {string} symbol unified market symbol of the market the position is held in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_41 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_get_futures_positions(&[__ws_arg_41]).await;
//
// {
// "success": true,
// "data": {
// "positions": [
// {
// "symbol": "PERP_LTC_USDT",
// "holding": "0.1",
// "pendingLongQty": "0",
// "pendingShortQty": "0",
// "settlePrice": "96.87",
// "averageOpenPrice": "96.87",
// "pnl24H": "0",
// "fee24H": "0.0048435",
// "markPrice": "96.83793449",
// "estLiqPrice": "0",
// "timestamp": 1752500555823,
// "adlQuantile": 2,
// "positionSide": "BOTH",
// "marginMode": "CROSS",
// "isolatedMarginToken": "",
// "isolatedMarginAmount": "0",
// "isolatedFrozenLong": "0",
// "isolatedFrozenShort": "0",
// "leverage": 10
// }
// ]
// },
// "timestamp": 1752500579848
// }
//
let mut result: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut positions: Value = self.safe_list_k(result, "positions", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(positions, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_position(first, &[market]);
Value::Null
}
/*
* @method
* @name woo#fetchPositions
* @description fetch all open positions
* @see https://developer.woox.io/api-reference/endpoint/futures/get_positions
* @param {string[]} [symbols] list of unified market symbols, the exchange filters server-side when exactly one symbol is provided
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (symbolsNormalized != Value::Null) {
let mut symbolsLength: f64 = ((symbolsNormalized.len() as i64) as f64);
if (symbolsLength == 1.0) {
let mut market: Value = self.market(symbolsNormalized.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
}
let __ws_arg_42 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_get_futures_positions(&[__ws_arg_42]).await;
//
// {
// "success": true,
// "data": {
// "positions": [
// {
// "symbol": "PERP_LTC_USDT",
// "holding": "0.1",
// "pendingLongQty": "0",
// "pendingShortQty": "0",
// "settlePrice": "96.87",
// "averageOpenPrice": "96.87",
// "pnl24H": "0",
// "fee24H": "0.0048435",
// "markPrice": "96.83793449",
// "estLiqPrice": "0",
// "timestamp": 1752500555823,
// "adlQuantile": 2,
// "positionSide": "BOTH",
// "marginMode": "CROSS",
// "isolatedMarginToken": "",
// "isolatedMarginAmount": "0",
// "isolatedFrozenLong": "0",
// "isolatedFrozenShort": "0",
// "leverage": 10
// }
// ]
// },
// "timestamp": 1752500579848
// }
//
let mut result: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut positions: Value = self.safe_list_k(result, "positions", &[Value::from(vec![])]);
return self.parse_positions(positions, &[symbolsNormalized]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// v1PrivateGetPositionSymbol
// {
// "symbol": "PERP_ETH_USDT",
// "position_side": "BOTH",
// "leverage": 10,
// "margin_mode": "CROSS",
// "average_open_price": 3139.9,
// "isolated_margin_amount": 0.0,
// "isolated_margin_token": "",
// "opening_time": "1720627963.094",
// "mark_price": 3155.19169891,
// "pending_short_qty": 0.0,
// "pending_long_qty": 0.0,
// "holding": -0.7,
// "pnl_24_h": 0.0,
// "est_liq_price": 9107.40055552,
// "settle_price": 3151.0319904,
// "success": true,
// "fee_24_h": 0.0,
// "isolated_frozen_long": 0.0,
// "isolated_frozen_short": 0.0,
// "timestamp": "1720867502.544"
// }
//
// v3PrivateGetPositions
// {
// "symbol": "PERP_LTC_USDT",
// "holding": "0.1",
// "pendingLongQty": "0",
// "pendingShortQty": "0",
// "settlePrice": "96.87",
// "averageOpenPrice": "96.87",
// "pnl24H": "0",
// "fee24H": "0.0048435",
// "markPrice": "96.83793449",
// "estLiqPrice": "0",
// "timestamp": 1752500555823,
// "adlQuantile": 2,
// "positionSide": "BOTH",
// "marginMode": "CROSS",
// "isolatedMarginToken": "",
// "isolatedMarginAmount": "0",
// "isolatedFrozenLong": "0",
// "isolatedFrozenShort": "0",
// "leverage": 10
// }
//
let mut contract: Value = self.safe_string_k(position.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[contract, market]);
let mut size: Value = self.safe_string_k(position.clone(), "holding", &[]);
let mut side: Value = Value::Null;
if is_true(&crate::precise::Precise::stringGt(&size, &Value::Str("0".into()))) {
side = Value::Str("long".into());
} else {
side = Value::Str("short".into());
}
let mut contractSize: Value = self.safe_string_k(marketResolved.clone(), "contractSize", &[]);
let mut markPrice: Value = self.safe_string2(position.clone(), Value::Str("markPrice".into()), Value::Str("mark_price".into()), &[]);
let mut timestampString: Value = self.safe_string_k(position.clone(), "timestamp", &[]);
let mut timestamp: Value = Value::Null;
if (timestampString != Value::Null) {
if Value::Int(timestampString.as_str().and_then(|__s| __s.find(".")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64) {
timestamp = self.safe_timestamp_k(position.clone(), "timestamp", &[]);
} else {
timestamp = self.safe_integer_k(position.clone(), "timestamp", &[]);
}
}
let mut entryPrice: Value = self.safe_string2(position.clone(), Value::Str("averageOpenPrice".into()), Value::Str("average_open_price".into()), &[]);
let mut priceDifference: Value = crate::precise::Precise::stringSub(&markPrice, &entryPrice);
let mut unrealisedPnl: Value = crate::precise::Precise::stringMul(&priceDifference, &size);
size = crate::precise::Precise::stringAbs(&size);
let mut notional: Value = crate::precise::Precise::stringMul(&size, &markPrice);
let mut positionSide: Option<String> = self.safe_string_k(position.clone(), "positionSide", &[]).as_str().map(str::to_owned); // 'SHORT' or 'LONG' for hedged, 'BOTH' for non-hedged
let mut marginMode: Value = self.safe_string_lower2(position.clone(), Value::Str("marginMode".into()), Value::Str("margin_mode".into()), &[]);
let mut positionMargin: Value = Value::Null;
if (marginMode.as_str() == Some("isolated")) {
positionMargin = self.safe_number2(position.clone(), Value::Str("isolatedMarginAmount".into()), Value::Str("isolated_margin_amount".into()), &[]);
}
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), Value::Null);
m.insert("symbol".to_string(), self.safe_string_k(marketResolved, "symbol", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastUpdateTimestamp".to_string(), Value::Null);
m.insert("initialMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("entryPrice".to_string(), self.parse_number(entryPrice, &[]));
m.insert("notional".to_string(), self.parse_number(notional, &[]));
m.insert("leverage".to_string(), self.safe_number_k(position.clone(), "leverage", &[]));
m.insert("unrealizedPnl".to_string(), self.parse_number(unrealisedPnl, &[]));
m.insert("contracts".to_string(), self.parse_number(size, &[]));
m.insert("contractSize".to_string(), self.parse_number(contractSize, &[]));
m.insert("marginRatio".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), self.safe_number2(position, Value::Str("estLiqPrice".into()), Value::Str("est_liq_price".into()), &[]));
m.insert("markPrice".to_string(), self.parse_number(markPrice, &[]));
m.insert("lastPrice".to_string(), Value::Null);
m.insert("positionMargin".to_string(), positionMargin);
m.insert("collateral".to_string(), Value::Null);
m.insert("marginMode".to_string(), marginMode);
m.insert("side".to_string(), side);
m.insert("percentage".to_string(), Value::Null);
m.insert("hedged".to_string(), Value::Bool(positionSide.as_deref() != Some("BOTH")));
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name woo#fetchConvertQuote
* @description fetch a quote for converting from one currency to another
* @see https://docs.woox.io/#get-quote-rfq
* @param {string} fromCode the currency that you want to sell and convert from
* @param {string} toCode the currency that you want to buy and convert into
* @param {float} [amount] how much you want to trade in units of the from currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sellToken".to_string(), to_upper(&fromCode));
m.insert("buyToken".to_string(), to_upper(&toCode));
m.insert("sellQuantity".to_string(), self.number_to_string(amount));
m
});
let __ws_arg_43 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_get_convert_rfq(&[__ws_arg_43]).await;
//
// {
// "success": true,
// "data": {
// "quoteId": 123123123,
// "counterPartyId": "",
// "sellToken": "ETH",
// "sellQuantity": "0.0445",
// "buyToken": "USDT",
// "buyQuantity": "33.45",
// "buyPrice": "6.77",
// "expireTimestamp": 1659084466000,
// "message": 1659084466000
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromCurrencyId: Value = self.safe_string_k(data.clone(), "sellToken", &[fromCode]);
let mut fromCurrency: Value = self.currency(fromCurrencyId);
let mut toCurrencyId: Value = self.safe_string_k(data.clone(), "buyToken", &[toCode]);
let mut toCurrency: Value = self.currency(toCurrencyId);
return self.parse_conversion(data, &[fromCurrency, toCurrency]);
Value::Null
}
/*
* @method
* @name woo#createConvertTrade
* @description convert from one currency to another
* @see https://docs.woox.io/#send-quote-rft
* @param {string} id the id of the trade that you want to make
* @param {string} fromCode the currency that you want to sell and convert from
* @param {string} toCode the currency that you want to buy and convert into
* @param {float} [amount] how much you want to trade in units of the from currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn create_convert_trade(&mut self, mut id: Value, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quoteId".to_string(), id);
m
});
let __ws_arg_44 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_post_convert_rft(&[__ws_arg_44]).await;
//
// {
// "success": true,
// "data": {
// "quoteId": 123123123,
// "counterPartyId": "",
// "rftAccepted": 1 // 1 -> success; 2 -> processing; 3 -> fail
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_conversion(data, &[]);
Value::Null
}
/*
* @method
* @name woo#fetchConvertTrade
* @description fetch the data for a conversion trade
* @see https://docs.woox.io/#get-quote-trade
* @param {string} id the id of the trade that you want to fetch
* @param {string} [code] the unified currency code of the conversion trade
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quoteId".to_string(), id);
m
});
let __ws_arg_45 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_get_convert_trade(&[__ws_arg_45]).await;
//
// {
// "success": true,
// "data": {
// "quoteId": 12,
// "buyAsset": "",
// "sellAsset": "",
// "buyAmount": 12.11,
// "sellAmount": 12.11,
// "tradeStatus": 12,
// "createdTime": ""
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromCurrencyId: Value = self.safe_string_k(data.clone(), "sellAsset", &[]);
let mut toCurrencyId: Value = self.safe_string_k(data.clone(), "buyAsset", &[]);
let mut fromCurrency: Value = Value::Null;
let mut toCurrency: Value = Value::Null;
if (fromCurrencyId != Value::Null) {
fromCurrency = self.currency(fromCurrencyId);
}
if (toCurrencyId != Value::Null) {
toCurrency = self.currency(toCurrencyId);
}
return self.parse_conversion(data, &[fromCurrency, toCurrency]);
Value::Null
}
/*
* @method
* @name woo#fetchConvertTradeHistory
* @description fetch the users history of conversion trades
* @see https://docs.woox.io/#get-quote-trades
* @param {string} [code] the unified currency code
* @param {int} [since] the earliest time in ms to fetch conversions for
* @param {int} [limit] the maximum number of conversion structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest conversion to fetch
* @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut requestUntilparamsUntilVariable = self.handle_until_option(Value::Str("endTime".into()), request, params, &[]);
let mut requestUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (since != Value::Null) {
add_element_to_object(&mut requestUntil, &Value::Str("startTime".into()), since.clone());
}
if (limit != Value::Null) {
add_element_to_object(&mut requestUntil, &Value::Str("size".into()), limit.clone());
}
let __ws_arg_46 = self.extend(requestUntil, &[paramsUntil]);
let mut response: Value = self.v3_private_get_convert_trades(&[__ws_arg_46]).await;
//
// {
// "success": true,
// "data": {
// "count": 12,
// "tradeVos":[
// {
// "quoteId": 12,
// "buyAsset": "",
// "sellAsset": "",
// "buyAmount": 12.11,
// "sellAmount": 12.11,
// "tradeStatus": 12,
// "createdTime": ""
// }
// ...
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "tradeVos", &[Value::from(vec![])]);
return self.parse_conversions(rows, &[code, Value::Str("sellAsset".into()), Value::Str("buyAsset".into()), since, limit]);
Value::Null
}
pub fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
let mut toCurrency = get_arg(optional_args, 1, Value::Null);
//
// fetchConvertQuote
//
// {
// "quoteId": 123123123,
// "counterPartyId": "",
// "sellToken": "ETH",
// "sellQuantity": "0.0445",
// "buyToken": "USDT",
// "buyQuantity": "33.45",
// "buyPrice": "6.77",
// "expireTimestamp": 1659084466000,
// "message": 1659084466000
// }
//
// createConvertTrade
//
// {
// "quoteId": 123123123,
// "counterPartyId": "",
// "rftAccepted": 1 // 1 -> success; 2 -> processing; 3 -> fail
// }
//
// fetchConvertTrade, fetchConvertTradeHistory
//
// {
// "quoteId": 12,
// "buyAsset": "",
// "sellAsset": "",
// "buyAmount": 12.11,
// "sellAmount": 12.11,
// "tradeStatus": 12,
// "createdTime": ""
// }
//
let mut timestamp: Value = self.safe_integer2(conversion.clone(), Value::Str("expireTimestamp".into()), Value::Str("createdTime".into()), &[]);
let mut fromCurr: Value = self.safe_string2(conversion.clone(), Value::Str("sellToken".into()), Value::Str("buyAsset".into()), &[]);
let mut fromCode: Value = self.safe_currency_code(fromCurr, &[fromCurrency]);
let mut to: Value = self.safe_string2(conversion.clone(), Value::Str("buyToken".into()), Value::Str("sellAsset".into()), &[]);
let mut toCode: Value = self.safe_currency_code(to, &[toCurrency]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), conversion.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("id".to_string(), self.safe_string_k(conversion.clone(), "quoteId", &[]));
m.insert("fromCurrency".to_string(), fromCode);
m.insert("fromAmount".to_string(), self.safe_number2(conversion.clone(), Value::Str("sellQuantity".into()), Value::Str("sellAmount".into()), &[]));
m.insert("toCurrency".to_string(), toCode);
m.insert("toAmount".to_string(), self.safe_number2(conversion.clone(), Value::Str("buyQuantity".into()), Value::Str("buyAmount".into()), &[]));
m.insert("price".to_string(), self.safe_number_k(conversion, "buyPrice", &[]));
m.insert("fee".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name woo#fetchConvertCurrencies
* @description fetches all available currencies that can be converted
* @see https://docs.woox.io/#get-quote-asset-info
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v3_private_get_convert_asset_info(&[params]).await;
//
// {
// "success": true,
// "rows": [
// {
// "token": "BTC",
// "tick": 0.0001,
// "createdTime": "1575014248.99", // Unix epoch time in seconds
// "updatedTime": "1575014248.99" // Unix epoch time in seconds
// },
// ]
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut data: Value = self.safe_list_k(response, "rows", &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1147: bool = true;
while { if !__for_first_1147 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1147 = false; i.as_f64().unwrap_or(f64::NAN) < ((data.len() as i64) as f64) } {
let mut entry: Value = data.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut id: Value = self.safe_string_k(entry.clone(), "token", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("id".to_string(), id);
m.insert("code".to_string(), code.clone());
m.insert("networks".to_string(), Value::Null);
m.insert("type".to_string(), Value::Null);
m.insert("name".to_string(), Value::Null);
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), self.safe_number_k(entry.clone(), "tick", &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), self.safe_timestamp_k(entry, "createdTime", &[]));
m
})); }
}
}
}
return result;
Value::Null
}
/*
* @method
* @name woo#fetchPositionsADLRank
* @description fetches the auto deleveraging rank and risk percentage for a list of symbols
* @see https://developer.woox.io/api-reference/endpoint/futures/get_positions
* @param {string[]} [symbols] a list of unified market symbols, the exchange filters server-side when exactly one symbol is provided
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of [auto de leverage structures]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
*/
pub async fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols, Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (symbolsNormalized != Value::Null) {
let mut symbolsLength: f64 = ((symbolsNormalized.len() as i64) as f64);
if (symbolsLength == 1.0) {
let mut market: Value = self.market(symbolsNormalized.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
}
let __ws_arg_47 = self.extend(request, &[params]);
let mut response: Value = self.v3_private_get_futures_positions(&[__ws_arg_47]).await;
//
// {
// "success": true,
// "data": {
// "positions": [
// {
// "symbol": "PERP_BTC_USDT",
// "holding": "0.001",
// "pendingLongQty": "0",
// "pendingShortQty": "0",
// "settlePrice": "90732",
// "averageOpenPrice": "90732",
// "pnl24H": "-0.001",
// "fee24H": "0.1360115",
// "markPrice": "90736",
// "estLiqPrice": "0",
// "timestamp": 1768049379264,
// "adlQuantile": 3,
// "positionSide": "BOTH",
// "marginMode": "CROSS",
// "isolatedMarginToken": "",
// "isolatedMarginAmount": "0",
// "isolatedFrozenLong": "0",
// "isolatedFrozenShort": "0",
// "leverage": 10
// },
// ]
// },
// "timestamp": 1768049428472
// }
//
let mut result: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut positions: Value = self.safe_list_k(result, "positions", &[Value::from(vec![])]);
return self.parse_adl_ranks(positions, &[symbolsNormalized]);
Value::Null
}
pub fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchPositionsADLRank
//
// {
// "symbol": "PERP_BTC_USDT",
// "holding": "0.001",
// "pendingLongQty": "0",
// "pendingShortQty": "0",
// "settlePrice": "90732",
// "averageOpenPrice": "90732",
// "pnl24H": "-0.001",
// "fee24H": "0.1360115",
// "markPrice": "90736",
// "estLiqPrice": "0",
// "timestamp": 1768049379264,
// "adlQuantile": 3,
// "positionSide": "BOTH",
// "marginMode": "CROSS",
// "isolatedMarginToken": "",
// "isolatedMarginAmount": "0",
// "isolatedFrozenLong": "0",
// "isolatedFrozenShort": "0",
// "leverage": 10
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer_k(info.clone(), "timestamp", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market, Value::Null, Value::Str("contract".into())]));
m.insert("rank".to_string(), self.safe_number_k(info, "adlQuantile", &[]));
m.insert("rating".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
});
Value::Null
}
pub fn default_network_code_for_currency(&self, mut code: Value) -> Option<String> {
let mut currencyItem: Value = self.currency(code);
let mut networks: Value = currencyItem.as_map().and_then(|__m| __m.get("networks")).cloned().unwrap_or(Value::Null);
let mut networkKeys: Value = object_keys(&networks);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1148: bool = true;
while { if !__for_first_1148 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1148 = false; i.as_f64().unwrap_or(f64::NAN) < ((networkKeys.len() as i64) as f64) } {
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);
if (network.as_str() == Some("ERC20")) {
return network.as_str().map(str::to_owned);
}
}
}
return self.safe_string(networkKeys, Value::Int(0), &[]).as_str().map(str::to_owned);
}
pub fn set_sandbox_mode(&mut self, mut enable: Value) {
self.super_set_sandbox_mode(enable.clone());
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("sandboxMode".into(), enable); }
}
}