// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct BlockchaincomCore {
pub exchange: crate::exchange::Exchange,
}
impl BlockchaincomCore {
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 = BlockchaincomCore::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 BlockchaincomCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BlockchaincomCore.
BlockchaincomCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BlockchaincomCore.
BlockchaincomCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BlockchaincomCore.
BlockchaincomCore::parse_order(self, order, &[market])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BlockchaincomCore.
BlockchaincomCore::parse_transaction(self, transaction, &[currency])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BlockchaincomCore.
BlockchaincomCore::sign(self, path, &[api, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on BlockchaincomCore.
BlockchaincomCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BlockchaincomCore {
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[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders_by_state" => self.fetch_orders_by_state(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"fetch_withdrawal" => self.fetch_withdrawal(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BlockchaincomCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BlockchaincomCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BlockchaincomCore {
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("blockchaincom".into()));
m.insert("secret".to_string(), Value::Null);
m.insert("name".to_string(), Value::Str("Blockchain.com".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("LX".into())]));
m.insert("rateLimit".to_string(), Value::Int(500));
m.insert("version".to_string(), Value::Str("v3".into()));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Bool(false));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Null);
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCurrencies".to_string(), Value::Bool(false));
m.insert("fetchDeposit".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchL2OrderBook".to_string(), Value::Bool(true));
m.insert("fetchL3OrderBook".to_string(), Value::Bool(true));
m.insert("fetchLedger".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(false));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Bool(true));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchWithdrawalWhitelist".to_string(), Value::Bool(true));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Null);
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/975e3054-3399-4363-bcee-ec3c6d63d4e8".into()));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://testnet-api.delta.exchange".into()));
m.insert("private".to_string(), Value::Str("https://testnet-api.delta.exchange".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.blockchain.com/v3/exchange".into()));
m.insert("private".to_string(), Value::Str("https://api.blockchain.com/v3/exchange".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://blockchain.com".into()));
m.insert("doc".to_string(), Value::from(vec![Value::Str("https://api.blockchain.com/v3".into())]));
m.insert("fees".to_string(), Value::Str("https://exchange.blockchain.com/fees".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tickers/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("symbols/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("l2/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("l3/{symbol}".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("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("internal/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{orderId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deposits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deposits/{depositId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("accounts/{account}/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("whitelist".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("whitelist/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("withdrawals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("withdrawals/{withdrawalId}".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("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deposits/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("withdrawals".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("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{orderId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("feeSide".to_string(), Value::Str("get".into()));
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), Value::from(vec![Value::from(vec![self.parse_number(Value::Str("0".into()), &[]), self.parse_number(Value::Str("0.0045".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("10000".into()), &[]), self.parse_number(Value::Str("0.0035".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("50000".into()), &[]), self.parse_number(Value::Str("0.0018".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("100000".into()), &[]), self.parse_number(Value::Str("0.0018".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("500000".into()), &[]), self.parse_number(Value::Str("0.0018".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("1000000".into()), &[]), self.parse_number(Value::Str("0.0018".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("2500000".into()), &[]), self.parse_number(Value::Str("0.0018".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("5000000".into()), &[]), self.parse_number(Value::Str("0.0016".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("25000000".into()), &[]), self.parse_number(Value::Str("0.0014".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("100000000".into()), &[]), self.parse_number(Value::Str("0.0011".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("500000000".into()), &[]), self.parse_number(Value::Str("0.0008".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("1000000000".into()), &[]), self.parse_number(Value::Str("0.0006".into()), &[])])]));
m.insert("maker".to_string(), Value::from(vec![Value::from(vec![self.parse_number(Value::Str("0".into()), &[]), self.parse_number(Value::Str("0.004".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("10000".into()), &[]), self.parse_number(Value::Str("0.0017".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("50000".into()), &[]), self.parse_number(Value::Str("0.0015".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("100000".into()), &[]), self.parse_number(Value::Str("0.0008".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("500000".into()), &[]), self.parse_number(Value::Str("0.0007".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("1000000".into()), &[]), self.parse_number(Value::Str("0.0006".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("2500000".into()), &[]), self.parse_number(Value::Str("0.0005".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("5000000".into()), &[]), self.parse_number(Value::Str("0.0004".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("25000000".into()), &[]), self.parse_number(Value::Str("0.0003".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("100000000".into()), &[]), self.parse_number(Value::Str("0.0002".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("500000000".into()), &[]), self.parse_number(Value::Str("0.0001".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("1000000000".into()), &[]), self.parse_number(Value::Str("0".into()), &[])])]));
m
}));
m
}));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(false));
m.insert("secret".to_string(), Value::Bool(true));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ERC20".to_string(), Value::Str("ETH".into()));
m.insert("TRC20".to_string(), Value::Str("TRX".into()));
m.insert("ALGO".to_string(), Value::Str("ALGO".into()));
m.insert("ADA".to_string(), Value::Str("ADA".into()));
m.insert("AR".to_string(), Value::Str("AR".into()));
m.insert("ATOM".to_string(), Value::Str("ATOM".into()));
m.insert("AVAXC".to_string(), Value::Str("AVAX".into()));
m.insert("BCH".to_string(), Value::Str("BCH".into()));
m.insert("BSV".to_string(), Value::Str("BSV".into()));
m.insert("BTC".to_string(), Value::Str("BTC".into()));
m.insert("DCR".to_string(), Value::Str("DCR".into()));
m.insert("DESO".to_string(), Value::Str("DESO".into()));
m.insert("DASH".to_string(), Value::Str("DASH".into()));
m.insert("CELO".to_string(), Value::Str("CELO".into()));
m.insert("CHZ".to_string(), Value::Str("CHZ".into()));
m.insert("MATIC".to_string(), Value::Str("MATIC".into()));
m.insert("SOL".to_string(), Value::Str("SOL".into()));
m.insert("DOGE".to_string(), Value::Str("DOGE".into()));
m.insert("DOT".to_string(), Value::Str("DOT".into()));
m.insert("EOS".to_string(), Value::Str("EOS".into()));
m.insert("ETC".to_string(), Value::Str("ETC".into()));
m.insert("FIL".to_string(), Value::Str("FIL".into()));
m.insert("KAVA".to_string(), Value::Str("KAVA".into()));
m.insert("LTC".to_string(), Value::Str("LTC".into()));
m.insert("IOTA".to_string(), Value::Str("MIOTA".into()));
m.insert("NEAR".to_string(), Value::Str("NEAR".into()));
m.insert("STX".to_string(), Value::Str("STX".into()));
m.insert("XLM".to_string(), Value::Str("XLM".into()));
m.insert("XMR".to_string(), Value::Str("XMR".into()));
m.insert("XRP".to_string(), Value::Str("XRP".into()));
m.insert("XTZ".to_string(), Value::Str("XTZ".into()));
m.insert("ZEC".to_string(), Value::Str("ZEC".into()));
m.insert("ZIL".to_string(), Value::Str("ZIL".into()));
m
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(false));
m.insert("GTD".to_string(), Value::Bool(true));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("daysBackCanceled".to_string(), Value::Int(1));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Null);
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
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("401".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("404".to_string(), Value::Str("OrderNotFound".into()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchMarkets
* @description retrieves data on all markets for blockchaincom
* @see https://api.blockchain.com/v3/#getsymbols
* @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
}));
//
// "USDC-GBP": {
// "base_currency": "USDC",
// "base_currency_scale": 6,
// "counter_currency": "GBP",
// "counter_currency_scale": 2,
// "min_price_increment": 10000,
// "min_price_increment_scale": 8,
// "min_order_size": 500000000,
// "min_order_size_scale": 8,
// "max_order_size": 0,
// "max_order_size_scale": 8,
// "lot_size": 10000,
// "lot_size_scale": 8,
// "status": "open",
// "id": 68,
// "auction_price": 0,
// "auction_size": 0,
// "auction_time": "",
// "imbalance": 0
// }
//
let mut markets: Value = self.public_get_symbols(&[params]).await;
let mut marketIds: Value = object_keys(&markets);
let mut result: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_439: bool = true;
while { if !__for_first_439 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_439 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut market: Value = self.safe_dict(markets.clone(), marketId.clone(), &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "base_currency", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "counter_currency", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut numericId: Value = self.safe_number_k(market.clone(), "id", &[]);
let mut active: Value = Value::Null;
let mut marketState: Option<String> = self.safe_string_k(market.clone(), "status", &[]).as_str().map(str::to_owned);
if (marketState.as_deref() == Some("open")) {
active = Value::Bool(true);
} else {
active = Value::Bool(false);
}
// price precision
let mut minPriceIncrementString: Value = self.safe_string_k(market.clone(), "min_price_increment", &[]);
let mut minPriceIncrementScaleString: Value = self.safe_string_k(market.clone(), "min_price_increment_scale", &[]);
let mut minPriceScalePrecisionString: Value = self.parse_precision(&[minPriceIncrementScaleString]);
let mut pricePrecisionString: Value = crate::precise::Precise::stringMul(&minPriceIncrementString, &minPriceScalePrecisionString);
// amount precision
let mut lotSizeString: Value = self.safe_string_k(market.clone(), "lot_size", &[]);
let mut lotSizeScaleString: Value = self.safe_string_k(market.clone(), "lot_size_scale", &[]);
let mut lotSizeScalePrecisionString: Value = self.parse_precision(&[lotSizeScaleString]);
let mut amountPrecisionString: Value = crate::precise::Precise::stringMul(&lotSizeString, &lotSizeScalePrecisionString);
// minimum order size
let mut minOrderSizeString: Value = self.safe_string_k(market.clone(), "min_order_size", &[]);
let mut minOrderSizeScaleString: Value = self.safe_string_k(market.clone(), "min_order_size_scale", &[]);
let mut minOrderSizeScalePrecisionString: Value = self.parse_precision(&[minOrderSizeScaleString]);
let mut minOrderSizePreciseString: Value = crate::precise::Precise::stringMul(&minOrderSizeString, &minOrderSizeScalePrecisionString);
let mut minOrderSize: Value = self.parse_number(minOrderSizePreciseString, &[]);
// maximum order size
let mut maxOrderSize: Value = Value::Null;
let mut maxOrderSizeRaw: Value = self.safe_string_k(market.clone(), "max_order_size", &[]);
if (maxOrderSizeRaw.as_str() != Some("0")) {
let mut maxOrderSizeScaleString: Value = self.safe_string_k(market.clone(), "max_order_size_scale", &[]);
let mut maxOrderSizeScalePrecisionString: Value = self.parse_precision(&[maxOrderSizeScaleString]);
let mut maxOrderSizeValueString: Value = crate::precise::Precise::stringMul(&maxOrderSizeRaw, &maxOrderSizeScalePrecisionString);
maxOrderSize = self.parse_number(maxOrderSizeValueString, &[]);
}
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), market);
m.insert("id".to_string(), marketId);
m.insert("numericId".to_string(), numericId);
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active);
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(amountPrecisionString, &[]));
m.insert("price".to_string(), self.parse_number(pricePrecisionString, &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), minOrderSize);
m.insert("max".to_string(), maxOrderSize);
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(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name blockchaincom#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://api.blockchain.com/v3/#getl3orderbook
* @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
}));
return self.fetch_l3_order_book(symbol, &[limit, params]).await;
Value::Null
}
/*
* @method
* @name blockchaincom#fetchL3OrderBook
* @description fetches level 3 information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://api.blockchain.com/v3/#getl3orderbook
* @param {string} symbol unified market symbol
* @param {int} [limit] max number of orders to return, default is undefined
* @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_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("depth".into(), limit); }
}
let __ws_arg_0 = self.extend(request, &[params]);
let mut response: Value = self.public_get_l3_symbol(&[__ws_arg_0]).await;
return self.parse_order_book(response, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[Value::Null, Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("px".into()), Value::Str("qty".into())]);
Value::Null
}
pub async fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("depth".into(), limit); }
}
let __ws_arg_1 = self.extend(request, &[params]);
let mut response: Value = self.public_get_l2_symbol(&[__ws_arg_1]).await;
return self.parse_order_book(response, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[Value::Null, Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("px".into()), Value::Str("qty".into())]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "BTC-USD",
// "price_24h": 47791.86,
// "volume_24h": 362.88635738,
// "last_trade_price": 47587.75
// }
//
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone(), Value::Str("-".into())]);
let mut last: Value = self.safe_string_k(ticker.clone(), "last_trade_price", &[]);
let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "volume_24h", &[]);
let mut open: Value = self.safe_string_k(ticker.clone(), "price_24h", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("high".to_string(), Value::Null);
m.insert("low".to_string(), Value::Null);
m.insert("bid".to_string(), Value::Null);
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), Value::Null);
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), open);
m.insert("close".to_string(), Value::Null);
m.insert("last".to_string(), last);
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume);
m.insert("quoteVolume".to_string(), Value::Null);
m.insert("info".to_string(), ticker);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name blockchaincom#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.blockchain.com/v3/#gettickerbysymbol
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_2 = self.extend(request, &[params]);
let mut response: Value = self.public_get_tickers_symbol(&[__ws_arg_2]).await;
return self.parse_ticker(response, &[market]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://api.blockchain.com/v3/#gettickers
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut tickers: Value = self.public_get_tickers(&[params]).await;
return self.parse_tickers(tickers, &[symbols]);
Value::Null
}
pub fn parse_order_state(&self, mut state: Value) -> Option<String> {
let mut states: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OPEN".to_string(), Value::Str("open".into()));
m.insert("REJECTED".to_string(), Value::Str("rejected".into()));
m.insert("FILLED".to_string(), Value::Str("closed".into()));
m.insert("CANCELED".to_string(), Value::Str("canceled".into()));
m.insert("PART_FILLED".to_string(), Value::Str("open".into()));
m.insert("EXPIRED".to_string(), Value::Str("expired".into()));
m
});
return self.safe_string(states, state.clone(), &[state.clone()]).as_str().map(str::to_owned);
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "clOrdId": "00001",
// "ordType": "MARKET",
// "ordStatus": "FILLED",
// "side": "BUY",
// "symbol": "USDC-USDT",
// "exOrdId": "281775861306290",
// "price": null,
// "text": "Fill",
// "lastShares": "30.0",
// "lastPx": "0.9999",
// "leavesQty": "0.0",
// "cumQty": "30.0",
// "avgPx": "0.9999",
// "timestamp": "1633940339619"
// }
//
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "clOrdId", &[]);
let mut type_var: Value = self.safe_string_lower_k(order.clone(), "ordType", &[]);
let mut statusId: Value = self.safe_string_k(order.clone(), "ordStatus", &[]);
let mut state: Value = self.parse_order_state(statusId).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut side: Value = self.safe_string_lower_k(order.clone(), "side", &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market, Value::Str("-".into())]);
let mut exchangeOrderId: Value = self.safe_string_k(order.clone(), "exOrdId", &[]);
let mut price: Value = (if (type_var.as_str() != Some("market")) { self.safe_string_k(order.clone(), "price", &[]) } else { Value::Null });
let mut average: Value = self.safe_number_k(order.clone(), "avgPx", &[]);
let mut timestamp: Value = self.safe_integer_k(order.clone(), "timestamp", &[]);
let mut datetime: Value = self.iso8601(timestamp.clone());
let mut filled: Value = self.safe_string_k(order.clone(), "cumQty", &[]);
let mut remaining: Value = self.safe_string_k(order.clone(), "leavesQty", &[]);
let mut result: Value = self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), exchangeOrderId);
m.insert("clientOrderId".to_string(), clientOrderId);
m.insert("datetime".to_string(), datetime);
m.insert("timestamp".to_string(), timestamp);
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), state);
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), type_var);
m.insert("timeInForce".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("average".to_string(), average);
m.insert("amount".to_string(), Value::Null);
m.insert("filled".to_string(), filled);
m.insert("remaining".to_string(), remaining);
m.insert("cost".to_string(), Value::Null);
m.insert("trades".to_string(), Value::from(vec![]));
m.insert("fees".to_string(), Value::from(vec![]));
m.insert("info".to_string(), order);
m
}), &[]);
return result;
Value::Null
}
/*
* @method
* @name blockchaincom#createOrder
* @description create a trade order
* @see https://api.blockchain.com/v3/#createorder
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut orderType: Value = self.safe_string_k(params.clone(), "ordType", &[type_var]);
let mut uppercaseOrderType: Value = to_upper(&orderType);
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".into()), Value::Str("clOrdId".into()), &[self.uuid16(&[])]);
params = self.omit(params.clone(), Value::from(vec![Value::Str("ordType".into()), Value::Str("clientOrderId".into()), Value::Str("clOrdId".into())]), &[]);
if (side == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a side argument".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ordType".to_string(), uppercaseOrderType.clone());
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("side".to_string(), to_upper(&side));
m.insert("orderQty".to_string(), self.amount_to_precision(symbol.clone(), amount));
m.insert("clOrdId".to_string(), clientOrderId);
m
});
let mut triggerPrice: Value = self.safe_value_n(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stopPx".into()), Value::Str("stopPrice".into())]), &[]);
params = self.omit(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stopPx".into()), Value::Str("stopPrice".into())]), &[]);
if (uppercaseOrderType.as_str() == Some("STOP")) || (uppercaseOrderType.as_str() == Some("STOPLIMIT")) {
if (triggerPrice == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a stopPx or triggerPrice param for a ".into())).into()), uppercaseOrderType).into()), Value::Str(" order".into()))));
}
}
if (triggerPrice != Value::Null) {
if (uppercaseOrderType.as_str() == Some("MARKET")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ordType".into(), Value::Str("STOP".into())); }
} else if (uppercaseOrderType.as_str() == Some("LIMIT")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ordType".into(), Value::Str("STOPLIMIT".into())); }
}
}
let mut priceRequired: bool = false;
let mut stopPriceRequired: bool = false;
if (match &request { Value::Dict(__m15) => __m15.get("ordType").cloned().unwrap_or(Value::Null), _ => Value::Null }.as_str() == Some("LIMIT")) || (match &request { Value::Dict(__m15) => __m15.get("ordType").cloned().unwrap_or(Value::Null), _ => Value::Null }.as_str() == Some("STOPLIMIT")) {
priceRequired = true;
}
if (match &request { Value::Dict(__m15) => __m15.get("ordType").cloned().unwrap_or(Value::Null), _ => Value::Null }.as_str() == Some("STOP")) || (match &request { Value::Dict(__m15) => __m15.get("ordType").cloned().unwrap_or(Value::Null), _ => Value::Null }.as_str() == Some("STOPLIMIT")) {
stopPriceRequired = true;
}
if priceRequired {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price)); }
}
if stopPriceRequired {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopPx".into(), self.price_to_precision(symbol, triggerPrice)); }
}
let __ws_arg_3 = self.extend(request, &[params]);
let mut response: Value = self.private_post_orders(&[__ws_arg_3]).await;
return self.parse_order(response, &[market]);
Value::Null
}
/*
* @method
* @name blockchaincom#cancelOrder
* @description cancels an open order
* @see https://api.blockchain.com/v3/#deleteorder
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id.clone());
m
});
let __ws_arg_4 = self.extend(request, &[params]);
let mut response: Value = self.private_delete_orders_order_id(&[__ws_arg_4]).await;
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("info".to_string(), response);
m
}), &[]);
Value::Null
}
/*
* @method
* @name blockchaincom#cancelAllOrders
* @description cancel all open orders
* @see https://api.blockchain.com/v3/#deleteallorders
* @param {string} [symbol] unified market symbol of the market to cancel orders in, all markets are used if undefined, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// cancels all open orders if no symbol specified
// cancels all open orders of specified symbol, if symbol is specified
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
let mut marketId: Value = self.market_id(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), marketId); }
}
let __ws_arg_5 = self.extend(request, &[params]);
let mut response: Value = self.private_delete_orders(&[__ws_arg_5]).await;
return Value::from(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
}), &[])]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://api.blockchain.com/v3/#getfees
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_fees(&[params]).await;
//
// {
// "makerRate": "0.002",
// "takerRate": "0.004",
// "volumeInUSD": "0.0"
// }
//
let mut makerFee: Value = self.safe_number_k(response.clone(), "makerRate", &[]);
let mut takerFee: Value = self.safe_number_k(response.clone(), "takerRate", &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbols: Value = self.symbols.clone();
{
let mut i: Value = Value::Int(0);
let mut __for_first_440: bool = true;
while { if !__for_first_440 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_440 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
let mut symbol: Value = symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), makerFee.clone());
m.insert("taker".to_string(), takerFee.clone());
m
})); }
}
}
return result;
Value::Null
}
/*
* @method
* @name blockchaincom#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://api.blockchain.com/v3/#getorders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
* @param {int} [limit] max number of orders to return, default is undefined
* @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 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 state: Value = Value::Str("CANCELED".into());
return self.fetch_orders_by_state(state, &[symbol, since, limit, params]).await;
Value::Null
}
/*
* @method
* @name blockchaincom#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://api.blockchain.com/v3/#getorders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 state: Value = Value::Str("FILLED".into());
return self.fetch_orders_by_state(state, &[symbol, since, limit, params]).await;
Value::Null
}
/*
* @method
* @name blockchaincom#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://api.blockchain.com/v3/#getorders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders 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
}));
let mut state: Value = Value::Str("OPEN".into());
return self.fetch_orders_by_state(state, &[symbol, since, limit, params]).await;
Value::Null
}
pub async fn fetch_orders_by_state(&mut self, mut state: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), state);
m.insert("limit".to_string(), Value::Int(100));
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_6 = self.extend(request, &[params]);
let mut response: Value = self.private_get_orders(&[__ws_arg_6]).await;
return self.parse_orders(response, &[market, since, limit]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "exOrdId":281685751028507,
// "tradeId":281685434947633,
// "execId":8847494003,
// "side":"BUY",
// "symbol":"AAVE-USDT",
// "price":405.34,
// "qty":0.1,
// "fee":0.162136,
// "timestamp":1634559249687
// }
//
let mut orderId: Value = self.safe_string_k(trade.clone(), "exOrdId", &[]);
let mut tradeId: Value = self.safe_string_k(trade.clone(), "tradeId", &[]);
let mut side: Value = self.safe_string_lower_k(trade.clone(), "side", &[]);
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "qty", &[]);
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
let mut datetime: Value = self.iso8601(timestamp.clone());
market = self.safe_market(&[marketId, market.clone(), Value::Str("-".into())]);
let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "fee", &[]);
if (feeCostString != Value::Null) {
let mut feeCurrency: Value = market.as_map().and_then(|__m| __m.get("quote")).cloned().unwrap_or(Value::Null);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString);
m.insert("currency".to_string(), feeCurrency);
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), tradeId);
m.insert("timestamp".to_string(), timestamp);
m.insert("datetime".to_string(), datetime);
m.insert("symbol".to_string(), symbol);
m.insert("order".to_string(), orderId);
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), priceString);
m.insert("amount".to_string(), amountString);
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), fee);
m.insert("info".to_string(), trade);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchMyTrades
* @description fetch all trades made by the user
* @see https://api.blockchain.com/v3/#getfills
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.market_id(symbol.clone())); }
market = self.market(symbol);
}
let __ws_arg_7 = self.extend(request, &[params.clone()]);
let mut trades: Value = self.private_get_fills(&[__ws_arg_7]).await;
return self.parse_trades(trades, &[market, since, limit, params]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://api.blockchain.com/v3/#getdepositaddress
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_8 = self.extend(request, &[params]);
let mut response: Value = self.private_post_deposits_currency(&[__ws_arg_8]).await;
let mut rawAddress: Value = self.safe_string_k(response.clone(), "address", &[]);
let mut tag: Value = Value::Null;
let mut address: Value = Value::Null;
if (rawAddress != Value::Null) {
let mut addressParts: Value = split(&rawAddress, &Value::Str(";".into()));
// if a tag or memo is used it is separated by a colon in the 'address' value
tag = self.safe_string(addressParts.clone(), Value::Int(0), &[]);
address = self.safe_string(addressParts, Value::Int(1), &[]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null));
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
m
});
Value::Null
}
pub fn parse_transaction_state(&self, mut state: Value) -> Option<String> {
let mut states: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("COMPLETED".to_string(), Value::Str("ok".into()));
m.insert("REJECTED".to_string(), Value::Str("failed".into()));
m.insert("PENDING".to_string(), Value::Str("pending".into()));
m.insert("FAILED".to_string(), Value::Str("failed".into()));
m.insert("REFUNDED".to_string(), Value::Str("refunded".into()));
m
});
return self.safe_string(states, state.clone(), &[state.clone()]).as_str().map(str::to_owned);
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// deposit
//
// {
// "depositId":"748e9180-be0d-4a80-e175-0156150efc95",
// "amount":0.009,
// "currency":"ETH",
// "address":"0xEC6B5929D454C8D9546d4221ace969E1810Fa92c",
// "state":"COMPLETED",
// "txHash":"582114562140e51a80b481c2dfebaf62b4ab9769b8ff54820bb67e34d4a3ab0c",
// "timestamp":1633697196241
// }
//
// withdrawal
//
// {
// "amount":30.0,
// "currency":"USDT",
// "beneficiary":"cab00d11-6e7f-46b7-b453-2e8ef6f101fa", // blockchain specific id
// "withdrawalId":"99df5ef7-eab6-4033-be49-312930fbd1ea",
// "fee":34.005078,
// "state":"COMPLETED",
// "timestamp":1634218452549
// }
//
let mut type_var: Value = Value::Null;
let mut id: Value = Value::Null;
let mut amount: Value = self.safe_number_k(transaction.clone(), "amount", &[]);
let mut timestamp: Value = self.safe_integer_k(transaction.clone(), "timestamp", &[]);
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[currency]);
let mut state: Value = self.safe_string_k(transaction.clone(), "state", &[]);
if (matches!(&transaction, Value::Dict(__d) if __d.contains_key("depositId"))) {
type_var = Value::Str("deposit".into());
id = self.safe_string_k(transaction.clone(), "depositId", &[]);
} else if (matches!(&transaction, Value::Dict(__d) if __d.contains_key("withdrawalId"))) {
type_var = Value::Str("withdrawal".into());
id = self.safe_string_k(transaction.clone(), "withdrawalId", &[]);
}
let mut feeCost: Value = (if (type_var.as_str() == Some("withdrawal")) { self.safe_number_k(transaction.clone(), "fee", &[]) } else { Value::Null });
let mut fee: Value = Value::Null;
if (feeCost != Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), feeCost);
m
});
}
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut txid: Value = self.safe_string_k(transaction.clone(), "txhash", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction);
m.insert("id".to_string(), id);
m.insert("txid".to_string(), txid);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("network".to_string(), Value::Null);
m.insert("addressFrom".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), address);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tag".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("type".to_string(), type_var);
m.insert("amount".to_string(), amount);
m.insert("currency".to_string(), code);
m.insert("status".to_string(), self.parse_transaction_state(state).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("updated".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), fee);
m
});
Value::Null
}
/*
* @method
* @name blockchaincom#withdraw
* @description make a withdrawal
* @see https://api.blockchain.com/v3/#createwithdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amount);
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("beneficiary".to_string(), address);
m.insert("sendMax".to_string(), Value::Bool(false));
m
});
let __ws_arg_9 = self.extend(request, &[params]);
let mut response: Value = self.private_post_withdrawals(&[__ws_arg_9]).await;
return self.parse_transaction(response, &[currency]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://api.blockchain.com/v3/#getwithdrawals
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("from".into(), since.clone()); }
}
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
}
let __ws_arg_10 = self.extend(request, &[params]);
let mut response: Value = self.private_get_withdrawals(&[__ws_arg_10]).await;
return self.parse_transactions(response, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchWithdrawal
* @description fetch data on a currency withdrawal via the withdrawal id
* @see https://api.blockchain.com/v3/#getwithdrawalbyid
* @param {string} id withdrawal id
* @param {string} code not used by blockchaincom.fetchWithdrawal
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawal(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdrawalId".to_string(), id);
m
});
let __ws_arg_11 = self.extend(request, &[params]);
let mut response: Value = self.private_get_withdrawals_withdrawal_id(&[__ws_arg_11]).await;
return self.parse_transaction(response, &[]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchDeposits
* @description fetch all deposits made to an account
* @see https://api.blockchain.com/v3/#getdeposits
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("from".into(), since.clone()); }
}
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
}
let __ws_arg_12 = self.extend(request, &[params]);
let mut response: Value = self.private_get_deposits(&[__ws_arg_12]).await;
return self.parse_transactions(response, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchDeposit
* @description fetch information on a deposit
* @see https://api.blockchain.com/v3/#getdepositbyid
* @param {string} id deposit id
* @param {string} code not used by fetchDeposit ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposit(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut depositId: Value = self.safe_string_k(params.clone(), "depositId", &[id]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("depositId".to_string(), depositId);
m
});
let __ws_arg_13 = self.extend(request, &[params]);
let mut deposit: Value = self.private_get_deposits_deposit_id(&[__ws_arg_13]).await;
return self.parse_transaction(deposit, &[]);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://api.blockchain.com/v3/#getaccounts
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut accountName: Value = self.safe_string_k(params.clone(), "account", &[Value::Str("primary".into())]);
params = self.omit(params.clone(), Value::Str("account".into()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account".to_string(), accountName.clone());
m
});
let __ws_arg_14 = self.extend(request, &[params]);
let mut response: Value = self.private_get_accounts(&[__ws_arg_14]).await;
//
// {
// "primary": [
// {
// "currency":"ETH",
// "balance":0.009,
// "available":0.009,
// "balance_local":30.82869,
// "available_local":30.82869,
// "rate":3425.41
// },
// ...
// ]
// }
//
let mut balances: Value = self.safe_list(response.clone(), accountName.clone(), &[]);
if (balances == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchBalance() could not find the \"".into())).into()), accountName).into()), Value::Str("\" account".into()))));
}
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_441: bool = true;
while { if !__for_first_441 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_441 = false; i.as_f64().unwrap_or(f64::NAN) < ((balances.len() as i64) as f64) } {
let mut entry: Value = balances.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(entry.clone(), "available", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string_k(entry, "balance", &[])); }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
return self.safe_balance(result);
Value::Null
}
/*
* @method
* @name blockchaincom#fetchOrder
* @description fetches information on an order made by the user
* @see https://api.blockchain.com/v3/#getorderbyid
* @param {string} id the order id
* @param {string} symbol not used by blockchaincom fetchOrder
* @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 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
}));
// note: only works with exchange-order-id
// does not work with clientOrderId
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id);
m
});
let __ws_arg_15 = self.extend(request, &[params]);
let mut response: Value = self.private_get_orders_order_id(&[__ws_arg_15]).await;
return self.parse_order(response, &[]);
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut requestPath: Value = Value::Str(format!("{}{}", Value::Str("/".into()), self.implode_params(path.clone(), params.clone())).into());
let mut url: Value = add(&get_value(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), &api), &requestPath);
let mut query: Value = self.omit(params, self.extract_params(path), &[]);
if (api.as_str() == Some("public")) {
if ((object_keys(&query).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
} else if (api.as_str() == Some("private")) {
self.check_required_credentials(&[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-API-Token".to_string(), self.secret.clone());
m
});
if (method.as_str() == Some("GET")) {
if ((object_keys(&query).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
} else {
body = json_stringify(&query);
if let Value::Dict(__d) = &mut headers { std::sync::Arc::make_mut(__d).insert("Content-Type".into(), Value::Str("application/json".into())); }
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), body);
m.insert("headers".to_string(), headers);
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: 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 {
// {"timestamp":"2021-10-21T15:13:58.837+00:00","status":404,"error":"Not Found","message":"","path":"/orders/505050"
if (response == Value::Null) {
return Value::Null;
}
let mut text: Option<String> = self.safe_string_k(response.clone(), "text", &[]).as_str().map(str::to_owned);
if (text.is_some()) {
if (text.as_deref() == Some("Insufficient Balance")) {
panic!("{}", crate::exchange_errors::insufficient_funds(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body)));
}
}
let mut errorCode: Value = self.safe_string_k(response.clone(), "status", &[]);
let mut errorMessage: Value = self.safe_string_k(response.clone(), "error", &[]);
if (code != Value::Null) {
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), json_stringify(&response)).into());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), errorCode, feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), errorMessage, feedback);
}
return Value::Null;
Value::Null
}
}