// 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;
pub struct ExtendedCore {
pub exchange: crate::exchange::Exchange,
}
impl ExtendedCore {
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 = ExtendedCore::describe(self);
self.initialize_properties(described);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// 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 ExtendedCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_position(self, position, &[market.clone()])
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_ledger_entry(self, entry, &[currency.clone()])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_currency(self, currency)
}
fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_open_interest(self, interest, &[market.clone()])
}
fn parse_funding_rate_history(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_funding_rate_history(self, entry, &[market.clone()])
}
fn parse_account(&self, account: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_account(self, account)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on ExtendedCore.
ExtendedCore::parse_leverage(self, leverage, &[market.clone()])
}
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 ExtendedCore.
ExtendedCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
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 ExtendedCore.
ExtendedCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for ExtendedCore {
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_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_extended_order_request" => self.create_extended_order_request(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..).unwrap_or(&[]).to_vec()[..]).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.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_order_settlement_data" => self.create_order_settlement_data(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..).unwrap_or(&[]).to_vec()[..]),
"create_transfer_settlement_data" => self.create_transfer_settlement_data(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..).unwrap_or(&[]).to_vec()[..]),
"create_withdrawal_settlement_data" => self.create_withdrawal_settlement_data(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..).unwrap_or(&[]).to_vec()[..]),
"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.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_account" => self.fetch_account(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_accounts" => self.fetch_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_extended_account" => self.fetch_extended_account(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_history" => self.fetch_funding_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_history" => self.fetch_positions_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transactions" => self.fetch_transactions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"get_extended_currency_code_by_id" => self.get_extended_currency_code_by_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"get_extended_decimal_to_base16" => self.get_extended_decimal_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_extended_domain_hash" => self.get_extended_domain_hash(),
"get_extended_encode_i64" => self.get_extended_encode_i64(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_extended_order_msg_hash" => self.get_extended_order_msg_hash(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_extended_signature_hex" => self.get_extended_signature_hex(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_extended_stark_amount" => self.get_extended_stark_amount(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"get_extended_string_to_felt" => self.get_extended_string_to_felt(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_extended_transfer_msg_hash" => self.get_extended_transfer_msg_hash(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_extended_withdrawal_msg_hash" => self.get_extended_withdrawal_msg_hash(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)),
"index_by_stringified_numeric_id" => self.index_by_stringified_numeric_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"load_markets" => self.load_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"parse_account" => self.parse_account(args.get(0).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_funding_histories" => self.parse_funding_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_history" => self.parse_funding_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate_history" => self.parse_funding_rate_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_leverage" => self.parse_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_open_interest" => self.parse_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trading_fee" => self.parse_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transaction_type" => self.parse_transaction_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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.get(4..).unwrap_or(&[]).to_vec()[..]).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.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for ExtendedCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for ExtendedCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl ExtendedCore {
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("extended".to_string()));
m.insert("name".to_string(), Value::Str("Extended".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("SG".to_string())]));
m.insert("version".to_string(), Value::Str("v2".to_string()));
m.insert("rateLimit".to_string(), Value::Int(600));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("certified".to_string(), Value::Bool(false));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("dex".to_string(), Value::Bool(true));
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(true));
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("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelAllOrdersAfter".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(true));
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("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrders".to_string(), Value::Bool(false));
m.insert("createOrderWithTakeProfitAndStopLoss".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("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Bool(false));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
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("fetchDeposit".to_string(), Value::Bool(false));
m.insert("fetchDepositAddress".to_string(), Value::Bool(false));
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(false));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(false));
m.insert("fetchFundingHistory".to_string(), Value::Bool(true));
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(true));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(true));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(true));
m.insert("fetchLeverage".to_string(), Value::Bool(true));
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("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(true));
m.insert("fetchMarkPrice".to_string(), Value::Bool(false));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(true));
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("fetchOrderBooks".to_string(), Value::Bool(false));
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(false));
m.insert("fetchPosition".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("fetchPositionsHistory".to_string(), Value::Bool(true));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchStatus".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
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(true));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Bool(true));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(true));
m.insert("fetchWithdrawAddresses".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
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("setLeverage".to_string(), Value::Bool(true));
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("signIn".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("PT1M".to_string()));
m.insert("5m".to_string(), Value::Str("PT5M".to_string()));
m.insert("15m".to_string(), Value::Str("PT15M".to_string()));
m.insert("30m".to_string(), Value::Str("PT30M".to_string()));
m.insert("1h".to_string(), Value::Str("PT1H".to_string()));
m.insert("2h".to_string(), Value::Str("PT2H".to_string()));
m.insert("4h".to_string(), Value::Str("PT4H".to_string()));
m.insert("8h".to_string(), Value::Str("PT8H".to_string()));
m.insert("12h".to_string(), Value::Str("PT12H".to_string()));
m.insert("1d".to_string(), Value::Str("PT24H".to_string()));
m.insert("1w".to_string(), Value::Str("P7D".to_string()));
m.insert("1M".to_string(), Value::Str("P30D".to_string()));
m
}));
m.insert("hostname".to_string(), Value::Str("extended.exchange".to_string()));
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/e2fe2bdf-6b28-4af8-b30f-38db496dc079".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api.starknet.{hostname}".to_string()));
m
}));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api.starknet.sepolia.{hostname}".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://app.extended.exchange".to_string()));
m.insert("doc".to_string(), Value::Str("https://api.docs.extended.exchange".to_string()));
m.insert("fees".to_string(), Value::Str("https://docs.extended.exchange/extended-resources/trading/trading-fees-and-rebates".to_string()));
m.insert("referral".to_string(), Value::Str("".to_string()));
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("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/markets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/assets/{asset}/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/markets/{market}/stats".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/markets/{market}/orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/markets/{market}/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/candles/{market}/{candleType}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/{market}/funding".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/{market}/open-interests".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/builder/dashboard".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("user/accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/account/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/spot/balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/assetOperations".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/positions/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/orders/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/orders/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/orders/external/{externalId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/funding/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/rebates/stats".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/bridge/config".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/bridge/quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/affiliate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/referrals/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/referrals/links".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/referrals/dashboard".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/rewards/earned".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/rewards/leaderboard/stats".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolio/charts/equities".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolio/charts/pnl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("vault/public/performance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("vault/public/summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("builder/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("user/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/order/massCancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/deadmanswitch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/bridge/quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/referrals/use".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/referrals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("user/referrals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("patch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("user/leverage".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("user/order/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(false));
m.insert("privateKey".to_string(), Value::Bool(true));
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("InvalidOrder".to_string()).clone());
m.insert("1001".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1002".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1003".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1004".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1005".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1006".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("1008".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1009".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1010".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("1011".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1012".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1013".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1014".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1049".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1050".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10501".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1052".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1053".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1100".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1101".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1102".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1120".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1121".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1122".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1123".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1124".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1125".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1126".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1127".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1128".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1129".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1130".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1131".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1132".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1133".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1134".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1135".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1136".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1137".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1138".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1139".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1140".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("1141".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1142".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1143".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1144".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1145".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1146".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1147".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1148".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1500".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("1600".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1601".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1602".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1604".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1605".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1607".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1608".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1650".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1700".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1701".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1703".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1704".to_string(), Value::Str("BadRequest".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("builderFee".to_string(), Value::Bool(true));
m.insert("builderFeeRate".to_string(), Value::Str("0.0001".to_string()));
m.insert("builderId".to_string(), Value::Str("257624".to_string()));
m
}));
m
})]);
Value::Null
}
pub async fn load_markets(&mut self, optional_args: &[Value]) -> Value {
let mut reload = get_arg(optional_args, 0, Value::Bool(false));
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut markets: Value = self.super_load_markets(reload.clone(), params.clone()).await;
let mut currenciesByNumericId: Value = self.safe_dict_k(self.options.clone(), "currenciesByNumericId", &[]);
if is_true(&(is_equal(¤ciesByNumericId, &Value::Null))) || is_true(&reload) {
{ let __be_tmp = self.index_by_stringified_numeric_id(self.currencies.clone()); add_element_to_object(&mut self.options, &Value::Str("currenciesByNumericId".to_string()), __be_tmp); };
}
return markets;
Value::Null
}
pub fn index_by_stringified_numeric_id(&self, mut input: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&input, &Value::Null) {
return Value::Null;
}
let mut keys: Value = object_keys(&input);
{
let mut i: Value = Value::Int(0);
let mut __for_first_655: bool = true;
while { if !__for_first_655 { i = add(&i, &Value::Int(1)); } __for_first_655 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut item: Value = get_value(&input, &key);
let mut item: Value = get_value(&input, &key);
let mut numericIdString: Value = self.safe_string_k(item.clone(), "numericId", &[]);
if is_equal(&numericIdString, &Value::Null) {
continue;
}
add_element_to_object(&mut result, &numericIdString, item.clone());
}
}
return result;
Value::Null
}
/*
* @method
* @name extended#fetchMarkets
* @description retrieves data on all markets for extended
* @see https://api.docs.extended.exchange/#get-markets
* @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.v1_public_get_info_markets(&[params.clone()]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "name": "BTC-USD",
// "uiName": "BTC-USD",
// "category": "Crypto",
// "subCategory": "L1",
// "assetName": "BTC",
// "assetPrecision": 5,
// "collateralAssetName": "USD",
// "collateralAssetPrecision": 6,
// "description": "Bitcoin",
// "active": true,
// "status": "ACTIVE",
// "marketStats": {
// "dailyVolume": "231016077.512960",
// "dailyVolumeBase": "3025.00058",
// "dailyPriceChange": "420",
// "dailyPriceChangePercentage": "0.0055",
// "dailyLow": "75635",
// "dailyHigh": "77399",
// "lastPrice": "77259",
// "askPrice": "77260",
// "bidPrice": "77259",
// "markPrice": "77259.680250000004",
// "indexPrice": "77299.020412500001",
// "fundingRate": "0.000013",
// "nextFundingRate": 1777442400000,
// "openInterest": "115861923.311902",
// "openInterestBase": "1500.40958",
// "deleverageLevels": {
// "shortPositions": [
// {
// "level": 1,
// "rankingLowerBound": "-815.7788"
// },
// {
// "level": 2,
// "rankingLowerBound": "-2.1328"
// },
// {
// "level": 3,
// "rankingLowerBound": "-0.9297"
// },
// {
// "level": 4,
// "rankingLowerBound": "0.0000"
// }
// ],
// "longPositions": [
// {
// "level": 1,
// "rankingLowerBound": "-47234.9095"
// },
// {
// "level": 2,
// "rankingLowerBound": "-0.0030"
// },
// {
// "level": 3,
// "rankingLowerBound": "0.0020"
// },
// {
// "level": 4,
// "rankingLowerBound": "0.0033"
// }
// ]
// }
// },
// "tradingConfig": {
// "minOrderSize": "0.0001",
// "minOrderSizeChange": "0.00001",
// "minPriceChange": "1",
// "maxMarketOrderValue": "3000000",
// "maxLimitOrderValue": "15000000",
// "maxPositionValue": "60000000",
// "maxLeverage": "50.00",
// "hourlyFundingRateCap": "0.25",
// "maxNumOrders": "200",
// "limitPriceCap": "0.05",
// "limitPriceFloor": "0.05",
// "riskFactorConfig": [
// {
// "upperBound": "4000000",
// "riskFactor": "0.02",
// "isAvailableForUsers": true
// }
// ]
// },
// "l2Config": {
// "type": "STARKX",
// "collateralId": "0x1",
// "syntheticId": "0x4254432d3600000000000000000000",
// "syntheticResolution": 1000000,
// "collateralResolution": 1000000
// },
// "visibleOnUi": true,
// "createdAt": 1752829532673
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_markets(data.clone());
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
//
// {
// "name": "BTC-USD",
// "uiName": "BTC-USD",
// "category": "Crypto",
// "subCategory": "L1",
// "assetName": "BTC",
// "assetPrecision": 5,
// "collateralAssetName": "USD",
// "collateralAssetPrecision": 6,
// "description": "Bitcoin",
// "active": true,
// "status": "ACTIVE",
// "marketStats": { ... },
// "tradingConfig": {
// "minOrderSize": "0.0001",
// "minOrderSizeChange": "0.00001",
// "minPriceChange": "1",
// "maxMarketOrderValue": "3000000",
// "maxLimitOrderValue": "15000000",
// "maxPositionValue": "60000000",
// "maxLeverage": "50.00",
// "hourlyFundingRateCap": "0.25",
// "maxNumOrders": "200",
// "limitPriceCap": "0.05",
// "limitPriceFloor": "0.05",
// "riskFactorConfig": [
// {
// "upperBound": "4000000",
// "riskFactor": "0.02",
// "isAvailableForUsers": true
// }
// ]
// },
// "l2Config": { ... },
// "visibleOnUi": true,
// "createdAt": 1752829532673
// }
//
let mut tradingConfig: Value = self.safe_dict_k(market.clone(), "tradingConfig", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut marketId: Value = self.safe_string_k(market.clone(), "name", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "assetName", &[Value::Str("".to_string())]);
if is_greater_than_or_equal(&get_index_of(&baseId, &Value::Str("SPOT".to_string())), &Value::Int(0)) {
baseId = replace_str(&baseId, &Value::Str("SPOT".to_string()), &Value::Str("".to_string()));
}
let mut quoteId: Value = self.safe_string_k(market.clone(), "collateralAssetName", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if is_equal("eId, &Value::Str("USD".to_string())) {
quote = Value::Str("USDC".to_string());
}
let mut status: Value = self.safe_string_k(market.clone(), "status", &[]);
let mut active: Value = Value::Bool(is_equal(&status, &Value::Str("ACTIVE".to_string())));
let mut amountPrecision: Value = self.safe_number_k(tradingConfig.clone(), "minOrderSizeChange", &[]);
let mut pricePrecision: Value = self.safe_number_k(tradingConfig.clone(), "minPriceChange", &[]);
let mut maxLeverage: Value = self.safe_number_k(tradingConfig.clone(), "maxLeverage", &[]);
let mut minAmount: Value = self.safe_number_k(tradingConfig.clone(), "minOrderSize", &[]);
let mut maxCost: Value = self.safe_number_k(tradingConfig.clone(), "maxLimitOrderValue", &[]);
let mut created: Value = self.safe_integer_k(market.clone(), "createdAt", &[]);
let mut settleId: Value = Value::Null;
let mut settle: Value = Value::Null;
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut isSpot: Value = Value::Bool(false);
let mut type_var: Value = self.safe_string_lower(market.clone(), Value::Str("type".to_string()), &[]);
let mut contractSize: Value = Value::Null;
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
if is_equal(&type_var, &Value::Str("spot".to_string())) {
isSpot = Value::Bool(true);
} else {
type_var = Value::Str("swap".to_string());
settleId = quoteId.clone();
settle = quote.clone();
symbol = add(&symbol, &add(&Value::Str(":".to_string()), &settle));
contractSize = self.parse_number(Value::Str("1".to_string()), &[]);
linear = Value::Bool(true);
inverse = Value::Bool(false);
}
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("spot".to_string(), isSpot.clone());
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(!is_true(&isSpot)));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active.clone());
m.insert("contract".to_string(), Value::Bool(!is_true(&isSpot)));
m.insert("linear".to_string(), linear.clone());
m.insert("inverse".to_string(), inverse.clone());
m.insert("taker".to_string(), self.safe_number_k(self.fees.clone(), "taker", &[]));
m.insert("maker".to_string(), self.safe_number_k(self.fees.clone(), "maker", &[]));
m.insert("contractSize".to_string(), contractSize.clone());
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(), amountPrecision.clone());
m.insert("price".to_string(), pricePrecision.clone());
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(), self.parse_number(Value::Str("1".to_string()), &[]));
m.insert("max".to_string(), maxLeverage.clone());
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), minAmount.clone());
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".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(), maxCost.clone());
m
}));
m
}));
m.insert("created".to_string(), created.clone());
m.insert("info".to_string(), market.clone());
m
})]);
Value::Null
}
/*
* @method
* @name extended#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://api.docs.extended.exchange/#get-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.v1_public_get_info_assets(&[params.clone()]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "id": 1,
// "name": "USD",
// "symbol": "USD",
// "description": "USD Collateral",
// "precision": 6,
// "isActive": true,
// "isCollateral": true,
// "starkexId": "0x1",
// "starkexResolution": 1000000,
// "l1Id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
// "l1Resolution": 1000000,
// "version": 3,
// "createdAt": 1752829532673,
// "type": "SPOT",
// "canBeUsedAsCollateral": true,
// "riskFactors": [],
// "availableForTradeFactors": []
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_currencies(data.clone());
Value::Null
}
pub fn parse_currency(&self, mut currency: Value) -> Value {
//
// {
// "id": 1,
// "name": "USD",
// "symbol": "USD",
// "description": "USD Collateral",
// "precision": 6,
// "isActive": true,
// "isCollateral": true,
// "starkexId": "0x1",
// "starkexResolution": 1000000,
// "l1Id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
// "l1Resolution": 1000000,
// "version": 3,
// "createdAt": 1752829532673,
// "type": "SPOT",
// "canBeUsedAsCollateral": true,
// "riskFactors": [],
// "availableForTradeFactors": []
// }
//
let mut currencyId: Value = self.safe_string_k(currency.clone(), "symbol", &[]);
if is_true(&(!is_equal(¤cyId, &Value::Null))) && is_true(&(is_greater_than_or_equal(&get_index_of(¤cyId, &Value::Str("SPOT".to_string())), &Value::Int(0)))) {
currencyId = replace_str(¤cyId, &Value::Str("SPOT".to_string()), &Value::Str("".to_string()));
}
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if is_equal(¤cyId, &Value::Str("USD".to_string())) {
code = Value::Str("USDC".to_string());
}
let mut name: Value = self.safe_string_k(currency.clone(), "name", &[]);
let mut precision: Value = self.safe_integer_k(currency.clone(), "precision", &[Value::Int(0)]);
let mut isActive: Value = self.safe_bool_k(currency.clone(), "isActive", &[]);
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), currencyId.clone());
m.insert("code".to_string(), code.clone());
m.insert("numericId".to_string(), self.safe_integer_k(currency.clone(), "id", &[]));
m.insert("name".to_string(), name.clone());
m.insert("active".to_string(), isActive.clone());
m.insert("deposit".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m.insert("precision".to_string(), crate::runtime::Math::pow(&Value::Int(10), &multiply(&precision, &negate(&Value::Int(1)))));
m.insert("type".to_string(), Value::Str("other".to_string()));
m.insert("margin".to_string(), self.safe_bool_k(currency.clone(), "canBeUsedAsCollateral", &[]));
m.insert("info".to_string(), currency.clone());
m
}));
Value::Null
}
/*
* @method
* @name extended#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://api.docs.extended.exchange/#get-market-statistics
* @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
}));
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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_info_markets_market_stats(&[__ws_arg_0]).await;
//
// {
// "status": "OK",
// "data": {
// "dailyVolume": "231216165.666600",
// "dailyVolumeBase": "3027.36710",
// "dailyPriceChange": "181",
// "dailyPriceChangePercentage": "0.0024",
// "dailyLow": "75635",
// "dailyHigh": "77399",
// "lastPrice": "77026",
// "askPrice": "77026",
// "bidPrice": "77025",
// "markPrice": "77006.091897999984",
// "indexPrice": "77050.739529925005",
// "fundingRate": "0.000012",
// "nextFundingRate": 1777446000000,
// "openInterest": "114851569.088316",
// "openInterestBase": "1491.33012",
// "deleverageLevels": {
// "shortPositions": [
// { "level": 1, "rankingLowerBound": "-784.2884" },
// { "level": 2, "rankingLowerBound": "-2.1078" },
// { "level": 3, "rankingLowerBound": "-0.8754" },
// { "level": 4, "rankingLowerBound": "0.0000" }
// ],
// "longPositions": [
// { "level": 1, "rankingLowerBound": "-47747.2010" },
// { "level": 2, "rankingLowerBound": "-0.0131" },
// { "level": 3, "rankingLowerBound": "0.0019" },
// { "level": 4, "rankingLowerBound": "0.0032" }
// ]
// }
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for all markets
* @see https://api.docs.extended.exchange/#get-markets
* @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
}));
self.load_markets(&[]).await;
symbols = self.market_symbols(&[symbols.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbols, &Value::Null) {
let mut marketIds: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_656: bool = true;
while { if !__for_first_656 { i = add(&i, &Value::Int(1)); } __for_first_656 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut market: Value = self.market(get_value(&symbols, &i));
append_to_array(&mut marketIds, get_value(&market, &Value::Str("id".to_string())));
}
}
add_element_to_object(&mut request, &Value::Str("market".to_string()), marketIds.clone());
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_info_markets(&[__ws_arg_1]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "name": "BTC-USD",
// "assetName": "BTC",
// "collateralAssetName": "USD",
// "marketStats": {
// "dailyVolume": "231016077.512960",
// ...
// },
// ...
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut tickers: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_657: bool = true;
while { if !__for_first_657 { i = add(&i, &Value::Int(1)); } __for_first_657 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut marketData: Value = get_value(&data, &i);
let mut marketData: Value = get_value(&data, &i);
let mut marketId: Value = self.safe_string_k(marketData.clone(), "name", &[]);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut stats: Value = self.safe_dict_k(marketData.clone(), "marketStats", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut ticker: Value = self.parse_ticker(stats.clone(), &[market.clone()]);
let mut symbol: Value = get_value(&ticker, &Value::Str("symbol".to_string()));
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut tickers, &symbol, ticker.clone());
}
}
}
return self.filter_by_array_tickers(tickers.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "dailyVolume": "231216165.666600",
// "dailyVolumeBase": "3027.36710",
// "dailyPriceChange": "181",
// "dailyPriceChangePercentage": "0.0024",
// "dailyLow": "75635",
// "dailyHigh": "77399",
// "lastPrice": "77026",
// "askPrice": "77026",
// "bidPrice": "77025",
// "markPrice": "77006.091897999984",
// "indexPrice": "77050.739529925005",
// "fundingRate": "0.000012",
// "nextFundingRate": 1777446000000,
// "openInterest": "114851569.088316",
// "openInterestBase": "1491.33012",
// "deleverageLevels": {
// "shortPositions": [
// { "level": 1, "rankingLowerBound": "-784.2884" },
// { "level": 2, "rankingLowerBound": "-2.1078" },
// { "level": 3, "rankingLowerBound": "-0.8754" },
// { "level": 4, "rankingLowerBound": "0.0000" }
// ],
// "longPositions": [
// { "level": 1, "rankingLowerBound": "-47747.2010" },
// { "level": 2, "rankingLowerBound": "-0.0131" },
// { "level": 3, "rankingLowerBound": "0.0019" },
// { "level": 4, "rankingLowerBound": "0.0032" }
// ]
// }
// }
//
let mut symbol: Value = self.safe_symbol(Value::Null, &[market.clone()]);
let mut last: Value = self.safe_number_k(ticker.clone(), "lastPrice", &[]);
let mut percentageRaw: Value = self.safe_string_k(ticker.clone(), "dailyPriceChangePercentage", &[]);
let mut percentage: Value = ternary(is_true(&(!is_equal(&percentageRaw, &Value::Null))), crate::precise::Precise::stringMul(&percentageRaw, &Value::Str("100".to_string())), Value::Null);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("high".to_string(), self.safe_number_k(ticker.clone(), "dailyHigh", &[]));
m.insert("low".to_string(), self.safe_number_k(ticker.clone(), "dailyLow", &[]));
m.insert("bid".to_string(), self.safe_number_k(ticker.clone(), "bidPrice", &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_number_k(ticker.clone(), "askPrice", &[]));
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.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), self.safe_number_k(ticker.clone(), "dailyPriceChange", &[]));
m.insert("percentage".to_string(), percentage.clone());
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_number_k(ticker.clone(), "dailyVolumeBase", &[]));
m.insert("quoteVolume".to_string(), self.safe_number_k(ticker.clone(), "dailyVolume", &[]));
m.insert("markPrice".to_string(), self.safe_number_k(ticker.clone(), "markPrice", &[]));
m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://api.docs.extended.exchange/#get-market-order-book
* @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
}));
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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_info_markets_market_orderbook(&[__ws_arg_2]).await;
//
// {
// "status": "OK",
// "data": {
// "market": "BTC-USD",
// "bid": [
// {
// "qty": "14.46084",
// "price": "76214"
// }
// ],
// "ask": [
// {
// "qty": "0.11585",
// "price": "76215"
// }
// ]
// }
// }
//
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.milliseconds();
let mut orderbook: Value = self.parse_order_book(data.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[timestamp.clone(), Value::Str("bid".to_string()), Value::Str("ask".to_string()), Value::Str("price".to_string()), Value::Str("qty".to_string())]);
if !is_equal(&limit, &Value::Null) {
{ let __be_tmp = self.array_slice(get_value(&orderbook, &Value::Str("bids".to_string())), Value::Int(0), &[limit.clone()]); add_element_to_object(&mut orderbook, &Value::Str("bids".to_string()), __be_tmp); };
{ let __be_tmp = self.array_slice(get_value(&orderbook, &Value::Str("asks".to_string())), Value::Int(0), &[limit.clone()]); add_element_to_object(&mut orderbook, &Value::Str("asks".to_string()), __be_tmp); };
}
return orderbook;
Value::Null
}
/*
* @method
* @name extended#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://api.docs.extended.exchange/#get-market-last-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
* @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
}));
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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_info_markets_market_trades(&[__ws_arg_3]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "i": 2.049676905958871e+18,
// "m": "BTC-USD",
// "S": "SELL",
// "tT": "TRADE",
// "T": 1777516030193,
// "p": "76140",
// "q": "0.00165"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_trades(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchMyTrades
* @description fetch all trades made by the user
* @see https://api.docs.extended.exchange/#get-trades
* @param {string} [symbol] unified market symbol of the trades
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trade 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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @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
}));
self.load_markets(&[]).await;
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchMyTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(100)]).await;
}
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_4 = self.extend(params.clone(), &[request.clone()]);
let mut response: Value = self.v1_private_get_user_trades(&[__ws_arg_4]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "id": 1,
// "orderId": 1784980437895231232,
// "externalId": "ExtId-1",
// "accountId": 1,
// "market": "BTC-USD",
// "side": "BUY",
// "price": "39000",
// "qty": "0.2",
// "value": "7800",
// "fee": "1.3",
// "tradeType": "TRADE",
// "isTaker": true,
// "createdTime": 1701563440000
// }
// ],
// "pagination": {
// "cursor": 1784963886257016832,
// "count": 1
// }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut pagination: Value = self.safe_dict_k(response.clone(), "pagination", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cursor: Value = self.safe_string_k(pagination.clone(), "cursor", &[]);
let mut result: Value = Value::List(vec![]);
let mut dataLength: Value = get_array_length(&data);
{
let mut i: Value = Value::Int(0);
let mut __for_first_658: bool = true;
while { if !__for_first_658 { i = add(&i, &Value::Int(1)); } __for_first_658 = false; is_less_than(&i, &dataLength) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
if is_true(&(!is_equal(&cursor, &Value::Null))) && is_true(&(is_equal(&i, &subtract(&dataLength, &Value::Int(1))))) {
entry = self.extend(entry.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cursor".to_string(), cursor.clone());
m
})]);
}
append_to_array(&mut result, entry.clone());
}
}
return self.parse_trades(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchFundingHistory
* @description fetch the funding payments history
* @see https://api.docs.extended.exchange/#get-funding-payments
* @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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {FundingHistory[]} a list of [funding history structures]{@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
}));
self.load_markets(&[]).await;
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingHistory".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchFundingHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(100)]).await;
}
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_5 = self.extend(params.clone(), &[request.clone()]);
let mut response: Value = self.v1_private_get_user_funding_history(&[__ws_arg_5]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "id": 8341,
// "accountId": 3137,
// "market": "BNB-USD",
// "positionId": 1821237954501148672,
// "side": "LONG",
// "size": "1.116",
// "value": "560.77401888",
// "markPrice": "502.48568",
// "fundingFee": "0",
// "fundingRate": "0",
// "paidTime": 1723147241346
// }
// ],
// "pagination": {
// "cursor": 8341,
// "count": 1
// }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut pagination: Value = self.safe_dict_k(response.clone(), "pagination", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cursor: Value = self.safe_string_k(pagination.clone(), "cursor", &[]);
let mut result: Value = Value::List(vec![]);
let mut dataLength: Value = get_array_length(&data);
{
let mut i: Value = Value::Int(0);
let mut __for_first_659: bool = true;
while { if !__for_first_659 { i = add(&i, &Value::Int(1)); } __for_first_659 = false; is_less_than(&i, &dataLength) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
if is_true(&(!is_equal(&cursor, &Value::Null))) && is_true(&(is_equal(&i, &subtract(&dataLength, &Value::Int(1))))) {
entry = self.extend(entry.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cursor".to_string(), cursor.clone());
m
})]);
}
append_to_array(&mut result, entry.clone());
}
}
return self.parse_funding_histories(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_funding_history(&self, mut history: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "id": 8341,
// "accountId": 3137,
// "market": "BNB-USD",
// "positionId": 1821237954501148672,
// "side": "LONG",
// "size": "1.116",
// "value": "560.77401888",
// "markPrice": "502.48568",
// "fundingFee": "0",
// "fundingRate": "0",
// "paidTime": 1723147241346
// }
//
let mut marketId: Value = self.safe_string_k(history.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer_k(history.clone(), "paidTime", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), history.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("code".to_string(), get_value(&market, &Value::Str("settle".to_string())));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("id".to_string(), self.safe_string_k(history.clone(), "id", &[]));
m.insert("amount".to_string(), self.safe_number_k(history.clone(), "fundingFee", &[]));
m.insert("rate".to_string(), self.safe_number_k(history.clone(), "fundingRate", &[]));
m
});
Value::Null
}
pub fn parse_funding_histories(&self, mut histories: Value, optional_args: &[Value]) -> Value {
let mut market = 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 result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_660: bool = true;
while { if !__for_first_660 { i = add(&i, &Value::Int(1)); } __for_first_660 = false; is_less_than(&i, &get_array_length(&histories)) } {
append_to_array(&mut result, self.parse_funding_history(get_value(&histories, &i), &[market.clone()]));
}
}
let mut symbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("symbol".to_string())));
return self.filter_by_symbol_since_limit(result.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades
//
// {
// "i": 2.049676905958871e+18,
// "m": "BTC-USD",
// "S": "SELL",
// "tT": "TRADE",
// "T": 1777516030193,
// "p": "76140",
// "q": "0.00165"
// }
//
// fetchMyTrades
//
// {
// "id": 1,
// "orderId": 1784980437895231232,
// "externalId": "ExtId-1",
// "accountId": 1,
// "market": "BTC-USD",
// "side": "BUY",
// "price": "39000",
// "qty": "0.2",
// "value": "7800",
// "fee": "1.3",
// "tradeType": "TRADE",
// "isTaker": true,
// "createdTime": 1701563440000
// }
//
let mut marketId: Value = self.safe_string2(trade.clone(), Value::Str("m".to_string()), Value::Str("market".to_string()), &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer2(trade.clone(), Value::Str("T".to_string()), Value::Str("createdTime".to_string()), &[]);
let mut priceString: Value = self.safe_string2(trade.clone(), Value::Str("p".to_string()), Value::Str("price".to_string()), &[]);
let mut amountString: Value = self.safe_string2(trade.clone(), Value::Str("q".to_string()), Value::Str("qty".to_string()), &[]);
let mut sideRaw: Value = self.safe_string2(trade.clone(), Value::Str("S".to_string()), Value::Str("side".to_string()), &[]);
let mut side: Value = ternary(is_true(&(!is_equal(&sideRaw, &Value::Null))), to_lower(&sideRaw), Value::Null);
let mut feeCost: Value = self.safe_string_k(trade.clone(), "fee", &[]);
let mut fee: Value = ternary(is_true(&(is_equal(&feeCost, &Value::Null))), Value::Null, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m.insert("currency".to_string(), ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("settle".to_string()))));
m
}));
let mut isTaker: Value = self.safe_bool_k(trade.clone(), "isTaker", &[]);
let mut takerOrMaker: Value = Value::Null;
if !is_equal(&isTaker, &Value::Null) {
takerOrMaker = ternary(is_true(&isTaker), Value::Str("taker".to_string()), Value::Str("maker".to_string()));
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(trade.clone(), Value::Str("i".to_string()), Value::Str("id".to_string()), &[]));
m.insert("info".to_string(), trade.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("order".to_string(), self.safe_string_k(trade.clone(), "orderId", &[]));
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), self.safe_string_k(trade.clone(), "value", &[]));
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://api.docs.extended.exchange/#get-candles-history
* @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] the maximum amount of candles to fetch, default 100
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.candleType] candle type: 'trades' (default), 'mark-prices', or 'index-prices'
* @param {string} [params.price] *ignored if params.candleType is set* 'mark' or 'index' for mark price and index price candles
* @param {int} [params.until] end timestamp in ms for the requested period
* @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".to_string()));
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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut price: Value = self.safe_string_k(params.clone(), "price", &[]);
let mut candleType: Value = self.safe_string_k(params.clone(), "candleType", &[]);
if is_equal(&candleType, &Value::Null) {
if is_equal(&price, &Value::Str("mark".to_string())) {
candleType = Value::Str("mark-prices".to_string());
} else if is_equal(&price, &Value::Str("index".to_string())) {
candleType = Value::Str("index-prices".to_string());
} else {
candleType = Value::Str("trades".to_string());
}
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("candleType".to_string()), Value::Str("price".to_string()), Value::Str("until".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("candleType".to_string(), candleType.clone());
m.insert("interval".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m.insert("limit".to_string(), ternary(is_true(&(!is_equal(&limit, &Value::Null))), limit.clone(), Value::Int(100)));
m
});
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_info_candles_market_candle_type(&[__ws_arg_6]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "o": "75657.5",
// "l": "75657.5",
// "h": "75657.5",
// "c": "75657.5",
// "v": "0",
// "T": 1777517880000
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_ohlc_vs(data.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
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::List(vec![self.safe_integer_k(ohlcv.clone(), "T", &[]), self.safe_number_k(ohlcv.clone(), "o", &[]), self.safe_number_k(ohlcv.clone(), "h", &[]), self.safe_number_k(ohlcv.clone(), "l", &[]), self.safe_number_k(ohlcv.clone(), "c", &[]), self.safe_number_k(ohlcv.clone(), "v", &[])]);
Value::Null
}
/*
* @method
* @name extended#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://api.docs.extended.exchange/#get-funding-rates-history
* @param {string} symbol unified symbol of the market to fetch funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of entries 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 to fetch
* @param {int} [params.endTime] exchange-specific end timestamp in ms of the latest funding rate to fetch
* @param {int} [params.cursor] offset of the result set
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available 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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchFundingRateHistory() requires a symbol argument".to_string()))));
}
self.load_markets(&[]).await;
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingRateHistory".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchFundingRateHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(10000)]).await;
}
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
if is_equal(&limit, &Value::Null) {
limit = Value::Int(100);
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[self.milliseconds()]);
let mut endTime: Value = self.safe_integer_k(params.clone(), "endTime", &[until.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("endTime".to_string()), Value::Str("until".to_string())]), &[]);
if is_equal(&since, &Value::Null) {
since = subtract(&endTime, &(multiply(&multiply(&multiply(&limit, &Value::Int(60)), &Value::Int(60)), &Value::Int(1000))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("startTime".to_string(), since.clone());
m.insert("endTime".to_string(), endTime.clone());
m.insert("limit".to_string(), limit.clone());
m
});
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_info_market_funding(&[__ws_arg_7]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "m": "BTC-USD",
// "f": "0.000008",
// "T": 1777507201028
// }
// ],
// "pagination": {
// "cursor": 1784963886257016832,
// "count": 1
// }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut pagination: Value = self.safe_dict_k(response.clone(), "pagination", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cursor: Value = self.safe_string_k(pagination.clone(), "cursor", &[]);
let mut result: Value = Value::List(vec![]);
let mut dataLength: Value = get_array_length(&data);
{
let mut i: Value = Value::Int(0);
let mut __for_first_661: bool = true;
while { if !__for_first_661 { i = add(&i, &Value::Int(1)); } __for_first_661 = false; is_less_than(&i, &dataLength) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
if is_true(&(!is_equal(&cursor, &Value::Null))) && is_true(&(is_equal(&i, &subtract(&dataLength, &Value::Int(1))))) {
entry = self.extend(entry.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cursor".to_string(), cursor.clone());
m
})]);
}
append_to_array(&mut result, self.parse_funding_rate_history(entry.clone(), &[market.clone()]));
}
}
let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "m": "BTC-USD",
// "f": "0.000008",
// "T": 1777507201028
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "m", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer_k(info.clone(), "T", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("fundingRate".to_string(), self.safe_number_k(info.clone(), "f", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
/*
* @method
* @name extended#fetchOpenInterestHistory
* @description Retrieves the open interest history of a currency
* @see https://api.docs.extended.exchange/#get-open-interest-history
* @param {string} symbol unified CCXT market symbol
* @param {string} timeframe '1h' or '1d'
* @param {int} [since] the time(ms) of the earliest record to retrieve as a unix timestamp
* @param {int} [limit] the maximum amount of open interest structures to retrieve
* @param {object} [params] exchange specific parameters
* @param {int} [params.until] timestamp in ms of the latest open interest record to fetch
* @returns {object[]} an array of [open interest structures]{@link https://docs.ccxt.com/?id=open-interest-structure}
*/
pub async fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".to_string()));
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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut interval: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[]);
if !is_true(&self.in_array(interval.clone(), Value::List(vec![Value::Str("PT1H".to_string()), Value::Str("P1D".to_string())]))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchOpenInterestHistory() supports 1h and 1d timeframes only".to_string()))));
}
if is_equal(&limit, &Value::Null) {
limit = Value::Int(100);
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[self.milliseconds()]);
let mut endTime: Value = self.safe_integer_k(params.clone(), "endTime", &[until.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("endTime".to_string()), Value::Str("until".to_string())]), &[]);
if is_equal(&since, &Value::Null) {
since = subtract(&endTime, &(multiply(&multiply(&limit, &self.parse_timeframe(timeframe.clone())), &Value::Int(1000))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("interval".to_string(), interval.clone());
m.insert("startTime".to_string(), since.clone());
m.insert("endTime".to_string(), endTime.clone());
m.insert("limit".to_string(), limit.clone());
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_info_market_open_interests(&[__ws_arg_8]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "i": "112620590.6060360000000000",
// "I": "1473.1408400000000000",
// "t": 1777420800000
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_open_interests_history(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "i": "112620590.6060360000000000",
// "I": "1473.1408400000000000",
// "t": 1777420800000
// }
//
let mut timestamp: Value = self.safe_integer_k(interest.clone(), "t", &[]);
return self.safe_open_interest(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "I", &[]));
m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "i", &[]));
m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "I", &[]));
m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "i", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("info".to_string(), interest.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://api.docs.extended.exchange/#get-spot-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
}));
self.load_markets(&[]).await;
let mut response: Value = self.v1_private_get_user_spot_balances(&[params.clone()]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "accountId": 123,
// "asset": "USDC",
// "balance": "13500",
// "indexPrice": "1",
// "notionalValue": "13500",
// "contributionFactor": "1",
// "equityContribution": "13500",
// "availableToWithdraw": "100",
// "updatedAt": 1701563440
// },
// {
// "accountId": 123,
// "asset": "BTC",
// "balance": "0.5",
// "indexPrice": "65000",
// "notionalValue": "32500",
// "contributionFactor": "0.95",
// "equityContribution": "30875",
// "availableToWithdraw": "0.5",
// "updatedAt": 1701563440
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_balance(data.clone());
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 i: Value = Value::Int(0);
let mut __for_first_662: bool = true;
while { if !__for_first_662 { i = add(&i, &Value::Int(1)); } __for_first_662 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut balance: Value = self.safe_dict(response.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "availableToWithdraw", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "balance", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name extended#fetchAccount
* @description fetch the current authenticated sub-account
* @see https://api.docs.extended.exchange/#get-account-details
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [account structure]{@link https://docs.ccxt.com/?id=account-structure}
*/
pub async fn fetch_account(&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.v1_private_get_user_account_info(&[params.clone()]).await;
//
// {
// "status": "OK",
// "data": {
// "accountId": 3342,
// "description": "Main account",
// "accountIndex": 0,
// "status": "ACTIVE",
// "l2Key": "0x...",
// "l2Vault": "500343",
// "bridgeStarknetAddress": "0x...",
// "apiKeys": [
// "..."
// ],
// "accountIndexForKeyGeneration": 0
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_account(data.clone());
Value::Null
}
/*
* @method
* @name extended#fetchAccounts
* @description fetch the current authenticated sub-account, extended private endpoints only return records for the authenticated sub-account
* @see https://api.docs.extended.exchange/#get-sub-accounts
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [account structures]{@link https://docs.ccxt.com/?id=account-structure}
*/
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 response: Value = self.v1_private_get_user_accounts(&[params.clone()]).await;
//
// {
// "status": "OK",
// "data": [{
// "accountId": 123,
// "description": "Main",
// "accountIndex": 0,
// "status": "ACTIVE",
// "l2Key": "0x123",
// "l2Vault": "321",
// "bridgeStarknetAddress": "0xabc",
// "accountIndexForKeyGeneration": 0
// }, {
// "accountId": 999,
// "description": "Vault Balance",
// "accountIndex": 1001,
// "status": "ACTIVE",
// "l2Key": "0x123",
// "l2Vault": "999",
// "bridgeStarknetAddress": "0xabc",
// "accountIndexForKeyGeneration": 0
// }
// ]}
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_accounts(data.clone(), &[]);
Value::Null
}
pub fn parse_account(&self, mut account: Value) -> Value {
let mut accountIndex: Value = self.safe_integer_k(account.clone(), "accountIndex", &[]);
let mut type_var: Value = Value::Null;
if !is_equal(&accountIndex, &Value::Null) {
type_var = ternary(is_true(&(is_equal(&accountIndex, &Value::Int(0)))), Value::Str("main".to_string()), Value::Str("subaccount".to_string()));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(account.clone(), Value::Str("accountId".to_string()), Value::Str("id".to_string()), &[]));
m.insert("type".to_string(), type_var.clone());
m.insert("code".to_string(), Value::Null);
m.insert("info".to_string(), account.clone());
m
});
Value::Null
}
/*
* @method
* @name extended#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history
* @param {string} [code] unified currency code
* @param {int} [since] timestamp in ms of the earliest ledger entry
* @param {int} [limit] max number of ledger entries to return
* @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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [ledger structures]{@link https://docs.ccxt.com/?id=ledger}
*/
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
}));
self.load_markets(&[]).await;
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchLedger".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchLedger".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(50)]).await;
}
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_user_asset_operations(&[__ws_arg_9]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut pagination: Value = self.safe_dict_k(response.clone(), "pagination", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cursor: Value = self.safe_string_k(pagination.clone(), "cursor", &[]);
let mut result: Value = Value::List(vec![]);
let mut dataLength: Value = get_array_length(&data);
{
let mut i: Value = Value::Int(0);
let mut __for_first_663: bool = true;
while { if !__for_first_663 { i = add(&i, &Value::Int(1)); } __for_first_663 = false; is_less_than(&i, &dataLength) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
if is_true(&(!is_equal(&cursor, &Value::Null))) && is_true(&(is_equal(&i, &subtract(&dataLength, &Value::Int(1))))) {
entry = self.extend(entry.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cursor".to_string(), cursor.clone());
m
})]);
}
append_to_array(&mut result, entry.clone());
}
}
return self.parse_ledger(result.clone(), &[currency.clone(), since.clone(), limit.clone()]);
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);
//
// {
// "id": "1951255127004282880",
// "type": "TRANSFER",
// "status": "COMPLETED",
// "amount": "-3.0000000000000000",
// "fee": "0",
// "asset": 1,
// "time": 1754050449502,
// "accountId": 100009,
// "counterpartyAccountId": 100023
// }
//
let mut timestamp: Value = self.safe_integer_k(item.clone(), "time", &[]);
let mut assetId: Value = self.safe_string_k(item.clone(), "asset", &[]);
let mut code: Value = self.get_extended_currency_code_by_id(assetId.clone(), &[currency.clone()]);
let mut ledgerCurrency: Value = self.safe_currency(code.clone(), &[currency.clone()]);
let mut amountString: Value = self.safe_string_k(item.clone(), "amount", &[]);
let mut direction: Value = Value::Null;
if !is_equal(&amountString, &Value::Null) {
direction = ternary(is_true(&crate::precise::Precise::stringLt(&amountString, &Value::Str("0".to_string()))), Value::Str("out".to_string()), Value::Str("in".to_string()));
}
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string_k(item.clone(), "fee", &[]);
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), self.parse_number(crate::precise::Precise::stringAbs(&feeCost), &[]));
m
});
}
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("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("direction".to_string(), direction.clone());
m.insert("account".to_string(), self.safe_string_k(item.clone(), "accountId", &[]));
m.insert("referenceId".to_string(), self.safe_string_k(item.clone(), "transactionHash", &[]));
m.insert("referenceAccount".to_string(), self.safe_string_k(item.clone(), "counterpartyAccountId", &[]));
m.insert("type".to_string(), self.parse_transaction_type(self.safe_string_k(item.clone(), "type", &[])));
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), ternary(is_true(&(is_equal(&amountString, &Value::Null))), Value::Null, self.parse_number(crate::precise::Precise::stringAbs(&amountString), &[])));
m.insert("before".to_string(), Value::Null);
m.insert("after".to_string(), Value::Null);
m.insert("status".to_string(), self.parse_transaction_status(self.safe_string_k(item.clone(), "status", &[])));
m.insert("fee".to_string(), fee.clone());
m
}), &[ledgerCurrency.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchTransactions
* @description fetch history of deposits, withdrawals, and transfers
* @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history
* @param {string} [code] unified currency code
* @param {int} [since] the earliest time in ms to fetch transactions for
* @param {int} [limit] the maximum number of transaction 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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {Transaction[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_transactions(&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
}));
self.load_markets(&[]).await;
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTransactions".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchTransactions".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(50)]).await;
}
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_user_asset_operations(&[__ws_arg_10]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "id": "1951255127004282880",
// "type": "TRANSFER",
// "status": "COMPLETED",
// "amount": "-3.0000000000000000",
// "fee": "0",
// "asset": 1,
// "time": 1754050449502,
// "accountId": 100009,
// "counterpartyAccountId": 100023
// }
// ],
// "pagination": {
// "cursor": 1951255127004282880,
// "count": 1
// }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut pagination: Value = self.safe_dict_k(response.clone(), "pagination", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cursor: Value = self.safe_string_k(pagination.clone(), "cursor", &[]);
let mut result: Value = Value::List(vec![]);
let mut dataLength: Value = get_array_length(&data);
{
let mut i: Value = Value::Int(0);
let mut __for_first_664: bool = true;
while { if !__for_first_664 { i = add(&i, &Value::Int(1)); } __for_first_664 = false; is_less_than(&i, &dataLength) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
if is_true(&(!is_equal(&cursor, &Value::Null))) && is_true(&(is_equal(&i, &subtract(&dataLength, &Value::Int(1))))) {
entry = self.extend(entry.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cursor".to_string(), cursor.clone());
m
})]);
}
append_to_array(&mut result, entry.clone());
}
}
return self.parse_transactions(result.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchDeposits
* @description fetch all deposits made to an account
* @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-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 deposit 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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {Transaction[]} 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 __ws_arg_11 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("DEPOSIT".to_string()));
m
}), &[params.clone()]);
return self.fetch_transactions(&[code.clone(), since.clone(), limit.clone(), __ws_arg_11]).await;
Value::Null
}
/*
* @method
* @name extended#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-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 withdrawal 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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {Transaction[]} 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 __ws_arg_12 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("WITHDRAWAL".to_string()));
m
}), &[params.clone()]);
return self.fetch_transactions(&[code.clone(), since.clone(), limit.clone(), __ws_arg_12]).await;
Value::Null
}
/*
* @method
* @name extended#withdraw
* @description make a Starknet withdrawal
* @see https://api.docs.extended.exchange/#withdrawals
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the Starknet address to withdraw to
* @param {string} tag unused
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.chainId] only STRK is supported
* @param {int} [params.settlementExpiration] settlement expiration timestamp in seconds, defaults to now + 14 days + 60 seconds
* @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 tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.check_required_credentials(&[]);
self.load_markets(&[]).await;
let mut currency: Value = self.currency(code.clone());
let mut chainId: Value = self.safe_string_upper2(params.clone(), Value::Str("chainId".to_string()), Value::Str("network".to_string()), &[Value::Str("STRK".to_string())]);
if !is_equal(&chainId, &Value::Str("STRK".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" withdraw() only supports Starknet withdrawals with chainId STRK".to_string()))));
}
if is_less_than_or_equal(&get_array_length(&address), &Value::Int(42)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" withdraw() requires a Starknet address for STRK withdrawals, EVM withdrawals require the bridge quote flow".to_string()))));
}
let mut account: Value = self.fetch_extended_account(&[]).await;
let mut amountString: Value = self.currency_to_precision(code.clone(), amount.clone(), &[]);
let mut accountId: Value = self.safe_string_k(account.clone(), "accountId", &[]);
let mut settlement: Value = self.create_withdrawal_settlement_data(address.clone(), amountString.clone(), currency.clone(), account.clone(), &[params.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("accountId".to_string(), accountId.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("chainId".to_string(), chainId.clone());
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("settlement".to_string(), settlement.clone());
m
});
params = self.omit(params.clone(), Value::List(vec![Value::Str("chainId".to_string()), Value::Str("network".to_string()), Value::Str("settlementExpiration".to_string()), Value::Str("nonce".to_string()), Value::Str("recipient".to_string()), Value::Str("positionId".to_string()), Value::Str("l2Vault".to_string()), Value::Str("collateralId".to_string()), Value::Str("resolution".to_string())]), &[]);
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_post_user_withdrawal(&[__ws_arg_13]).await;
//
// {
// "status": "OK",
// "data": 1820796462590083072
// }
//
let mut now: Value = self.milliseconds();
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), self.safe_string_k(response.clone(), "data", &[]));
m.insert("txid".to_string(), Value::Null);
m.insert("timestamp".to_string(), now.clone());
m.insert("datetime".to_string(), self.iso8601(now.clone()));
m.insert("address".to_string(), address.clone());
m.insert("addressFrom".to_string(), Value::Null);
m.insert("addressTo".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tagTo".to_string(), tag.clone());
m.insert("type".to_string(), Value::Str("withdrawal".to_string()));
m.insert("amount".to_string(), self.parse_number(amountString.clone(), &[]));
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("code".to_string())));
m.insert("status".to_string(), Value::Str("pending".to_string()));
m.insert("updated".to_string(), now.clone());
m.insert("fee".to_string(), Value::Null);
m.insert("network".to_string(), chainId.clone());
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Bool(false));
m
});
Value::Null
}
/*
* @method
* @name extended#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history
* @param {string} [code] unified currency code
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfer 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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {TransferEntry[]} 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
}));
self.load_markets(&[]).await;
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTransfers".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchTransfers".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(50)]).await;
}
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("TRANSFER".to_string()));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_user_asset_operations(&[__ws_arg_14]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut pagination: Value = self.safe_dict_k(response.clone(), "pagination", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cursor: Value = self.safe_string_k(pagination.clone(), "cursor", &[]);
let mut result: Value = Value::List(vec![]);
let mut dataLength: Value = get_array_length(&data);
{
let mut i: Value = Value::Int(0);
let mut __for_first_665: bool = true;
while { if !__for_first_665 { i = add(&i, &Value::Int(1)); } __for_first_665 = false; is_less_than(&i, &dataLength) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
if is_true(&(!is_equal(&cursor, &Value::Null))) && is_true(&(is_equal(&i, &subtract(&dataLength, &Value::Int(1))))) {
entry = self.extend(entry.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cursor".to_string(), cursor.clone());
m
})]);
}
append_to_array(&mut result, entry.clone());
}
}
return self.parse_transfers(result.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name extended#transfer
* @description transfer collateral between sub-accounts associated with the same wallet
* @see https://api.docs.extended.exchange/#create-transfer
* @param {string} code unified currency code
* @param {float} amount the amount to transfer
* @param {string} fromAccount source account id, defaults to the authenticated account id
* @param {string} toAccount destination account id
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.toVault destination account L2 vault
* @param {string} params.toL2Key destination account L2 public key
* @param {int} [params.settlementExpiration] settlement expiration timestamp in seconds, defaults to now + 21 days
* @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
}));
self.check_required_credentials(&[]);
self.load_markets(&[]).await;
let mut currency: Value = self.currency(code.clone());
let mut account: Value = self.fetch_extended_account(&[]).await;
let mut currentAccountId: Value = self.safe_string_k(account.clone(), "accountId", &[Value::Str("".to_string())]);
if is_equal(&fromAccount, &Value::Null) {
fromAccount = currentAccountId.clone();
} else if !is_equal(&fromAccount, ¤tAccountId) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" transfer() can only transfer from the authenticated account".to_string()))));
}
let mut toVault: Value = self.safe_string2(params.clone(), Value::Str("toVault".to_string()), Value::Str("receiverPositionId".to_string()), &[]);
let mut toL2Key: Value = self.safe_string2(params.clone(), Value::Str("toL2Key".to_string()), Value::Str("receiverPublicKey".to_string()), &[]);
if is_true(&(is_equal(&toAccount, &Value::Null))) || is_true(&(is_equal(&toVault, &Value::Null))) || is_true(&(is_equal(&toL2Key, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" transfer() requires a toAccount argument and params[\"toVault\"] and params[\"toL2Key\"]".to_string()))));
}
let mut amountString: Value = self.currency_to_precision(code.clone(), amount.clone(), &[]);
let mut settlement: Value = self.create_transfer_settlement_data(amountString.clone(), currency.clone(), account.clone(), toVault.clone(), toL2Key.clone(), &[params.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fromAccount".to_string(), fromAccount.clone());
m.insert("toAccount".to_string(), toAccount.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("transferredAsset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("settlement".to_string(), settlement.clone());
m
});
params = self.omit(params.clone(), Value::List(vec![Value::Str("fromVault".to_string()), Value::Str("senderPositionId".to_string()), Value::Str("fromL2Key".to_string()), Value::Str("senderPublicKey".to_string()), Value::Str("toVault".to_string()), Value::Str("receiverPositionId".to_string()), Value::Str("toL2Key".to_string()), Value::Str("receiverPublicKey".to_string()), Value::Str("settlementExpiration".to_string()), Value::Str("nonce".to_string()), Value::Str("assetId".to_string()), Value::Str("collateralId".to_string()), Value::Str("resolution".to_string())]), &[]);
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_post_user_transfer(&[__ws_arg_15]).await;
//
// {
// "status": "OK",
// "data": {
// "validSignature": true,
// "id": 1820778187672010752
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut validSignature: Value = self.safe_bool_k(data.clone(), "validSignature", &[]);
let mut now: Value = self.milliseconds();
let mut status: Value = Value::Str("pending".to_string());
if !is_equal(&validSignature, &Value::Null) {
status = ternary(is_true(&validSignature), Value::Str("ok".to_string()), Value::Str("failed".to_string()));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), self.safe_string_k(data.clone(), "id", &[]));
m.insert("timestamp".to_string(), now.clone());
m.insert("datetime".to_string(), self.iso8601(now.clone()));
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("code".to_string())));
m.insert("amount".to_string(), self.parse_number(amountString.clone(), &[]));
m.insert("fromAccount".to_string(), fromAccount.clone());
m.insert("toAccount".to_string(), toAccount.clone());
m.insert("status".to_string(), status.clone());
m
});
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Value = self.safe_integer_k(transfer.clone(), "time", &[]);
let mut assetId: Value = self.safe_string_k(transfer.clone(), "asset", &[]);
let mut code: Value = self.get_extended_currency_code_by_id(assetId.clone(), &[currency.clone()]);
let mut amountString: Value = self.safe_string_k(transfer.clone(), "amount", &[]);
let mut amount: Value = ternary(is_true(&(is_equal(&amountString, &Value::Null))), Value::Null, self.parse_number(crate::precise::Precise::stringAbs(&amountString), &[]));
let mut accountId: Value = self.safe_string_k(transfer.clone(), "accountId", &[]);
let mut counterpartyAccountId: Value = self.safe_string_k(transfer.clone(), "counterpartyAccountId", &[]);
let mut fromAccount: Value = accountId.clone();
let mut toAccount: Value = counterpartyAccountId.clone();
if is_true(&(!is_equal(&amountString, &Value::Null))) && !is_true(&crate::precise::Precise::stringLt(&amountString, &Value::Str("0".to_string()))) {
fromAccount = counterpartyAccountId.clone();
toAccount = accountId.clone();
}
let mut validSignature: Value = self.safe_bool_k(transfer.clone(), "validSignature", &[]);
let mut status: Value = Value::Null;
if !is_equal(&validSignature, &Value::Null) {
status = ternary(is_true(&validSignature), Value::Str("ok".to_string()), Value::Str("failed".to_string()));
} else {
status = self.parse_transaction_status(self.safe_string_k(transfer.clone(), "status", &[]));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transfer.clone());
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.clone()));
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("fromAccount".to_string(), fromAccount.clone());
m.insert("toAccount".to_string(), toAccount.clone());
m.insert("status".to_string(), status.clone());
m
});
Value::Null
}
pub fn get_extended_currency_code_by_id(&self, mut assetId: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
if is_equal(&assetId, &Value::Null) {
return self.safe_string_k(currency.clone(), "code", &[]);
}
let mut currenciesByNumericId: Value = self.safe_dict_k(self.options.clone(), "currenciesByNumericId", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencyByNumericId: Value = self.safe_dict(currenciesByNumericId.clone(), assetId.clone(), &[]);
if !is_equal(¤cyByNumericId, &Value::Null) {
return self.safe_string_k(currencyByNumericId.clone(), "code", &[]);
}
if !is_equal(¤cy, &Value::Null) {
return get_value(¤cy, &Value::Str("code".to_string()));
}
let mut code: Value = self.safe_currency_code(assetId.clone(), &[]);
if is_equal(&code, &Value::Str("USD".to_string())) {
code = Value::Str("USDC".to_string());
}
return code;
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CREATED".to_string(), Value::Str("pending".to_string()));
m.insert("IN_PROGRESS".to_string(), Value::Str("pending".to_string()));
m.insert("COMPLETED".to_string(), Value::Str("ok".to_string()));
m.insert("REJECTED".to_string(), Value::Str("failed".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transaction_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("DEPOSIT".to_string(), Value::Str("deposit".to_string()));
m.insert("WITHDRAWAL".to_string(), Value::Str("withdrawal".to_string()));
m.insert("TRANSFER".to_string(), Value::Str("transfer".to_string()));
m.insert("CLAIM".to_string(), Value::Str("claim".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "id": "1951255127004282880",
// "type": "TRANSFER",
// "status": "COMPLETED",
// "amount": "-3.0000000000000000",
// "fee": "0",
// "asset": 1,
// "time": 1754050449502,
// "accountId": 100009,
// "counterpartyAccountId": 100023
// }
//
let mut timestamp: Value = self.safe_integer_k(transaction.clone(), "time", &[]);
let mut assetId: Value = self.safe_string_k(transaction.clone(), "asset", &[]);
let mut code: Value = self.get_extended_currency_code_by_id(assetId.clone(), &[currency.clone()]);
let mut amountString: Value = self.safe_string_k(transaction.clone(), "amount", &[]);
let mut amount: Value = ternary(is_true(&(is_equal(&amountString, &Value::Null))), Value::Null, self.parse_number(crate::precise::Precise::stringAbs(&amountString), &[]));
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string_k(transaction.clone(), "fee", &[]);
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), self.parse_number(crate::precise::Precise::stringAbs(&feeCost), &[]));
m
});
}
let mut transactionType: Value = self.parse_transaction_type(self.safe_string_k(transaction.clone(), "type", &[]));
let mut network: Value = self.safe_string_k(transaction.clone(), "chain", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), self.safe_string_k(transaction.clone(), "id", &[]));
m.insert("txid".to_string(), self.safe_string_k(transaction.clone(), "transactionHash", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("address".to_string(), Value::Null);
m.insert("addressFrom".to_string(), Value::Null);
m.insert("addressTo".to_string(), Value::Null);
m.insert("tag".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("type".to_string(), transactionType.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), self.parse_transaction_status(self.safe_string_k(transaction.clone(), "status", &[])));
m.insert("updated".to_string(), timestamp.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("network".to_string(), network.clone());
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Bool((is_equal(&transactionType, &Value::Str("transfer".to_string())))));
m
});
Value::Null
}
/*
* @method
* @name extended#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://api.docs.extended.exchange/#get-fees
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.builderId] builder client id
* @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
}));
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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_user_fees(&[__ws_arg_16]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "market": "BTC-USD",
// "makerFeeRate": "0.00000",
// "takerFeeRate": "0.00025",
// "builderFeeRate": "0.0001"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut first: Value = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_trading_fee(first.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://api.docs.extended.exchange/#get-fees
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.market] exchange market id
* @param {string} [params.builderId] builder client id
* @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
}));
self.load_markets(&[]).await;
let mut response: Value = self.v1_private_get_user_fees(&[params.clone()]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "market": "BTC-USD",
// "makerFeeRate": "0.00000",
// "takerFeeRate": "0.00025",
// "builderFeeRate": "0.0001"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_666: bool = true;
while { if !__for_first_666 { i = add(&i, &Value::Int(1)); } __for_first_666 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut fee: Value = self.safe_dict(data.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut parsed: Value = self.parse_trading_fee(fee.clone(), &[]);
let mut symbol: Value = self.safe_string_k(parsed.clone(), "symbol", &[]);
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut result, &symbol, parsed.clone());
}
}
}
return result;
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);
//
// {
// "market": "BTC-USD",
// "makerFeeRate": "0.00000",
// "takerFeeRate": "0.00025",
// "builderFeeRate": "0.0001"
// }
//
let mut marketId: Value = self.safe_string_k(fee.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("maker".to_string(), self.safe_number_k(fee.clone(), "makerFeeRate", &[]));
m.insert("taker".to_string(), self.safe_number_k(fee.clone(), "takerFeeRate", &[]));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name extended#fetchLeverage
* @description fetch the set leverage for a market
* @see https://api.docs.extended.exchange/#get-leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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
}));
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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_user_leverage(&[__ws_arg_17]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "market": "SOL-USD",
// "leverage": "10"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_leverage(self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#setLeverage
* @description set the level of leverage for a market
* @see https://api.docs.extended.exchange/#update-leverage
* @param {int} leverage the rate of leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setLeverage() requires a symbol argument".to_string()))));
}
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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("leverage".to_string(), self.number_to_string(leverage.clone()));
m
});
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_patch_user_leverage(&[__ws_arg_18]).await;
//
// {
// "status": "OK",
// "data": {}
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_leverage(data.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "market": "BTC-USD",
// "leverage": "10"
// }
//
let mut marketId: Value = self.safe_string_k(leverage.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut leverageValue: Value = self.safe_number_k(leverage.clone(), "leverage", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), leverage.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("marginMode".to_string(), Value::Null);
m.insert("longLeverage".to_string(), leverageValue.clone());
m.insert("shortLeverage".to_string(), leverageValue.clone());
m
});
Value::Null
}
/*
* @method
* @name extended#fetchPositions
* @description fetch all open positions
* @see https://api.docs.extended.exchange/#get-positions
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Position[]} a list of [position structures]{@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
}));
self.load_markets(&[]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbols, &Value::Null) {
let mut marketIds: Value = self.market_ids(&[symbols.clone()]);
add_element_to_object(&mut request, &Value::Str("market".to_string()), marketIds.clone());
}
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_user_positions(&[__ws_arg_19]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "id": 1,
// "accountId": 1,
// "market": "BTC-USD",
// "side": "LONG",
// "leverage": "10",
// "size": "0.1",
// "value": "4000",
// "openPrice": "39000",
// "markPrice": "40000",
// "liquidationPrice": "38200",
// "margin": "20",
// "unrealisedPnl": "1000",
// "realisedPnl": "1.2",
// "tpTriggerPrice": "41000",
// "tpLimitPrice": "41500",
// "slTriggerPrice": "39500",
// "slLimitPrice": "39000",
// "adl": "2.5",
// "maxPositionSize": "0.2",
// "createdAt": 1701563440000,
// "updatedAt": 1701563440000
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_positions(data.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchPosition
* @description fetch data on an open position
* @see https://api.docs.extended.exchange/#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
}));
let mut positions: Value = self.fetch_positions(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
return self.safe_dict(positions.clone(), Value::Int(0), &[]);
Value::Null
}
/*
* @method
* @name extended#fetchPositionsHistory
* @description fetch historical positions
* @see https://api.docs.extended.exchange/#get-positions-history
* @param {string[]|undefined} symbols list of unified market symbols
* @param {int} [since] the earliest time in ms to fetch positions for
* @param {int} [limit] the maximum number of position 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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {Position[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = 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
}));
self.load_markets(&[]).await;
if is_string(&symbols) {
symbols = Value::List(vec![symbols.clone()]);
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchPositionsHistory".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchPositionsHistory".to_string()), &[symbols.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(10000)]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbols, &Value::Null) {
let mut marketIds: Value = self.market_ids(&[symbols.clone()]);
add_element_to_object(&mut request, &Value::Str("market".to_string()), marketIds.clone());
}
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_user_positions_history(&[__ws_arg_20]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "id": 1784963886257016832,
// "accountId": 1,
// "market": "BTC-USD",
// "side": "LONG",
// "exitType": "TRADE",
// "leverage": "10",
// "size": "0.1",
// "maxPositionSize": "0.2",
// "openPrice": "39000",
// "exitPrice": "40000",
// "realisedPnl": "10",
// "createdTime": 1701563440000,
// "closedTime": 1701567040000
// }
// ],
// "pagination": {
// "cursor": 1784963886257016832,
// "count": 1
// }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut pagination: Value = self.safe_dict_k(response.clone(), "pagination", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cursor: Value = self.safe_string_k(pagination.clone(), "cursor", &[]);
let mut result: Value = Value::List(vec![]);
let mut dataLength: Value = get_array_length(&data);
{
let mut i: Value = Value::Int(0);
let mut __for_first_667: bool = true;
while { if !__for_first_667 { i = add(&i, &Value::Int(1)); } __for_first_667 = false; is_less_than(&i, &dataLength) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
if is_true(&(!is_equal(&cursor, &Value::Null))) && is_true(&(is_equal(&i, &subtract(&dataLength, &Value::Int(1))))) {
entry = self.extend(entry.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cursor".to_string(), cursor.clone());
m
})]);
}
append_to_array(&mut result, entry.clone());
}
}
let mut positions: Value = self.parse_positions(result.clone(), &[symbols.clone()]);
return self.filter_by_since_limit(positions.clone(), &[since.clone(), limit.clone(), Value::Str("timestamp".to_string())]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "id": 1,
// "accountId": 1,
// "market": "BTC-USD",
// "side": "LONG",
// "leverage": "10",
// "size": "0.1",
// "value": "4000",
// "openPrice": "39000",
// "markPrice": "40000",
// "liquidationPrice": "38200",
// "margin": "20",
// "unrealisedPnl": "1000",
// "realisedPnl": "1.2",
// "tpTriggerPrice": "41000",
// "tpLimitPrice": "41500",
// "slTriggerPrice": "39500",
// "slLimitPrice": "39000",
// "adl": "2.5",
// "maxPositionSize": "0.2",
// "createdAt": 1701563440000,
// "updatedAt": 1701563440000
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer2(position.clone(), Value::Str("createdAt".to_string()), Value::Str("createdTime".to_string()), &[]);
let mut lastUpdateTimestamp: Value = self.safe_integer2(position.clone(), Value::Str("updatedAt".to_string()), Value::Str("updatedTime".to_string()), &[]);
lastUpdateTimestamp = self.safe_integer_k(position.clone(), "closedTime", &[lastUpdateTimestamp.clone()]);
let mut side: Value = self.safe_string_lower(position.clone(), Value::Str("side".to_string()), &[]);
let mut margin: Value = self.safe_string_k(position.clone(), "margin", &[]);
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), self.safe_string_k(position.clone(), "id", &[]));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp.clone());
m.insert("initialMargin".to_string(), margin.clone());
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.safe_string_k(position.clone(), "openPrice", &[]));
m.insert("notional".to_string(), self.safe_string_k(position.clone(), "value", &[]));
m.insert("leverage".to_string(), self.safe_string_k(position.clone(), "leverage", &[]));
m.insert("unrealizedPnl".to_string(), self.safe_string_k(position.clone(), "unrealisedPnl", &[]));
m.insert("realizedPnl".to_string(), self.safe_string_k(position.clone(), "realisedPnl", &[]));
m.insert("contracts".to_string(), self.safe_string_k(position.clone(), "size", &[]));
m.insert("contractSize".to_string(), self.safe_string_k(market.clone(), "contractSize", &[]));
m.insert("marginRatio".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), self.safe_string_k(position.clone(), "liquidationPrice", &[]));
m.insert("markPrice".to_string(), self.safe_string_k(position.clone(), "markPrice", &[]));
m.insert("lastPrice".to_string(), self.safe_string_k(position.clone(), "exitPrice", &[]));
m.insert("collateral".to_string(), margin.clone());
m.insert("marginMode".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("percentage".to_string(), Value::Null);
m.insert("hedged".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), self.safe_string_k(position.clone(), "slTriggerPrice", &[]));
m.insert("takeProfitPrice".to_string(), self.safe_string_k(position.clone(), "tpTriggerPrice", &[]));
m
}));
Value::Null
}
pub fn get_extended_stark_amount(&self, mut amount: Value, mut resolution: Value, optional_args: &[Value]) -> Value {
let mut roundUp = get_arg(optional_args, 0, Value::Bool(false));
let mut resolutionString: Value = self.number_to_string(resolution.clone());
let mut precise: Value = crate::precise::Precise::stringMul(&amount, &resolutionString);
let mut result: Value = self.decimal_to_precision(precise.clone(), Value::Int(crate::runtime::TRUNCATE), Value::Int(0), &[Value::Int(crate::runtime::DECIMAL_PLACES), Value::Int(crate::runtime::NO_PADDING)]);
if is_true(&roundUp) && is_true(&crate::precise::Precise::stringGt(&precise, &result)) {
result = crate::precise::Precise::stringAdd(&result, &Value::Str("1".to_string()));
}
return result;
Value::Null
}
pub async fn fetch_extended_account(&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 account: Value = self.safe_dict_k(self.options.clone(), "account", &[]);
if !is_equal(&account, &Value::Null) {
return account;
}
let mut accountData: Value = self.fetch_account(&[params.clone()]).await;
account = get_value(&accountData, &Value::Str("info".to_string()));
add_element_to_object(&mut self.options, &Value::Str("account".to_string()), account.clone());
return account;
Value::Null
}
pub fn create_order_settlement_data(&self, mut isBuy: Value, mut amountString: Value, mut priceString: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut totalFee: Value = self.safe_string_k(params.clone(), "totalFee", &[]);
let mut settlementExpiration: Value = self.safe_integer_k(params.clone(), "settlementExpiration", &[]);
let mut nonce: Value = self.safe_integer_k(params.clone(), "nonce", &[]);
let mut starkKey: Value = self.safe_string_k(params.clone(), "starkKey", &[]);
let mut collateralPosition: Value = self.safe_string_k(params.clone(), "collateralPosition", &[]);
let mut syntheticId: Value = self.safe_string_k(params.clone(), "syntheticId", &[]);
let mut collateralId: Value = self.safe_string_k(params.clone(), "collateralId", &[]);
let mut syntheticResolution: Value = self.safe_integer_k(params.clone(), "syntheticResolution", &[]);
let mut collateralResolution: Value = self.safe_integer_k(params.clone(), "collateralResolution", &[]);
let mut quoteAmount: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
let mut baseRoundUp: Value = isBuy.clone();
let mut quoteRoundUp: Value = isBuy.clone();
let mut baseAmount: Value = self.get_extended_stark_amount(amountString.clone(), syntheticResolution.clone(), &[baseRoundUp.clone()]);
let mut collateralAmount: Value = self.get_extended_stark_amount(quoteAmount.clone(), collateralResolution.clone(), &[quoteRoundUp.clone()]);
if is_true(&isBuy) {
collateralAmount = crate::precise::Precise::stringNeg(&collateralAmount);
} else {
baseAmount = crate::precise::Precise::stringNeg(&baseAmount);
}
let mut feeAmount: Value = self.get_extended_stark_amount(crate::precise::Precise::stringMul(&totalFee, "eAmount), collateralResolution.clone(), &[Value::Bool(true)]);
let mut settlement: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("starkKey".to_string(), starkKey.clone());
m.insert("collateralPosition".to_string(), collateralPosition.clone());
m.insert("baseAssetId".to_string(), syntheticId.clone());
m.insert("baseAmount".to_string(), baseAmount.clone());
m.insert("quoteAssetId".to_string(), collateralId.clone());
m.insert("quoteAmount".to_string(), collateralAmount.clone());
m.insert("feeAssetId".to_string(), collateralId.clone());
m.insert("feeAmount".to_string(), feeAmount.clone());
m.insert("expiration".to_string(), self.number_to_string(settlementExpiration.clone()));
m.insert("salt".to_string(), nonce.clone());
m
});
let mut msgHash: Value = self.get_extended_order_msg_hash(settlement.clone());
let mut sig: Value = json_parse(&self.extended_starknet_sign(msgHash.clone(), self.privateKey.clone()));
let mut r: Value = self.get_extended_signature_hex(get_value(&sig, &Value::Int(0)));
let mut s: Value = self.get_extended_signature_hex(get_value(&sig, &Value::Int(1)));
add_element_to_object(&mut settlement, &Value::Str("r".to_string()), r.clone());
add_element_to_object(&mut settlement, &Value::Str("s".to_string()), s.clone());
return settlement;
Value::Null
}
pub fn create_withdrawal_settlement_data(&self, mut address: Value, mut amountString: Value, mut currency: Value, mut account: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut now: Value = self.milliseconds();
let mut settlementExpiration: Value = self.safe_integer_k(params.clone(), "settlementExpiration", &[add(&add(&self.parse_to_int(divide(&(add(&now, &Value::Int(999))), &Value::Int(1000))), &Value::Int(1209600)), &Value::Int(60))]);
let mut nonce: Value = self.safe_integer_k(params.clone(), "nonce", &[self.nonce()]);
let mut positionId: Value = self.safe_string2(params.clone(), Value::Str("positionId".to_string()), Value::Str("l2Vault".to_string()), &[self.safe_string_k(account.clone(), "l2Vault", &[])]);
let mut recipient: Value = self.safe_string_k(params.clone(), "recipient", &[address.clone()]);
let mut currencyInfo: Value = self.safe_dict_k(currency.clone(), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut collateralId: Value = self.safe_string_k(params.clone(), "collateralId", &[self.safe_string2(currencyInfo.clone(), Value::Str("starkexId".to_string()), Value::Str("l1Id".to_string()), &[])]);
let mut resolution: Value = self.safe_integer_k(params.clone(), "resolution", &[self.safe_value2(currencyInfo.clone(), Value::Str("starkexResolution".to_string()), Value::Str("l1Resolution".to_string()), &[])]);
let mut starkKey: Value = self.safe_string_k(account.clone(), "l2Key", &[]);
if is_true(&(is_equal(&positionId, &Value::Null))) || is_true(&(is_equal(&collateralId, &Value::Null))) || is_true(&(is_equal(&resolution, &Value::Null))) || is_true(&(is_equal(&starkKey, &Value::Null))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" withdraw() requires currency starkexId/starkexResolution, account l2Vault and account l2Key".to_string()))));
}
let mut amount: Value = self.get_extended_stark_amount(amountString.clone(), resolution.clone(), &[]);
let mut settlement: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("recipient".to_string(), recipient.clone());
m.insert("positionId".to_string(), positionId.clone());
m.insert("collateralId".to_string(), collateralId.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("expiration".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("seconds".to_string(), settlementExpiration.clone());
m
}));
m.insert("salt".to_string(), nonce.clone());
m
});
let mut msgHash: Value = self.get_extended_withdrawal_msg_hash(settlement.clone(), starkKey.clone());
let mut sig: Value = json_parse(&self.extended_starknet_sign(msgHash.clone(), self.privateKey.clone()));
add_element_to_object(&mut settlement, &Value::Str("signature".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("r".to_string(), self.get_extended_signature_hex(get_value(&sig, &Value::Int(0))));
m.insert("s".to_string(), self.get_extended_signature_hex(get_value(&sig, &Value::Int(1))));
m
}));
return settlement;
Value::Null
}
pub fn create_transfer_settlement_data(&self, mut amountString: Value, mut currency: Value, mut account: Value, mut toVault: Value, mut toL2Key: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut now: Value = self.milliseconds();
let mut settlementExpiration: Value = self.safe_integer_k(params.clone(), "settlementExpiration", &[add(&self.parse_to_int(divide(&(add(&now, &Value::Int(999))), &Value::Int(1000))), &Value::Int(1814400))]);
let mut nonce: Value = self.safe_integer_k(params.clone(), "nonce", &[self.nonce()]);
let mut fromVault: Value = self.safe_string2(params.clone(), Value::Str("fromVault".to_string()), Value::Str("senderPositionId".to_string()), &[self.safe_string_k(account.clone(), "l2Vault", &[])]);
let mut fromL2Key: Value = self.safe_string2(params.clone(), Value::Str("fromL2Key".to_string()), Value::Str("senderPublicKey".to_string()), &[self.safe_string_k(account.clone(), "l2Key", &[])]);
let mut currencyInfo: Value = self.safe_dict_k(currency.clone(), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut collateralId: Value = self.safe_string2(params.clone(), Value::Str("assetId".to_string()), Value::Str("collateralId".to_string()), &[self.safe_string2(currencyInfo.clone(), Value::Str("starkexId".to_string()), Value::Str("l1Id".to_string()), &[])]);
let mut resolution: Value = self.safe_integer_k(params.clone(), "resolution", &[self.safe_value2(currencyInfo.clone(), Value::Str("starkexResolution".to_string()), Value::Str("l1Resolution".to_string()), &[])]);
if is_true(&(is_equal(&fromVault, &Value::Null))) || is_true(&(is_equal(&fromL2Key, &Value::Null))) || is_true(&(is_equal(&collateralId, &Value::Null))) || is_true(&(is_equal(&resolution, &Value::Null))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" transfer() requires currency starkexId/starkexResolution, account l2Vault and account l2Key".to_string()))));
}
let mut transferAmount: Value = self.get_extended_stark_amount(amountString.clone(), resolution.clone(), &[]);
let mut settlement: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), transferAmount.clone());
m.insert("assetId".to_string(), collateralId.clone());
m.insert("expirationTimestamp".to_string(), settlementExpiration.clone());
m.insert("nonce".to_string(), nonce.clone());
m.insert("receiverPositionId".to_string(), toVault.clone());
m.insert("receiverPublicKey".to_string(), toL2Key.clone());
m.insert("senderPositionId".to_string(), fromVault.clone());
m.insert("senderPublicKey".to_string(), fromL2Key.clone());
m
});
let mut msgHash: Value = self.get_extended_transfer_msg_hash(settlement.clone());
let mut sig: Value = json_parse(&self.extended_starknet_sign(msgHash.clone(), self.privateKey.clone()));
add_element_to_object(&mut settlement, &Value::Str("signature".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("r".to_string(), self.get_extended_signature_hex(get_value(&sig, &Value::Int(0))));
m.insert("s".to_string(), self.get_extended_signature_hex(get_value(&sig, &Value::Int(1))));
m
}));
return settlement;
Value::Null
}
pub async fn create_extended_order_request(&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 is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut uppercaseType: Value = to_upper(&type_var);
let mut uppercaseSide: Value = to_upper(&side);
if is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) && !is_equal(&uppercaseType, &Value::Str("LIMIT".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrder() supports limit orders for spot markets only".to_string()))));
}
if !is_true(&self.in_array(uppercaseType.clone(), Value::List(vec![Value::Str("LIMIT".to_string()), Value::Str("MARKET".to_string()), Value::Str("CONDITIONAL".to_string()), Value::Str("TPSL".to_string())]))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrder() supports limit, market, conditional and tpsl orders only".to_string()))));
}
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a price argument".to_string()))));
}
let mut amountString: Value = self.amount_to_precision(symbol.clone(), amount.clone());
let mut priceString: Value = self.price_to_precision(symbol.clone(), price.clone());
let mut postOnly: Value = self.is_post_only(Value::Bool(is_equal(&uppercaseType, &Value::Str("MARKET".to_string()))), Value::Null, &[params.clone()]);
let mut reduceOnly: Value = self.safe_bool2(params.clone(), Value::Str("reduceOnly".to_string()), Value::Str("reduce_only".to_string()), &[Value::Bool(false)]);
let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
if is_equal(&timeInForce, &Value::Null) {
timeInForce = ternary(is_true(&(is_equal(&uppercaseType, &Value::Str("MARKET".to_string())))), Value::Str("IOC".to_string()), Value::Str("GTT".to_string()));
}
let mut fee: Value = self.safe_string_k(params.clone(), "fee", &[Value::Str("0.0005".to_string())]);
let mut builderFeeRate: Value = Value::Null;
let mut builderId: Value = Value::Null;
if is_true(&self.isSandboxModeEnabled) {
builderFeeRate = self.safe_string2(params.clone(), Value::Str("builderFeeRate".to_string()), Value::Str("defaultBuilderFeeRate".to_string()), &[]);
builderId = self.safe_string2(params.clone(), Value::Str("builderId".to_string()), Value::Str("defaultBuilderId".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("builderFeeRate".to_string()), Value::Str("defaultBuilderFeeRate".to_string()), Value::Str("builderId".to_string()), Value::Str("defaultBuilderId".to_string())]), &[]);
} else {
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("builderFeeRate".to_string()), &[Value::Str("0.0001".to_string())]); builderFeeRate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("builderId".to_string()), &[]); builderId = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
}
let mut totalFee: Value = fee.clone();
if !is_equal(&builderFeeRate, &Value::Null) {
totalFee = crate::precise::Precise::stringAdd(&fee, &builderFeeRate);
}
let mut now: Value = self.milliseconds();
let mut expiryEpochMillis: Value = self.safe_integer_k(params.clone(), "expiryEpochMillis", &[add(&now, &Value::Int(3600000))]);
let mut settlementExpiration: Value = self.safe_integer_k(params.clone(), "settlementExpiration", &[add(&self.parse_to_int(divide(&(add(&expiryEpochMillis, &Value::Int(999))), &Value::Int(1000))), &Value::Int(1209600))]);
let mut nonce: Value = self.number_to_string(self.nonce());
let mut account: Value = self.fetch_extended_account(&[]).await;
let mut starkKey: Value = self.safe_string_k(account.clone(), "l2Key", &[]);
let mut collateralPosition: Value = self.safe_string_k(account.clone(), "l2Vault", &[]);
let mut info: Value = self.safe_dict_k(market.clone(), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut l2Config: Value = self.safe_dict_k(info.clone(), "l2Config", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut syntheticId: Value = self.safe_string_k(l2Config.clone(), "syntheticId", &[]);
let mut collateralId: Value = self.safe_string_k(l2Config.clone(), "collateralId", &[]);
let mut syntheticResolution: Value = self.safe_integer_k(l2Config.clone(), "syntheticResolution", &[]);
let mut collateralResolution: Value = self.safe_integer_k(l2Config.clone(), "collateralResolution", &[]);
if is_true(&(is_equal(&syntheticId, &Value::Null))) || is_true(&(is_equal(&collateralId, &Value::Null))) || is_true(&(is_equal(&syntheticResolution, &Value::Null))) || is_true(&(is_equal(&collateralResolution, &Value::Null))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrder() requires l2Config in market info".to_string()))));
}
let mut settlementParams: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("totalFee".to_string(), totalFee.clone());
m.insert("starkKey".to_string(), starkKey.clone());
m.insert("syntheticId".to_string(), syntheticId.clone());
m.insert("syntheticResolution".to_string(), syntheticResolution.clone());
m.insert("collateralId".to_string(), collateralId.clone());
m.insert("collateralResolution".to_string(), collateralResolution.clone());
m.insert("settlementExpiration".to_string(), settlementExpiration.clone());
m.insert("nonce".to_string(), nonce.clone());
m.insert("collateralPosition".to_string(), collateralPosition.clone());
m
});
let mut isBuy: Value = Value::Bool(is_equal(&uppercaseSide, &Value::Str("BUY".to_string())));
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_id".to_string()), &[self.uuid(&[])]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), clientOrderId.clone());
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("type".to_string(), uppercaseType.clone());
m.insert("side".to_string(), uppercaseSide.clone());
m.insert("qty".to_string(), amountString.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("expiryEpochMillis".to_string(), expiryEpochMillis.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("nonce".to_string(), nonce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("reduceOnly".to_string(), reduceOnly.clone());
m.insert("selfTradeProtectionLevel".to_string(), Value::Str("ACCOUNT".to_string()));
m
});
if !is_equal(&builderFeeRate, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("builderFee".to_string()), builderFeeRate.clone());
}
if !is_equal(&builderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("builderId".to_string()), builderId.clone());
}
let mut cancelId: Value = self.safe_string2(params.clone(), Value::Str("cancelId".to_string()), Value::Str("previousOrderId".to_string()), &[]);
if !is_equal(&cancelId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("cancelId".to_string()), cancelId.clone());
}
let mut settlement: Value = self.create_order_settlement_data(isBuy.clone(), amountString.clone(), priceString.clone(), &[settlementParams.clone()]);
add_element_to_object(&mut request, &Value::Str("settlement".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("signature".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("r".to_string(), get_value(&settlement, &Value::Str("r".to_string())));
m.insert("s".to_string(), get_value(&settlement, &Value::Str("s".to_string())));
m
}));
m.insert("starkKey".to_string(), starkKey.clone());
m.insert("collateralPosition".to_string(), collateralPosition.clone());
m
}));
let mut triggerPriceStr: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
let mut stopLossTriggerPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
let mut takeProfitTriggerPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
let mut isStopLossOrder: bool = !is_equal(&stopLossTriggerPrice, &Value::Null);
let mut isTakeProfitOrder: bool = !is_equal(&takeProfitTriggerPrice, &Value::Null);
let mut stopLoss: Value = self.safe_dict_k(params.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_dict_k(params.clone(), "takeProfit", &[]);
let mut hasStopLoss: bool = !is_equal(&stopLoss, &Value::Null);
let mut hasTakeProfit: bool = !is_equal(&takeProfit, &Value::Null);
if is_true(&hasStopLoss) || is_true(&hasTakeProfit) {
add_element_to_object(&mut request, &Value::Str("tpSlType".to_string()), Value::Str("ORDER".to_string()));
if is_true(&hasStopLoss) {
let mut stopLossTrigger: Value = self.safe_string_k(stopLoss.clone(), "triggerPrice", &[]);
let mut stopLossTriggerPriceType: Value = self.safe_string_k(stopLoss.clone(), "triggerPriceType", &[]);
let mut stopLossExecutionPrice: Value = self.safe_string_k(stopLoss.clone(), "price", &[]);
let mut stopLossType: Value = self.safe_string_k(stopLoss.clone(), "type", &[]);
let mut stopLossSettlement: Value = self.create_order_settlement_data(Value::Bool(!is_true(&isBuy)), amountString.clone(), stopLossExecutionPrice.clone(), &[settlementParams.clone()]);
let mut requestStopLoss: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), self.price_to_precision(symbol.clone(), stopLossTrigger.clone()));
m.insert("price".to_string(), self.price_to_precision(symbol.clone(), stopLossExecutionPrice.clone()));
m.insert("settlement".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("signature".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("r".to_string(), get_value(&stopLossSettlement, &Value::Str("r".to_string())));
m.insert("s".to_string(), get_value(&stopLossSettlement, &Value::Str("s".to_string())));
m
}));
m.insert("starkKey".to_string(), starkKey.clone());
m.insert("collateralPosition".to_string(), collateralPosition.clone());
m
}));
m
});
if !is_equal(&stopLossTriggerPriceType, &Value::Null) {
add_element_to_object(&mut requestStopLoss, &Value::Str("triggerPriceType".to_string()), stopLossTriggerPriceType.clone());
}
if !is_equal(&stopLossType, &Value::Null) {
add_element_to_object(&mut requestStopLoss, &Value::Str("priceType".to_string()), stopLossType.clone());
}
add_element_to_object(&mut request, &Value::Str("stopLoss".to_string()), requestStopLoss.clone());
}
if is_true(&hasTakeProfit) {
let mut takeProfitTrigger: Value = self.safe_string_k(takeProfit.clone(), "triggerPrice", &[]);
let mut takeProfitTriggerPriceType: Value = self.safe_string_k(takeProfit.clone(), "triggerPriceType", &[]);
let mut takeProfitExecutionPrice: Value = self.safe_string_k(takeProfit.clone(), "price", &[]);
let mut takeProfitType: Value = self.safe_string_k(takeProfit.clone(), "type", &[]);
let mut takeProfitSettlement: Value = self.create_order_settlement_data(Value::Bool(!is_true(&isBuy)), amountString.clone(), takeProfitExecutionPrice.clone(), &[settlementParams.clone()]);
let mut requestTakeProfit: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), self.price_to_precision(symbol.clone(), takeProfitTrigger.clone()));
m.insert("price".to_string(), self.price_to_precision(symbol.clone(), takeProfitExecutionPrice.clone()));
m.insert("settlement".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("signature".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("r".to_string(), get_value(&takeProfitSettlement, &Value::Str("r".to_string())));
m.insert("s".to_string(), get_value(&takeProfitSettlement, &Value::Str("s".to_string())));
m
}));
m.insert("starkKey".to_string(), starkKey.clone());
m.insert("collateralPosition".to_string(), collateralPosition.clone());
m
}));
m
});
if !is_equal(&takeProfitTriggerPriceType, &Value::Null) {
add_element_to_object(&mut requestTakeProfit, &Value::Str("triggerPriceType".to_string()), takeProfitTriggerPriceType.clone());
}
if !is_equal(&takeProfitType, &Value::Null) {
add_element_to_object(&mut requestTakeProfit, &Value::Str("priceType".to_string()), takeProfitType.clone());
}
add_element_to_object(&mut request, &Value::Str("takeProfit".to_string()), requestTakeProfit.clone());
}
} else {
if !is_equal(&triggerPriceStr, &Value::Null) {
let mut triggerDirection: Value = self.safe_string_upper(params.clone(), Value::Str("triggerDirection".to_string()), &[]);
if is_equal(&triggerDirection, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires triggerDirection for trigger order".to_string()))));
}
let mut trigger: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), self.price_to_precision(symbol.clone(), triggerPriceStr.clone()));
m
});
add_element_to_object(&mut trigger, &Value::Str("direction".to_string()), triggerDirection.clone());
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("CONDITIONAL".to_string()));
add_element_to_object(&mut request, &Value::Str("trigger".to_string()), trigger.clone());
} else if is_true(&isStopLossOrder) || is_true(&isTakeProfitOrder) {
triggerPriceStr = ternary(is_true(&isStopLossOrder), stopLossTriggerPrice.clone(), takeProfitTriggerPrice.clone());
let mut trigger: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), self.price_to_precision(symbol.clone(), triggerPriceStr.clone()));
m
});
if is_true(&isBuy) {
add_element_to_object(&mut trigger, &Value::Str("direction".to_string()), ternary(is_true(&isStopLossOrder), Value::Str("UP".to_string()), Value::Str("DOWN".to_string())));
} else {
add_element_to_object(&mut trigger, &Value::Str("direction".to_string()), ternary(is_true(&isStopLossOrder), Value::Str("DOWN".to_string()), Value::Str("UP".to_string())));
}
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("CONDITIONAL".to_string()));
add_element_to_object(&mut request, &Value::Str("trigger".to_string()), trigger.clone());
}
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("client_id".to_string()), Value::Str("timeInForce".to_string()), Value::Str("postOnly".to_string()), Value::Str("reduceOnly".to_string()), Value::Str("reduce_only".to_string()), Value::Str("fee".to_string()), Value::Str("nonce".to_string()), Value::Str("expiryEpochMillis".to_string()), Value::Str("settlementExpiration".to_string()), Value::Str("cancelId".to_string()), Value::Str("previousOrderId".to_string()), Value::Str("brokerId".to_string()), Value::Str("referralCode".to_string()), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), Value::Str("triggerDirection".to_string()), Value::Str("stopLossPrice".to_string()), Value::Str("takeProfitPrice".to_string()), Value::Str("stopLoss".to_string()), Value::Str("takeProfit".to_string())]), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("request".to_string(), self.extend(request.clone(), &[params.clone()]));
m.insert("market".to_string(), market.clone());
m.insert("timestamp".to_string(), now.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m
});
Value::Null
}
/*
* @method
* @name extended#createOrder
* @description create a trade order
* @see https://api.docs.extended.exchange/#create-or-edit-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'limit' or 'market'
* @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, required for all order types
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] client order id, sent as the exchange order id
* @param {string} [params.cancelId] previous external order id to replace
* @param {string} [params.timeInForce] 'GTT' or 'IOC'
* @param {boolean} [params.postOnly] true if the order should only make liquidity
* @param {boolean} [params.reduceOnly] true if the order should only reduce a position
* @param {string} [params.fee] max fee rate for the order, default is 0.0005
* @param {int} [params.expiryEpochMillis] order expiration timestamp in milliseconds, default is now + 1 hour
* @param {float} [params.triggerPrice] *swap only* The price at which a trigger order is triggered at
* @param {float} [params.stopLossPrice] *swap only* The price at which a stop loss order is triggered at
* @param {float} [params.takeProfitPrice] *swap only* The price at which a take profit 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] *swap only* take profit trigger price
* @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
* @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'LAST', 'MARK' or 'INDEX', default is ''
* @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] *swap only* stop loss trigger price
* @param {float} [params.stopLoss.price] *swap only* the execution price for a stop loss attached to a trigger order
* @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'LAST', 'MARK' or 'INDEX', default is ''
* @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
}));
self.check_required_credentials(&[]);
let mut extendedOrderRequest: Value = self.create_extended_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
let mut request: Value = self.safe_dict_k(extendedOrderRequest.clone(), "request", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut response: Value = self.v1_private_post_user_order(&[request.clone()]).await;
//
// {
// "status": "OK",
// "data": {
// "id": "2051479786538188800",
// "externalId": "3480985089570526249141260266819446928410958787024864860785196119336740291620"
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut market: Value = get_value(&extendedOrderRequest, &Value::Str("market".to_string()));
let mut now: Value = self.safe_integer_k(extendedOrderRequest.clone(), "timestamp", &[]);
add_element_to_object(&mut data, &Value::Str("timestamp".to_string()), now.clone());
add_element_to_object(&mut data, &Value::Str("status".to_string()), Value::Str("NEW".to_string()));
let __ws_arg_21 = self.extend(request.clone(), &[data.clone()]);
return self.parse_order(__ws_arg_21, &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#editOrder
* @description edit a trade order
* @see https://api.docs.extended.exchange/#create-or-edit-order
* @param {string} id order id assigned by Extended
* @param {string} symbol unified symbol of the market to edit an order in
* @param {string} type 'limit' or 'market'
* @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
* @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 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 is_equal(&id, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() requires an id argument".to_string()))));
}
let mut expiryEpochMillis: Value = self.safe_integer_k(params.clone(), "expiryEpochMillis", &[]);
let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[]);
let mut reduceOnly: Value = self.safe_bool2(params.clone(), Value::Str("reduceOnly".to_string()), Value::Str("reduce_only".to_string()), &[]);
let mut cancelId: Value = self.safe_string2(params.clone(), Value::Str("cancelId".to_string()), Value::Str("previousOrderId".to_string()), &[]);
if is_true(&(is_equal(&amount, &Value::Null))) || is_true(&(is_equal(&price, &Value::Null))) || is_true(&(is_equal(&expiryEpochMillis, &Value::Null))) || is_true(&(is_equal(&postOnly, &Value::Null))) || is_true(&(is_equal(&reduceOnly, &Value::Null))) || is_true(&(is_equal(&cancelId, &Value::Null))) {
let mut response: Value = self.v1_private_get_user_orders_id(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
})]).await;
let mut order: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_equal(&amount, &Value::Null) {
amount = self.safe_number_k(order.clone(), "qty", &[]);
}
if is_equal(&price, &Value::Null) {
price = self.safe_number_k(order.clone(), "price", &[]);
}
if is_equal(&expiryEpochMillis, &Value::Null) {
expiryEpochMillis = self.safe_integer_k(order.clone(), "expireTime", &[]);
}
if is_equal(&postOnly, &Value::Null) {
postOnly = self.safe_bool_k(order.clone(), "postOnly", &[Value::Bool(false)]);
}
if is_equal(&reduceOnly, &Value::Null) {
reduceOnly = self.safe_bool_k(order.clone(), "reduceOnly", &[Value::Bool(false)]);
}
if is_equal(&cancelId, &Value::Null) {
cancelId = self.safe_string_k(order.clone(), "externalId", &[]);
}
}
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() requires an amount argument or an existing order with qty".to_string()))));
}
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() requires a price argument or an existing order with price".to_string()))));
}
params = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("reduceOnly".to_string(), reduceOnly.clone());
m
}), &[params.clone()]);
let mut requestParams: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cancelId".to_string(), cancelId.clone());
m.insert("expiryEpochMillis".to_string(), expiryEpochMillis.clone());
m
})]);
let mut extendedOrderRequest: Value = self.create_extended_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), requestParams.clone()]).await;
let mut request: Value = self.safe_dict_k(extendedOrderRequest.clone(), "request", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut editResponse: Value = self.v1_private_post_user_order(&[request.clone()]).await;
//
// {
// "status": "OK",
// "data": {
// "id": "2051479786538188800",
// "externalId": "3480985089570526249141260266819446928410958787024864860785196119336740291620"
// }
// }
//
let mut responseData: Value = self.safe_dict_k(editResponse.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut market: Value = get_value(&extendedOrderRequest, &Value::Str("market".to_string()));
let mut now: Value = self.safe_integer_k(extendedOrderRequest.clone(), "timestamp", &[]);
add_element_to_object(&mut responseData, &Value::Str("timestamp".to_string()), now.clone());
add_element_to_object(&mut responseData, &Value::Str("status".to_string()), Value::Str("NEW".to_string()));
let __ws_arg_22 = self.extend(request.clone(), &[responseData.clone()]);
return self.parse_order(__ws_arg_22, &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#cancelOrder
* @description cancels an open order
* @see https://api.docs.extended.exchange/#cancel-order-by-id
* @see https://api.docs.extended.exchange/#cancel-order-by-external-id
* @param {string} id order id assigned by Extended
* @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 {string} [params.clientOrderId] user-defined order id, cancels by external id
* @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
}));
self.load_markets(&[]).await;
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut response: Value = Value::Null;
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_id".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("client_id".to_string())]), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("externalId".to_string(), clientOrderId.clone());
m
});
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
response = self.v1_private_delete_user_order(&[__ws_arg_23]).await;
} else {
if is_equal(&id, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires an id argument".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
});
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
response = self.v1_private_delete_user_order_id(&[__ws_arg_24]).await;
}
//
// {
// "status": "OK"
// }
//
let mut orderId: Value = ternary(is_true(&(is_equal(&clientOrderId, &Value::Null))), id.clone(), Value::Null);
let mut orderSymbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), symbol.clone(), get_value(&market, &Value::Str("symbol".to_string())));
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), orderId.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("symbol".to_string(), orderSymbol.clone());
m.insert("status".to_string(), Value::Str("canceled".to_string()));
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#cancelOrders
* @description cancel multiple orders by order ids or client order ids
* @see https://api.docs.extended.exchange/#mass-cancel
* @param {string[]} ids order ids
* @param {string} [symbol] unified market symbol, only used to populate the returned orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string[]} [params.clientOrderIds] client order ids
* @param {string} [params.clientOrderId] single client order id
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_orders(&mut self, mut ids: 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
}));
self.load_markets(&[]).await;
let mut clientOrderIds: Value = self.safe_list_n(params.clone(), Value::List(vec![Value::Str("clientOrderIds".to_string()), Value::Str("client_order_ids".to_string()), Value::Str("externalOrderIds".to_string()), Value::Str("external_order_ids".to_string())]), &[]);
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_id".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderIds".to_string()), Value::Str("client_order_ids".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("client_id".to_string()), Value::Str("externalOrderIds".to_string()), Value::Str("external_order_ids".to_string()), Value::Str("orderIds".to_string()), Value::Str("order_ids".to_string()), Value::Str("markets".to_string()), Value::Str("cancelAll".to_string()), Value::Str("cancel_all".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut hasOrderIds: bool = !is_equal(&ids, &Value::Null);
if is_true(&hasOrderIds) {
let mut idsLength: Value = get_array_length(&ids);
if is_greater_than(&idsLength, &Value::Int(0)) {
add_element_to_object(&mut request, &Value::Str("orderIds".to_string()), ids.clone());
}
}
if is_equal(&clientOrderIds, &Value::Null) && !is_equal(&clientOrderId, &Value::Null) {
clientOrderIds = Value::List(vec![clientOrderId.clone()]);
}
let mut hasClientOrderIds: bool = !is_equal(&clientOrderIds, &Value::Null);
if !is_equal(&clientOrderIds, &Value::Null) {
let mut clientOrderIdsLength: Value = get_array_length(&clientOrderIds);
if is_greater_than(&clientOrderIdsLength, &Value::Int(0)) {
add_element_to_object(&mut request, &Value::Str("externalOrderIds".to_string()), clientOrderIds.clone());
}
}
if !is_true(&hasOrderIds) && !is_true(&hasClientOrderIds) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrders() requires an ids argument or clientOrderIds parameter".to_string()))));
}
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
self.v1_private_post_user_order_mass_cancel(&[__ws_arg_25]).await;
return Value::List(vec![]);
Value::Null
}
/*
* @method
* @name extended#cancelAllOrders
* @description cancels all open orders, optionally filtered by symbol
* @see https://api.docs.extended.exchange/#mass-cancel
* @param {string} [symbol] unified market symbol of the market to cancel orders in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a 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
}));
self.load_markets(&[]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cancelAll".to_string(), Value::Bool(true));
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("markets".to_string()), Value::List(vec![get_value(&market, &Value::Str("id".to_string()))]));
}
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
self.v1_private_post_user_order_mass_cancel(&[__ws_arg_26]).await;
return Value::List(vec![]);
Value::Null
}
/*
* @method
* @name extended#cancelAllOrdersAfter
* @description dead man's switch, cancel all orders after the given timeout
* @see https://api.docs.extended.exchange/#mass-auto-cancel-dead-man-39-s-switch
* @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
}));
self.load_markets(&[]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("countdownTime".to_string(), ternary(is_true(&(is_greater_than(&timeout, &Value::Int(0)))), self.parse_to_int(divide(&timeout, &Value::Int(1000))), Value::Int(0)));
m
});
let __ws_arg_27 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_post_user_deadmanswitch(&[__ws_arg_27]).await;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name extended#fetchOrder
* @description fetches information on an order made by the user
* @see https://api.docs.extended.exchange/#get-order-by-id
* @see https://api.docs.extended.exchange/#get-orders-by-external-id
* @param {string} id order id assigned by Extended
* @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 {string} [params.clientOrderId] user-defined order id, fetches by external id
* @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
}));
self.load_markets(&[]).await;
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut response: Value = Value::Null;
let mut order: Value = Value::Null;
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_id".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("client_id".to_string())]), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("externalId".to_string(), clientOrderId.clone());
m
});
let __ws_arg_28 = self.extend(request.clone(), &[params.clone()]);
response = self.v1_private_get_user_orders_external_external_id(&[__ws_arg_28]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
order = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
} else {
if is_equal(&id, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires an id argument".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
});
let __ws_arg_29 = self.extend(request.clone(), &[params.clone()]);
response = self.v1_private_get_user_orders_id(&[__ws_arg_29]).await;
order = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
return self.parse_order(order.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://api.docs.extended.exchange/#get-open-orders
* @param {string} [symbol] unified market symbol of the orders
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of open order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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
}));
self.load_markets(&[]).await;
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_30 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_user_orders(&[__ws_arg_30]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "id": 1775511783722512384,
// "accountId": 3017,
// "externalId": "2554612759479898620327573136214120486511160383028978112799136270841501275076",
// "market": "ETH-USD",
// "type": "LIMIT",
// "side": "BUY",
// "status": "PARTIALLY_FILLED",
// "price": "3300",
// "averagePrice": "3297.00",
// "qty": "0.2",
// "filledQty": "0.1",
// "payedFee": "0.0120000000000000",
// "reduceOnly": false,
// "postOnly": false,
// "createdTime": 1701563440000,
// "updatedTime": 1701563440000,
// "timeInForce": "IOC",
// "expireTime": 1712754771819
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut orders: Value = self.parse_orders(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
return self.filter_by_symbol_since_limit(orders.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://api.docs.extended.exchange/#get-orders-history
* @param {string} [symbol] unified market symbol of the orders
* @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.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @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
}));
self.load_markets(&[]).await;
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOrders".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(100)]).await;
}
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_31 = self.extend(params.clone(), &[request.clone()]);
let mut response: Value = self.v1_private_get_user_orders_history(&[__ws_arg_31]).await;
//
// {
// "status": "OK",
// "data": [
// {
// "id": 1784963886257016832,
// "externalId": "ExtId-1",
// "accountId": 1,
// "market": "BTC-USD",
// "status": "FILLED",
// "type": "LIMIT",
// "side": "BUY",
// "price": "39000",
// "averagePrice": "39000",
// "qty": "0.2",
// "filledQty": "0.1",
// "payedFee": "0.0120000000000000",
// "reduceOnly": false,
// "postOnly": false,
// "createdTime": 1701563440000,
// "updatedTime": 1701563440000,
// "timeInForce": "IOC",
// "expireTime": 1706563440
// }
// ],
// "pagination": {
// "cursor": 1784963886257016832,
// "count": 1
// }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut pagination: Value = self.safe_dict_k(response.clone(), "pagination", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cursor: Value = self.safe_string_k(pagination.clone(), "cursor", &[]);
let mut result: Value = Value::List(vec![]);
let mut dataLength: Value = get_array_length(&data);
{
let mut i: Value = Value::Int(0);
let mut __for_first_668: bool = true;
while { if !__for_first_668 { i = add(&i, &Value::Int(1)); } __for_first_668 = false; is_less_than(&i, &dataLength) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
if is_true(&(!is_equal(&cursor, &Value::Null))) && is_true(&(is_equal(&i, &subtract(&dataLength, &Value::Int(1))))) {
entry = self.extend(entry.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cursor".to_string(), cursor.clone());
m
})]);
}
append_to_array(&mut result, entry.clone());
}
}
let mut orders: Value = self.parse_orders(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
return self.filter_by_symbol_since_limit(orders.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://api.docs.extended.exchange/#get-orders-history
* @param {string} [symbol] unified market symbol of the orders
* @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.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @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
}));
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), Value::Null, params.clone()]).await;
let mut closedOrders: Value = self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
return self.filter_by_symbol_since_limit(closedOrders.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name extended#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://api.docs.extended.exchange/#get-orders-history
* @param {string} [symbol] unified market symbol of the orders
* @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.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_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
}));
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), Value::Null, params.clone()]).await;
let mut canceledOrders: Value = self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("canceled".to_string()), &[]);
return self.filter_by_symbol_since_limit(canceledOrders.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("NEW".to_string(), Value::Str("open".to_string()));
m.insert("PARTIALLY_FILLED".to_string(), Value::Str("open".to_string()));
m.insert("UNTRIGGERED".to_string(), Value::Str("open".to_string()));
m.insert("TRIGGERED".to_string(), Value::Str("open".to_string()));
m.insert("FILLED".to_string(), Value::Str("closed".to_string()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".to_string()));
m.insert("REJECTED".to_string(), Value::Str("rejected".to_string()));
m.insert("EXPIRED".to_string(), Value::Str("expired".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "id": 1784963886257016832,
// "externalId": "ExtId-1",
// "accountId": 1,
// "market": "BTC-USD",
// "status": "FILLED",
// "type": "LIMIT",
// "side": "BUY",
// "price": "39000",
// "averagePrice": "39000",
// "qty": "0.2",
// "filledQty": "0.1",
// "payedFee": "0.0120000000000000",
// "reduceOnly": false,
// "postOnly": false,
// "trigger": {
// "triggerPrice": "34000",
// "triggerPriceType": "LAST",
// "triggerPriceDirection": "UP",
// "executionPriceType": "MARKET"
// },
// "takeProfit": {
// "triggerPrice": "34000",
// "triggerPriceType": "LAST",
// "price": "35000",
// "priceType": "MARKET"
// },
// "stopLoss": {
// "triggerPrice": "34000",
// "triggerPriceType": "LAST",
// "price": "35000",
// "priceType": "MARKET"
// },
// "createdTime": 1701563440000,
// "updatedTime": 1701563440000,
// "timeInForce": "IOC",
// "expireTime": 1706563440
// }
//
let mut marketId: Value = self.safe_string_k(order.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer2(order.clone(), Value::Str("createdTime".to_string()), Value::Str("timestamp".to_string()), &[]);
let mut lastUpdateTimestamp: Value = self.safe_integer_k(order.clone(), "updatedTime", &[]);
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "status", &[]));
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
let mut type_var: Value = self.safe_string_lower(order.clone(), Value::Str("type".to_string()), &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "qty", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "filledQty", &[]);
let mut feeCost: Value = self.safe_string_k(order.clone(), "payedFee", &[]);
let mut trigger: Value = self.safe_dict_k(order.clone(), "trigger", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut takeProfit: Value = self.safe_dict_k(order.clone(), "takeProfit", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut stopLoss: Value = self.safe_dict_k(order.clone(), "stopLoss", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m.insert("currency".to_string(), ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("settle".to_string()))));
m
});
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), self.safe_string_k(order.clone(), "id", &[]));
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "externalId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), self.safe_string_k(order.clone(), "timeInForce", &[]));
m.insert("postOnly".to_string(), self.safe_bool_k(order.clone(), "postOnly", &[]));
m.insert("reduceOnly".to_string(), self.safe_bool_k(order.clone(), "reduceOnly", &[]));
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), self.safe_string_k(order.clone(), "price", &[]));
m.insert("triggerPrice".to_string(), self.safe_string_k(trigger.clone(), "triggerPrice", &[]));
m.insert("takeProfitPrice".to_string(), self.safe_string_k(takeProfit.clone(), "triggerPrice", &[]));
m.insert("stopLossPrice".to_string(), self.safe_string_k(stopLoss.clone(), "triggerPrice", &[]));
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), self.safe_string_k(order.clone(), "averagePrice", &[]));
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
pub fn get_extended_string_to_felt(&self, mut value: Value) -> Value {
return self.convert_to_big_int(self.string_to_base16(value.clone()));
Value::Null
}
pub fn get_extended_encode_i64(&self, mut value: Value) -> Value {
// Cairo prime offset for i64 negative encoding.
let mut prime: Value = Value::Str("3618502788666131213697322783095070105623107215331596699973092056135872020481".to_string());
let mut valueString: Value = self.number_to_string(value.clone());
if is_true(&crate::precise::Precise::stringLt(&valueString, &Value::Str("0".to_string()))) {
return crate::precise::Precise::stringAdd(&prime, &valueString);
}
return value;
Value::Null
}
pub fn get_extended_decimal_to_base16(&self, mut value: Value) -> Value {
let mut decimalString: Value = Value::Str("".to_string());
if is_string(&value) {
decimalString = value.clone();
} else {
decimalString = self.number_to_string(value.clone());
}
let mut hexChars: Value = Value::List(vec![Value::Str("0".to_string()), Value::Str("1".to_string()), Value::Str("2".to_string()), Value::Str("3".to_string()), Value::Str("4".to_string()), Value::Str("5".to_string()), Value::Str("6".to_string()), Value::Str("7".to_string()), Value::Str("8".to_string()), Value::Str("9".to_string()), Value::Str("a".to_string()), Value::Str("b".to_string()), Value::Str("c".to_string()), Value::Str("d".to_string()), Value::Str("e".to_string()), Value::Str("f".to_string())]);
let mut result: Value = Value::Str("".to_string());
while is_true(&crate::precise::Precise::stringGt(&decimalString, &Value::Str("0".to_string()))) {
let mut remainder: Value = self.parse_to_int(crate::precise::Precise::stringMod(&decimalString, &Value::Str("16".to_string())));
result = add(&get_value(&hexChars, &remainder), &result);
decimalString = crate::precise::Precise::stringDivPrec(&decimalString, &Value::Str("16".to_string()), &Value::Int(0));
}
if is_equal(&result, &Value::Str("".to_string())) {
return Value::Str("0".to_string());
}
return result;
Value::Null
}
pub fn get_extended_signature_hex(&self, mut signature: Value) -> Value {
if is_string(&signature) {
if is_equal(&get_index_of(&signature, &Value::Str("0x".to_string())), &Value::Int(0)) {
return signature;
}
return add(&Value::Str("0x".to_string()), &self.get_extended_decimal_to_base16(signature.clone()));
}
let mut signatureString: Value = self.number_to_string(signature.clone());
if is_equal(&get_index_of(&signatureString, &Value::Str("0x".to_string())), &Value::Int(0)) {
return signatureString;
}
return add(&Value::Str("0x".to_string()), &self.get_extended_decimal_to_base16(signatureString.clone()));
Value::Null
}
pub fn get_extended_domain_hash(&self) -> Value {
let mut domainTypeHash: Value = self.convert_to_big_int(self.extended_starknet_get_selector_from_name(Value::Str("\"StarknetDomain\"(\"name\":\"shortstring\",\"version\":\"shortstring\",\"chainId\":\"shortstring\",\"revision\":\"shortstring\")".to_string())));
let mut isTestnet: bool = is_greater_than_or_equal(&get_index_of(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())), &Value::Str("sepolia".to_string())), &Value::Int(0));
let mut defaultChainId: Value = ternary(is_true(&isTestnet), Value::Str("SN_SEPOLIA".to_string()), Value::Str("SN_MAIN".to_string()));
let mut chainId: Value = self.safe_string_k(self.options.clone(), "chainId", &[defaultChainId.clone()]);
return self.convert_to_big_int(self.extended_starknet_compute_poseidon_hash_on_elements(Value::List(vec![domainTypeHash.clone(), self.get_extended_string_to_felt(Value::Str("Perpetuals".to_string())), self.get_extended_string_to_felt(Value::Str("v0".to_string())), self.get_extended_string_to_felt(chainId.clone()), self.convert_to_big_int(Value::Str("1".to_string()))])));
Value::Null
}
pub fn get_extended_order_msg_hash(&self, mut settlement: Value) -> Value {
let mut orderTypeHash: Value = self.convert_to_big_int(self.extended_starknet_get_selector_from_name(Value::Str("\"Order\"(\"position_id\":\"felt\",\"base_asset_id\":\"AssetId\",\"base_amount\":\"i64\",\"quote_asset_id\":\"AssetId\",\"quote_amount\":\"i64\",\"fee_asset_id\":\"AssetId\",\"fee_amount\":\"u64\",\"expiration\":\"Timestamp\",\"salt\":\"felt\")\"PositionId\"(\"value\":\"u32\")\"AssetId\"(\"value\":\"felt\")\"Timestamp\"(\"seconds\":\"u64\")".to_string())));
let mut domainHash: Value = self.get_extended_domain_hash();
// Order fields
let mut positionId: Value = self.convert_to_big_int(self.safe_string_k(settlement.clone(), "collateralPosition", &[Value::Str("0".to_string())]));
let mut baseAssetId: Value = self.safe_string_k(settlement.clone(), "baseAssetId", &[Value::Str("0".to_string())]);
let mut baseAmount: Value = self.convert_to_big_int(self.safe_string_k(settlement.clone(), "baseAmount", &[Value::Str("0".to_string())]));
let mut quoteAssetId: Value = self.safe_string_k(settlement.clone(), "quoteAssetId", &[Value::Str("0".to_string())]);
let mut quoteAmount: Value = self.convert_to_big_int(self.safe_string_k(settlement.clone(), "quoteAmount", &[Value::Str("0".to_string())]));
let mut feeAssetId: Value = self.safe_string_k(settlement.clone(), "feeAssetId", &[Value::Str("0".to_string())]);
let mut feeAmount: Value = self.convert_to_big_int(self.safe_string_k(settlement.clone(), "feeAmount", &[Value::Str("0".to_string())]));
let mut expiration: Value = self.convert_to_big_int(self.safe_string2(settlement.clone(), Value::Str("expiration".to_string()), Value::Str("expirationTimestamp".to_string()), &[Value::Str("0".to_string())]));
let mut salt: Value = self.convert_to_big_int(self.safe_string2(settlement.clone(), Value::Str("salt".to_string()), Value::Str("nonce".to_string()), &[Value::Str("0".to_string())]));
let mut starkKey: Value = self.convert_to_big_int(self.safe_string_k(settlement.clone(), "starkKey", &[Value::Str("0".to_string())]));
// Order struct hash
let mut orderHash: Value = self.convert_to_big_int(self.extended_starknet_compute_poseidon_hash_on_elements(Value::List(vec![orderTypeHash.clone(), positionId.clone(), self.convert_to_big_int(baseAssetId.clone()), self.get_extended_encode_i64(baseAmount.clone()), self.convert_to_big_int(quoteAssetId.clone()), self.get_extended_encode_i64(quoteAmount.clone()), self.convert_to_big_int(feeAssetId.clone()), feeAmount.clone(), expiration.clone(), salt.clone()])));
return self.extended_starknet_compute_poseidon_hash_on_elements(Value::List(vec![self.get_extended_string_to_felt(Value::Str("StarkNet Message".to_string())), domainHash.clone(), starkKey.clone(), orderHash.clone()]));
Value::Null
}
pub fn get_extended_withdrawal_msg_hash(&self, mut settlement: Value, mut starkKey: Value) -> Value {
let mut withdrawalTypeHash: Value = self.convert_to_big_int(self.extended_starknet_get_selector_from_name(Value::Str("\"Withdrawal\"(\"recipient\":\"felt\",\"position_id\":\"PositionId\",\"collateral_id\":\"AssetId\",\"amount\":\"u64\",\"expiration\":\"Timestamp\",\"salt\":\"felt\")\"PositionId\"(\"value\":\"u32\")\"AssetId\"(\"value\":\"felt\")\"Timestamp\"(\"seconds\":\"u64\")".to_string())));
let mut domainHash: Value = self.get_extended_domain_hash();
let mut expiration: Value = self.safe_dict_k(settlement.clone(), "expiration", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut withdrawalHash: Value = self.convert_to_big_int(self.extended_starknet_compute_poseidon_hash_on_elements(Value::List(vec![withdrawalTypeHash.clone(), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "recipient", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "positionId", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "collateralId", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "amount", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(expiration.clone(), "seconds", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "salt", &[Value::Str("0".to_string())]))])));
return self.extended_starknet_compute_poseidon_hash_on_elements(Value::List(vec![self.get_extended_string_to_felt(Value::Str("StarkNet Message".to_string())), domainHash.clone(), self.convert_to_big_int(starkKey.clone()), withdrawalHash.clone()]));
Value::Null
}
pub fn get_extended_transfer_msg_hash(&self, mut settlement: Value) -> Value {
let mut transferTypeHash: Value = self.convert_to_big_int(self.extended_starknet_get_selector_from_name(Value::Str("\"Transfer\"(\"sender_position_id\":\"PositionId\",\"receiver_position_id\":\"PositionId\",\"asset_id\":\"AssetId\",\"amount\":\"u64\",\"expiration\":\"Timestamp\",\"salt\":\"felt\")\"PositionId\"(\"value\":\"u32\")\"AssetId\"(\"value\":\"felt\")\"Timestamp\"(\"seconds\":\"u64\")".to_string())));
let mut domainHash: Value = self.get_extended_domain_hash();
let mut senderPublicKey: Value = self.convert_to_big_int(self.safe_string_k(settlement.clone(), "senderPublicKey", &[Value::Str("0".to_string())]));
let mut transferHash: Value = self.convert_to_big_int(self.extended_starknet_compute_poseidon_hash_on_elements(Value::List(vec![transferTypeHash.clone(), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "senderPositionId", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "receiverPositionId", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "assetId", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "amount", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "expirationTimestamp", &[Value::Str("0".to_string())])), self.convert_to_big_int(self.safe_string_k(settlement.clone(), "nonce", &[Value::Str("0".to_string())]))])));
return self.extended_starknet_compute_poseidon_hash_on_elements(Value::List(vec![self.get_extended_string_to_felt(Value::Str("StarkNet Message".to_string())), domainHash.clone(), senderPublicKey.clone(), transferHash.clone()]));
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 is_equal(&response, &Value::Null) {
return Value::Null;
}
//
// {"status":"ERROR","error":{"code":1140,"message":"New order cost exceeds available balance","debugInfo":"Order cost 2.000000 exceeds available for trade 0\nOrder price = 200, mark price = 95.2147597125 estimated market price = 94.81"}}
//
let mut status: Value = self.safe_string_lower(response.clone(), Value::Str("status".to_string()), &[]);
if is_equal(&status, &Value::Str("error".to_string())) {
let mut error: Value = self.safe_dict_k(response.clone(), "error", &[]);
let mut errorCode: Value = self.safe_string_k(error.clone(), "code", &[]);
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &self.json(response.clone()));
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), body.clone(), feedback.clone());
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorCode.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
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 version: Value = self.safe_string(api.clone(), Value::Int(0), &[]);
let mut accessibility: Value = self.safe_string(api.clone(), Value::Int(1), &[]);
let mut endpoint: Value = add(&Value::Str("/".to_string()), &self.implode_params(path.clone(), params.clone()));
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut queryPost: bool = is_equal(&path, &Value::Str("user/deadmanswitch".to_string()));
let mut url: Value = self.implode_hostname(get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())));
if is_equal(&accessibility, &Value::Str("private".to_string())) {
// this.checkRequiredCredentials ();
if is_equal(&self.apiKey, &Value::Null) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" sign() requires an apiKey for private endpoints".to_string()))));
}
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-Api-Key".to_string(), self.apiKey.clone());
m
});
if is_true(&(is_true(&(is_equal(&method, &Value::Str("POST".to_string())))) || is_true(&(is_equal(&method, &Value::Str("PATCH".to_string())))))) && !is_true(&queryPost) {
body = self.json(query.clone());
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
}
}
url = add(&add(&add(&url, &Value::Str("/api/".to_string())), &version), &endpoint);
if is_true(&(is_equal(&method, &Value::Str("GET".to_string())) || is_equal(&method, &Value::Str("DELETE".to_string())) || is_true(&queryPost))) && is_true(&(is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)))) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode_with_array_repeat(query.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(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
}