// 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 CryptomusCore {
pub exchange: crate::exchange::Exchange,
}
impl CryptomusCore {
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 = CryptomusCore::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 CryptomusCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CryptomusCore.
CryptomusCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CryptomusCore.
CryptomusCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CryptomusCore.
CryptomusCore::parse_order(self, order, &[market])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CryptomusCore.
CryptomusCore::parse_market(self, market)
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on CryptomusCore.
CryptomusCore::parse_balance(self, response)
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on CryptomusCore.
CryptomusCore::parse_currency(self, currency)
}
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 CryptomusCore.
CryptomusCore::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 CryptomusCore.
CryptomusCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for CryptomusCore {
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 {
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.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,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"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)),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_fee_tiers" => self.parse_fee_tiers(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_order" => self.parse_order(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_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for CryptomusCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for CryptomusCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl CryptomusCore {
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("cryptomus".into()));
m.insert("name".to_string(), Value::Str("Cryptomus".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("CA".into())]));
m.insert("rateLimit".to_string(), Value::Int(100));
m.insert("version".to_string(), Value::Str("v2".into()));
m.insert("certified".to_string(), Value::Bool(false));
m.insert("pro".to_string(), Value::Bool(false));
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(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(false));
m.insert("cancelAllOrdersAfter".to_string(), Value::Bool(false));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(false));
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(false));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketOrder".to_string(), Value::Bool(false));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(false));
m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Bool(false));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(false));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("createStopLimitOrder".to_string(), Value::Bool(false));
m.insert("createStopLossOrder".to_string(), Value::Bool(false));
m.insert("createStopMarketOrder".to_string(), Value::Bool(false));
m.insert("createStopOrder".to_string(), Value::Bool(false));
m.insert("createTakeProfitOrder".to_string(), Value::Bool(false));
m.insert("createTrailingAmountOrder".to_string(), Value::Bool(false));
m.insert("createTrailingPercentOrder".to_string(), Value::Bool(false));
m.insert("createTriggerOrder".to_string(), Value::Bool(false));
m.insert("fetchAccounts".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Bool(false));
m.insert("fetchCanceledAndClosedOrders".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(false));
m.insert("fetchConvertCurrencies".to_string(), Value::Bool(false));
m.insert("fetchConvertQuote".to_string(), Value::Bool(false));
m.insert("fetchConvertTrade".to_string(), Value::Bool(false));
m.insert("fetchConvertTradeHistory".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(false));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingInterval".to_string(), Value::Bool(false));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverages".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarginModes".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMarkPrices".to_string(), Value::Bool(false));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(false));
m.insert("fetchOHLCV".to_string(), Value::Bool(false));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenInterests".to_string(), Value::Bool(false));
m.insert("fetchOpenOrder".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOption".to_string(), Value::Bool(false));
m.insert("fetchOptionChain".to_string(), Value::Bool(false));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(false));
m.insert("fetchOrderTrades".to_string(), Value::Bool(false));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchStatus".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(false));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(false));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(false));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("repayMargin".to_string(), Value::Bool(false));
m.insert("sandbox".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(false));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(false));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/cce42038-d22e-49bc-8a9a-b9c92a2859a0".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.cryptomus.com".into()));
m.insert("private".to_string(), Value::Str("https://api.cryptomus.com".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://cryptomus.com".into()));
m.insert("doc".to_string(), Value::Str("https://doc.cryptomus.com/personal".into()));
m.insert("fees".to_string(), Value::Str("https://cryptomus.com/tariffs".into()));
m.insert("referral".to_string(), Value::Str("https://app.cryptomus.com/signup/?ref=JRP4yj".into()));
m
}));
m.insert("api".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("v2/user-api/exchange/markets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/exchange/market/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/exchange/markets/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/exchange/market/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/exchange/market/order-book/{currencyPair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/exchange/market/tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/exchange/market/trades/{currencyPair}".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("v2/user-api/exchange/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/exchange/orders/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/exchange/account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/exchange/account/tariffs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/payment/services".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/payout/services".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/transaction/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/convert/direction-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/convert/order-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/aml/check/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/aml/check/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/aml/check/packages".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/aml/check/request".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/aml/check/request/{id}".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("v2/user-api/exchange/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/exchange/orders/market".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/convert/calculate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/convert/limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/aml/check/request".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/aml/check/request/{id}/report/send".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v2/user-api/exchange/orders/{orderId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user-api/convert/{orderUuid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
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("percentage".to_string(), Value::Bool(true));
m.insert("feeSide".to_string(), Value::Str("get".into()));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.02".into()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.02".into()), &[]));
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(true));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BEP20".to_string(), Value::Str("bsc".into()));
m.insert("DASH".to_string(), Value::Str("dash".into()));
m.insert("POLYGON".to_string(), Value::Str("polygon".into()));
m.insert("ARBITRUM".to_string(), Value::Str("arbitrum".into()));
m.insert("SOL".to_string(), Value::Str("sol".into()));
m.insert("TON".to_string(), Value::Str("ton".into()));
m.insert("ERC20".to_string(), Value::Str("eth".into()));
m.insert("TRC20".to_string(), Value::Str("tron".into()));
m.insert("LTC".to_string(), Value::Str("ltc".into()));
m.insert("XMR".to_string(), Value::Str("xmr".into()));
m.insert("BCH".to_string(), Value::Str("bch".into()));
m.insert("DOGE".to_string(), Value::Str("doge".into()));
m.insert("AVAX".to_string(), Value::Str("avalanche".into()));
m.insert("BTC".to_string(), Value::Str("btc".into()));
m.insert("RUB".to_string(), Value::Str("rub".into()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("bsc".to_string(), Value::Str("BEP20".into()));
m.insert("dash".to_string(), Value::Str("DASH".into()));
m.insert("polygon".to_string(), Value::Str("POLYGON".into()));
m.insert("arbitrum".to_string(), Value::Str("ARBITRUM".into()));
m.insert("sol".to_string(), Value::Str("SOL".into()));
m.insert("ton".to_string(), Value::Str("TON".into()));
m.insert("eth".to_string(), Value::Str("ERC20".into()));
m.insert("tron".to_string(), Value::Str("TRC20".into()));
m.insert("ltc".to_string(), Value::Str("LTC".into()));
m.insert("xmr".to_string(), Value::Str("XMR".into()));
m.insert("bch".to_string(), Value::Str("BCH".into()));
m.insert("doge".to_string(), Value::Str("DOGE".into()));
m.insert("avalanche".to_string(), Value::Str("AVAX".into()));
m.insert("btc".to_string(), Value::Str("BTC".into()));
m.insert("rub".to_string(), Value::Str("RUB".into()));
m
}));
m.insert("fetchOrderBook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("level".to_string(), Value::Int(0));
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("500".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("6".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("Insufficient funds.".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("Minimum amount 15 USDT".to_string(), Value::Str("InvalidOrder".into()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(false));
m.insert("uid".to_string(), Value::Bool(true));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name cryptomus#fetchMarkets
* @description retrieves data on all markets for the exchange
* @see https://doc.cryptomus.com/personal/market-cap/tickers
* @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
}));
let mut response: Value = self.public_get_v2_user_api_exchange_markets(&[params]).await;
//
// {
// "result": [
// {
// "id": "01JHN5EFT64YC4HR9KCGM5M65D",
// "symbol": "POL_USDT",
// "baseCurrency": "POL",
// "quoteCurrency": "USDT",
// "baseMinSize": "1.00000000",
// "quoteMinSize": "5.00000000",
// "baseMaxSize": "50000.00000000",
// "quoteMaxSize": "10000000000.00000000",
// "basePrec": "1",
// "quotePrec": "4"
// },
// ...
// ]
// }
//
let mut result: Value = self.safe_list_k(response, "result", &[Value::from(vec![])]);
return self.parse_markets(result);
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
//
// {
// "id": "01JHN5EFT64YC4HR9KCGM5M65D",
// "symbol": "POL_USDT",
// "baseCurrency": "POL",
// "quoteCurrency": "USDT",
// "baseMinSize": "1.00000000",
// "quoteMinSize": "5.00000000",
// "baseMaxSize": "50000.00000000",
// "quoteMaxSize": "10000000000.00000000",
// "basePrec": "1",
// "quotePrec": "4"
// }
//
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[]);
if (marketId == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseMarket() missing marketId".into()))));
}
let mut parts: Value = split(&marketId, &Value::Str("_".into()));
let mut baseId: Value = parts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut quoteId: Value = parts.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
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 fees: Value = self.safe_dict_k(self.fees.clone(), "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(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("active".to_string(), Value::Bool(true));
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("subType".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("contract".to_string(), Value::Bool(false));
m.insert("settle".to_string(), Value::Null);
m.insert("settleId".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("taker".to_string(), self.safe_number_k(fees.clone(), "taker", &[]));
m.insert("maker".to_string(), self.safe_number_k(fees.clone(), "maker", &[]));
m.insert("percentage".to_string(), self.safe_bool_k(fees.clone(), "percentage", &[]));
m.insert("tierBased".to_string(), Value::Null);
m.insert("feeSide".to_string(), self.safe_string_k(fees, "feeSide", &[]));
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.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quotePrec", &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "basePrec", &[])]), &[]));
m
}));
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(), self.safe_number_k(market.clone(), "quoteMinSize", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "quoteMaxSize", &[]));
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(), "baseMinSize", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "baseMaxSize", &[]));
m
}));
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("cost".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(), Value::Null);
m.insert("info".to_string(), market);
m
})]);
Value::Null
}
/*
* @method
* @name cryptomus#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://doc.cryptomus.com/personal/market-cap/assets
* @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 response: Value = self.public_get_v1_exchange_market_assets(&[params]).await;
//
// {
// 'state': '0',
// 'result': [
// {
// 'currency_code': 'USDC',
// 'network_code': 'bsc',
// 'can_withdraw': true,
// 'can_deposit': true,
// 'min_withdraw': '1.00000000',
// 'max_withdraw': '10000000.00000000',
// 'max_deposit': '10000000.00000000',
// 'min_deposit': '1.00000000'
// },
// ...
// ]
// }
//
let mut coins: Value = self.safe_list_k(response, "result", &[]);
let mut groupedById: Value = self.group_by(coins, Value::Str("currency_code".into()), &[]);
let mut groupedArray: Value = object_values(&groupedById);
return self.parse_currencies(groupedArray);
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
// currency here is array of networks
let mut id: Value = Value::Null; // all entries have same id, as they were grouped by
let mut code: Value = Value::Null;
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_585: bool = true;
while { if !__for_first_585 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_585 = false; i.as_f64().unwrap_or(f64::NAN) < ((rawCurrency.len() as i64) as f64) } {
let mut networkEntry: Value = self.safe_dict(rawCurrency.clone(), i.clone(), &[]);
// set ID on first loop
if (id == Value::Null) {
id = self.safe_string_k(networkEntry.clone(), "currency_code", &[]);
code = self.safe_currency_code(id.clone(), &[]);
}
let mut networkId: Value = self.safe_string_k(networkEntry.clone(), "network_code", &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut networks { 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("network".to_string(), networkCode.clone());
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(), "min_withdraw", &[]));
m.insert("max".to_string(), self.safe_number_k(networkEntry.clone(), "max_withdraw", &[]));
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(networkEntry.clone(), "min_deposit", &[]));
m.insert("max".to_string(), self.safe_number_k(networkEntry.clone(), "max_deposit", &[]));
m
}));
m
}));
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), self.safe_bool_k(networkEntry.clone(), "can_deposit", &[]));
m.insert("withdraw".to_string(), self.safe_bool_k(networkEntry.clone(), "can_withdraw", &[]));
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Null);
m.insert("info".to_string(), networkEntry);
m
})); }
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("code".to_string(), code);
m.insert("networks".to_string(), networks);
m.insert("info".to_string(), rawCurrency);
m
}));
Value::Null
}
/*
* @method
* @name cryptomus#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://doc.cryptomus.com/personal/market-cap/tickers
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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;
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
let mut response: Value = self.public_get_v1_exchange_market_tickers(&[params]).await;
//
// {
// "data": [
// {
// "currency_pair": "MATIC_USDT",
// "last_price": "0.342",
// "base_volume": "1676.84092771",
// "quote_volume": "573.48033609043"
// },
// ...
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[]);
return self.parse_tickers(data, &[symbolsNormalized]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "currency_pair": "XMR_USDT",
// "last_price": "158.04829772",
// "base_volume": "0.35185785",
// "quote_volume": "55.523761128544"
// }
//
let mut marketId: Value = self.safe_string_k(ticker.clone(), "currency_pair", &[]);
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 last: Value = self.safe_string_k(ticker.clone(), "last_price", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("high".to_string(), Value::Null);
m.insert("low".to_string(), Value::Null);
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(), Value::Null);
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last);
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(), "base_volume", &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(ticker.clone(), "quote_volume", &[]));
m.insert("info".to_string(), ticker);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name cryptomus#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://doc.cryptomus.com/personal/market-cap/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
* @param {int} [params.level] 0 or 1 or 2 or 3 or 4 or 5 - the level of volume
* @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("currencyPair".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut level: Value = Value::Int(0);
let mut levelOptionparamsLevelVariable = self.handle_option_integer_and_params(params, Value::Str("fetchOrderBook".into()), Value::Str("level".into()), &[level]);
let mut levelOption: Value = levelOptionparamsLevelVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsLevel: Value = levelOptionparamsLevelVariable.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("level".into(), levelOption); }
let __ws_arg_0 = self.extend(request, &[paramsLevel]);
let mut response: Value = self.public_get_v1_exchange_market_order_book_currency_pair(&[__ws_arg_0]).await;
//
// {
// "data": {
// "timestamp": "1730138702",
// "bids": [
// {
// "price": "2250.00",
// "quantity": "1.00000"
// }
// ],
// "asks": [
// {
// "price": "2428.69",
// "quantity": "0.16470"
// }
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.safe_timestamp_k(data.clone(), "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
}
/*
* @method
* @name cryptomus#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://doc.cryptomus.com/personal/market-cap/trades
* @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 (maximum value is 100)
* @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("currencyPair".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.public_get_v1_exchange_market_trades_currency_pair(&[__ws_arg_1]).await;
//
// {
// "data": [
// {
// "trade_id": "01J829C3RAXHXHR09HABGQ1YAT",
// "price": "2315.6320500000000000",
// "base_volume": "21.9839623057260000",
// "quote_volume": "0.0094937200000000",
// "timestamp": 1726653796,
// "type": "sell"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[]);
let mut dataList: Value = Value::from(vec![]);
if (data != Value::Null) {
dataList = data;
}
return self.parse_trades(dataList, &[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);
//
// {
// "trade_id": "01J017Q6B3JGHZRP9D2NZHVKFX",
// "price": "59498.63487492",
// "base_volume": "94.00784310",
// "quote_volume": "0.00158000",
// "timestamp": 1718028573,
// "type": "sell"
// }
//
let mut timestamp: Value = self.safe_timestamp_k(trade.clone(), "timestamp", &[]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(trade.clone(), "trade_id", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("side".to_string(), self.safe_string_k(trade.clone(), "type", &[]));
m.insert("price".to_string(), self.safe_string_k(trade.clone(), "price", &[]));
m.insert("amount".to_string(), self.safe_string_k(trade.clone(), "quote_volume", &[]));
m.insert("cost".to_string(), self.safe_string_k(trade.clone(), "base_volume", &[]));
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("type".to_string(), Value::Null);
m.insert("order".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m
}));
m.insert("info".to_string(), trade);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name cryptomus#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://doc.cryptomus.com/personal/converts/balance
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let __ws_arg_2 = self.extend(request, &[params]);
let mut response: Value = self.private_get_v2_user_api_exchange_account_balance(&[__ws_arg_2]).await;
//
// {
// "result": [
// {
// "ticker": "AVAX",
// "available": "0.00000000",
// "held": "0.00000000"
// }
// ]
// }
//
let mut result: Value = self.safe_list_k(response, "result", &[Value::from(vec![])]);
return self.parse_balance(result);
Value::Null
}
pub fn parse_balance(&self, mut balance: Value) -> Value {
//
// {
// "ticker": "AVAX",
// "available": "0.00000000",
// "held": "0.00000000"
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), balance.clone());
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_586: bool = true;
while { if !__for_first_586 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_586 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&balance).as_f64().unwrap_or(f64::NAN) } {
let mut balanceEntry: Value = self.safe_dict(balance.clone(), i.clone(), &[]);
let mut currencyId: Value = self.safe_string_k(balanceEntry.clone(), "ticker", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(balanceEntry.clone(), "available", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string_k(balanceEntry, "held", &[])); }
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 cryptomus#createOrder
* @description create a trade order
* @see https://doc.cryptomus.com/personal/exchange/market-order-creation
* @see https://doc.cryptomus.com/personal/exchange/limit-order-creation
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit' or for spot
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of you want to trade in units of the base currency
* @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders (only for limit orders)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.cost] *market buy only* the quote quantity that can be used as an alternative for the amount
* @param {string} [params.clientOrderId] a unique identifier for the order (optional)
* @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
}));
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("market".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("direction".to_string(), side.clone());
m.insert("tag".to_string(), Value::Str("ccxt".into()));
m
});
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
let mut paramsOmitted: Value = (if (clientOrderId != Value::Null) { self.omit(params.clone(), Value::Str("clientOrderId".into()), &[]) } else { params });
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_order_id".into(), clientOrderId); }
}
let mut sideBuy: bool = side.as_str() == Some("buy");
let mut amountToString: Value = self.number_to_string(amount);
let mut priceToString: Value = self.number_to_string(price.clone());
let mut costParamparamsCostVariable = self.handle_param_string(paramsOmitted, Value::Str("cost".into()), &[]);
let mut costParam: Value = costParamparamsCostVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsCost: Value = costParamparamsCostVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut cost: Value = costParam;
let mut response: Value = Value::Null;
if (type_var.as_str() == Some("market")) {
let mut requiresPriceAndParams: Value = self.handle_option_bool_and_params(paramsCost.clone(), Value::Str("createOrder".into()), Value::Str("createMarketBuyOrderRequiresPrice".into()), &[Value::Bool(true)]);
let mut paramsMarket: Value = paramsCost.clone();
if sideBuy {
paramsMarket = requiresPriceAndParams.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
}
if sideBuy {
let mut createMarketBuyOrderRequiresPrice: Value = requiresPriceAndParams.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
if is_true(&createMarketBuyOrderRequiresPrice) {
if (price == Value::Null) && (cost == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option of param to false and pass the cost to spend in the amount argument".into()))));
} else if (cost == Value::Null) {
cost = crate::precise::Precise::stringMul(&amountToString, &priceToString);
}
} else {
cost = (if ((cost != Value::Null) && (cost.as_str() != Some(""))) { cost.clone() } else { amountToString.clone() });
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("value".into(), cost); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quantity".into(), amountToString.clone()); }
}
let __ws_arg_3 = self.extend(request.clone(), &[paramsMarket]);
response = self.private_post_v2_user_api_exchange_orders_market(&[__ws_arg_3]).await;
} else if (type_var.as_str() == Some("limit")) {
if (price == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a price parameter for a ".into())).into()), type_var).into()), Value::Str(" order".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quantity".into(), amountToString); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), price); }
let __ws_arg_4 = self.extend(request, &[paramsCost]);
response = self.private_post_v2_user_api_exchange_orders(&[__ws_arg_4]).await;
} else {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a type parameter (limit or market)".into()))));
}
return self.parse_order(response, &[market]);
Value::Null
}
/*
* @method
* @name cryptomus#cancelOrder
* @description cancels an open limit order
* @see https://doc.cryptomus.com/personal/exchange/limit-order-cancellation
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in (not used in cryptomus)
* @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 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
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderId".into(), id); }
let __ws_arg_5 = self.extend(request, &[params]);
let mut response: Value = self.private_delete_v2_user_api_exchange_orders_order_id(&[__ws_arg_5]).await;
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
}), &[]);
Value::Null
}
/*
* @method
* @name cryptomus#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://doc.cryptomus.com/personal/exchange/history-of-completed-orders
* @param {string} symbol unified market symbol of the market orders were made in (not used in cryptomus)
* @param {int} [since] the earliest time in ms to fetch orders for (not used in cryptomus)
* @param {int} [limit] the maximum number of order structures to retrieve (not used in cryptomus)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.direction] order direction 'buy' or 'sell'
* @param {string} [params.order_id] order id
* @param {string} [params.client_order_id] client order id
* @param {string} [params.limit] A special parameter that sets the maximum number of records the request will return
* @param {string} [params.offset] A special parameter that sets the number of records from the beginning of the list
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_and_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 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("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit); }
}
let __ws_arg_6 = self.extend(request, &[params]);
let mut response: Value = self.private_get_v2_user_api_exchange_orders_history(&[__ws_arg_6]).await;
//
// {
// "result": [
// {
// "id": "01JEXAPY04JDFBVFC2D23BCKMK",
// "type": "market",
// "direction": "sell",
// "symbol": "TRX_USDT",
// "quantity": "67.5400000000000000",
// "filledQuantity": "67.5400000000000000",
// "filledValue": "20.0053480000000000",
// "state": "completed",
// "internalState": "filled",
// "createdAt": "2024-12-12 11:40:19",
// "finishedAt": "2024-12-12 11:40:21",
// "deal": {
// "id": "01JEXAPZ9C9TWENPFZJASZ1YD2",
// "state": "completed",
// "createdAt": "2024-12-12 11:40:21",
// "completedAt": "2024-12-12 11:40:21",
// "averageFilledPrice": "0.2962000000000000",
// "transactions": [
// {
// "id": "01JEXAPZ9C9TWENPFZJASZ1YD3",
// "tradeRole": "taker",
// "filledPrice": "0.2962000000000000",
// "filledQuantity": "67.5400000000000000",
// "filledValue": "20.0053480000000000",
// "fee": "0.0000000000000000",
// "feeCurrency": "USDT",
// "committedAt": "2024-12-12 11:40:21"
// }
// ]
// }
// },
// ...
// ]
// }
//
let mut result: Value = self.safe_list_k(response, "result", &[Value::from(vec![])]);
let mut orders: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_587: bool = true;
while { if !__for_first_587 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_587 = false; i.as_f64().unwrap_or(f64::NAN) < ((result.len() as i64) as f64) } {
let mut order: Value = result.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
append_to_array(&mut orders, self.parse_order(order, &[market.clone()]));
}
}
return orders;
Value::Null
}
/*
* @method
* @name cryptomus#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://doc.cryptomus.com/personal/exchange/list-of-active-orders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for (not used in cryptomus)
* @param {int} [limit] the maximum number of open orders structures to retrieve (not used in cryptomus)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.direction] order direction 'buy' or 'sell'
* @param {string} [params.order_id] order id
* @param {string} [params.client_order_id] client order id
* @param {string} [params.limit] A special parameter that sets the maximum number of records the request will return
* @param {string} [params.offset] A special parameter that sets the number of records from the beginning of the list
* @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 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
});
if (market != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_7 = self.extend(request, &[params]);
let mut response: Value = self.private_get_v2_user_api_exchange_orders(&[__ws_arg_7]).await;
//
// {
// "result": [
// {
// "id": "01JFFG72CBRDP68K179KC9DSTG",
// "direction": "sell",
// "symbol": "BTC_USDT",
// "price": "102.0130000000000000",
// "quantity": "0.0005000000000000",
// "value": "0.0510065000000000",
// "filledQuantity": "0.0000000000000000",
// "filledValue": "0.0000000000000000",
// "createdAt": "2024-12-19 09:02:51",
// "clientOrderId": "987654321",
// "stopLossPrice": "101.12"
// },
// ...
// ]
// }
let mut result: Value = self.safe_list_k(response, "result", &[Value::from(vec![])]);
return self.parse_orders(result, &[market, Value::Null, Value::Null]);
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
// {
// "order_id": "01JEXAFCCC5ZVJPZAAHHDKQBNG"
// }
//
// fetchOrders
// {
// "id": "01JEXAPY04JDFBVFC2D23BCKMK",
// "type": "market",
// "direction": "sell",
// "symbol": "TRX_USDT",
// "quantity": "67.5400000000000000",
// "filledQuantity": "67.5400000000000000",
// "filledValue": "20.0053480000000000",
// "state": "completed",
// "internalState": "filled",
// "createdAt": "2024-12-12 11:40:19",
// "finishedAt": "2024-12-12 11:40:21",
// "deal": {
// "id": "01JEXAPZ9C9TWENPFZJASZ1YD2",
// "state": "completed",
// "createdAt": "2024-12-12 11:40:21",
// "completedAt": "2024-12-12 11:40:21",
// "averageFilledPrice": "0.2962000000000000",
// "transactions": [
// {
// "id": "01JEXAPZ9C9TWENPFZJASZ1YD3",
// "tradeRole": "taker",
// "filledPrice": "0.2962000000000000",
// "filledQuantity": "67.5400000000000000",
// "filledValue": "20.0053480000000000",
// "fee": "0.0000000000000000",
// "feeCurrency": "USDT",
// "committedAt": "2024-12-12 11:40:21"
// }
// ]
// }
// },
// ...
//
// fetchOpenOrders
// {
// "id": "01JFFG72CBRDP68K179KC9DSTG",
// "direction": "sell",
// "symbol": "BTC_USDT",
// "price": "102.0130000000000000",
// "quantity": "0.0005000000000000",
// "value": "0.0510065000000000",
// "filledQuantity": "0.0000000000000000",
// "filledValue": "0.0000000000000000",
// "createdAt": "2024-12-19 09:02:51",
// "clientOrderId": "987654321",
// "stopLossPrice": "101.12"
// }
//
let mut id: Value = self.safe_string2(order.clone(), Value::Str("order_id".into()), Value::Str("id".into()), &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market]);
let mut dateTime: Value = self.safe_string_k(order.clone(), "createdAt", &[]);
let mut timestamp: Value = self.parse8601(dateTime);
let mut deal: Value = self.safe_dict_k(order.clone(), "deal", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut averageFilledPrice: Value = self.safe_number_k(deal.clone(), "averageFilledPrice", &[]);
let mut type_var: Value = self.safe_string_k(order.clone(), "type", &[]);
let mut side: Value = self.safe_string_k(order.clone(), "direction", &[]);
let mut price: Value = self.safe_number_k(order.clone(), "price", &[]);
let mut transaction: Value = self.safe_list_k(deal, "transactions", &[Value::from(vec![])]);
let mut fee: Value = Value::Null;
let mut firstTx: Value = self.safe_dict(transaction, Value::Int(0), &[]);
let mut feeCurrency: Value = self.safe_string_k(firstTx.clone(), "feeCurrency", &[]);
if (feeCurrency != Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(feeCurrency, &[]));
m.insert("cost".to_string(), self.safe_number_k(firstTx.clone(), "fee", &[]));
m
});
}
if (price == Value::Null) {
price = self.safe_number_k(firstTx, "filledPrice", &[]);
}
let mut amount: Value = self.safe_number_k(order.clone(), "quantity", &[]);
let mut cost: Value = self.safe_number_k(order.clone(), "value", &[]);
let mut status: Value = self.parse_order_status(&[self.safe_string_k(order.clone(), "state", &[])]).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "clientOrderId", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
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("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("type".to_string(), type_var);
m.insert("timeInForce".to_string(), Value::Null);
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("stopPrice".to_string(), self.safe_string_k(order.clone(), "stopLossPrice", &[]));
m.insert("triggerPrice".to_string(), self.safe_string_k(order.clone(), "stopLossPrice", &[]));
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), cost);
m.insert("average".to_string(), averageFilledPrice);
m.insert("filled".to_string(), self.safe_string_k(order.clone(), "filledQuantity", &[]));
m.insert("remaining".to_string(), Value::Null);
m.insert("status".to_string(), status);
m.insert("fee".to_string(), fee);
m.insert("trades".to_string(), Value::Null);
m.insert("info".to_string(), order);
m
}), &[marketResolved]);
Value::Null
}
pub fn parse_order_status(&self, optional_args: &[Value]) -> Option<String> {
let mut status = get_arg(optional_args, 0, Value::Null);
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("active".to_string(), Value::Str("open".into()));
m.insert("completed".to_string(), Value::Str("closed".into()));
m.insert("partially_completed".to_string(), Value::Str("open".into()));
m.insert("cancelled".to_string(), Value::Str("canceled".into()));
m.insert("expired".to_string(), Value::Str("expired".into()));
m.insert("failed".to_string(), Value::Str("failed".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
/*
* @method
* @name cryptomus#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://trade-docs.coinlist.co/?javascript--nodejs#list-fees
* @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
}));
let mut response: Value = self.private_get_v2_user_api_exchange_account_tariffs(&[params]).await;
//
// {
// result: {
// equivalent_currency_code: 'USD',
// current_tariff_step: {
// step: '0',
// from_turnover: '0.00000000',
// maker_percent: '0.08',
// taker_percent: '0.1'
// },
// tariff_steps: [
// {
// step: '0',
// from_turnover: '0.00000000',
// maker_percent: '0.08',
// taker_percent: '0.1'
// },
// {
// step: '1',
// from_turnover: '100001.00000000',
// maker_percent: '0.06',
// taker_percent: '0.095'
// },
// {
// step: '2',
// from_turnover: '250001.00000000',
// maker_percent: '0.055',
// taker_percent: '0.085'
// },
// {
// step: '3',
// from_turnover: '500001.00000000',
// maker_percent: '0.05',
// taker_percent: '0.075'
// },
// {
// step: '4',
// from_turnover: '2500001.00000000',
// maker_percent: '0.04',
// taker_percent: '0.07'
// }
// ],
// daily_turnover: '0.00000000',
// monthly_turnover: '77.52062617',
// circulation_funds: '25.48900443'
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currentFeeTier: Value = self.safe_dict_k(data.clone(), "current_tariff_step", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut makerFee: Value = self.safe_string_k(currentFeeTier.clone(), "maker_percent", &[]);
let mut takerFee: Value = self.safe_string_k(currentFeeTier, "taker_percent", &[]);
makerFee = crate::precise::Precise::stringDiv(&makerFee, &Value::Str("100".into()));
takerFee = crate::precise::Precise::stringDiv(&takerFee, &Value::Str("100".into()));
let mut feeTiers: Value = self.safe_list_k(data, "tariff_steps", &[Value::from(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut tiers: Value = self.parse_fee_tiers(feeTiers, &[]);
let mut symbols: Value = self.symbols.clone();
if (symbols == Value::Null) {
return result;
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_588: bool = true;
while { if !__for_first_588 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_588 = 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(makerFee.clone(), &[]));
m.insert("taker".to_string(), self.parse_number(takerFee.clone(), &[]));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("tiers".to_string(), tiers.clone());
m
})); }
}
}
return result;
Value::Null
}
pub fn parse_fee_tiers(&self, mut feeTiers: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut takerFees: Value = Value::from(vec![]);
let mut makerFees: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_589: bool = true;
while { if !__for_first_589 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_589 = false; i.as_f64().unwrap_or(f64::NAN) < ((feeTiers.len() as i64) as f64) } {
let mut tier: Value = self.safe_dict(feeTiers.clone(), i.clone(), &[]);
let mut turnover: Value = self.safe_number_k(tier.clone(), "from_turnover", &[]);
let mut taker: Value = self.safe_string_k(tier.clone(), "taker_percent", &[]);
let mut maker: Value = self.safe_string_k(tier, "maker_percent", &[]);
maker = crate::precise::Precise::stringDiv(&maker, &Value::Str("100".into()));
taker = crate::precise::Precise::stringDiv(&taker, &Value::Str("100".into()));
append_to_array(&mut makerFees, Value::from(vec![turnover.clone(), self.parse_number(maker, &[])]));
append_to_array(&mut takerFees, Value::from(vec![turnover, self.parse_number(taker, &[])]));
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maker".to_string(), makerFees);
m.insert("taker".to_string(), takerFees);
m
});
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, 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 headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut endpoint: Value = self.implode_params(path.clone(), params.clone());
let mut paramsOmitted: Value = self.omit(params, self.extract_params(path), &[]);
let mut apiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), api.clone(), &[]);
if (apiUrl == 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 = Value::Str(format!("{}{}", Value::Str(format!("{}{}", apiUrl, Value::Str("/".into())).into()), endpoint).into());
if (api.as_str() == Some("private")) {
self.check_required_credentials(&[]);
let mut jsonParams: Value = Value::Str("".into());
let mut privateHeaders: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("userId".to_string(), self.uid.clone());
m
});
if (method.as_str() != Some("GET")) {
jsonParams = json_stringify(¶msOmitted);
if let Value::Dict(__d) = &mut privateHeaders { std::sync::Arc::make_mut(__d).insert("Content-Type".into(), Value::Str("application/json".into())); }
} else {
let mut query: Value = self.urlencode(paramsOmitted.clone(), &[]);
if (Value::Int(query.len() as i64).as_f64() != Some(0.0)) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), query).into())).into());
}
}
let mut jsonParamsBase64: Value = self.string_to_base64(jsonParams.clone(), &[]);
let mut stringToSign: Value = Value::Str(format!("{}{}", jsonParamsBase64, self.secret.clone()).into());
let mut signature: Value = self.hash(self.encode(stringToSign), Value::Str("md5".into()), &[]);
if let Value::Dict(__d) = &mut privateHeaders { std::sync::Arc::make_mut(__d).insert("sign".into(), signature); }
let mut privateBody: Value = (if (method.as_str() != Some("GET")) { jsonParams } else { body.clone() });
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), privateBody);
m.insert("headers".to_string(), privateHeaders);
m
});
} else {
let mut query: Value = self.urlencode(paramsOmitted, &[]);
if (Value::Int(query.len() as i64).as_f64() != Some(0.0)) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), query).into())).into());
}
}
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(), body);
m.insert("headers".to_string(), headers);
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;
}
if (in_op(&response, &Value::Str("code".into()))) {
let mut code: Value = self.safe_string_k(response.clone(), "code", &[]);
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), code, feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
} else if (in_op(&response, &Value::Str("message".into()))) {
//
// {"message":"Minimum amount 15 USDT","state":1}
//
let mut message: Value = self.safe_string_k(response.clone(), "message", &[]);
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), message, feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}