// 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 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.clone()])
}
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.clone()])
}
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.clone()])
}
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.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 BlockchaincomCore.
BlockchaincomCore::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 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.get(0..).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,
"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,
"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_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_l3_order_book" => self.fetch_l3_order_book(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_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_by_state" => self.fetch_orders_by_state(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawal" => self.fetch_withdrawal(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).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.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_state" => self.parse_order_state(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"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_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_state" => self.parse_transaction_state(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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 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".to_string()));
m.insert("secret".to_string(), Value::Null);
m.insert("name".to_string(), Value::Str("Blockchain.com".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("LX".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(500));
m.insert("version".to_string(), Value::Str("v3".to_string()));
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".to_string()));
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".to_string()));
m.insert("private".to_string(), Value::Str("https://testnet-api.delta.exchange".to_string()));
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".to_string()));
m.insert("private".to_string(), Value::Str("https://api.blockchain.com/v3/exchange".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://blockchain.com".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://api.blockchain.com/v3".to_string())]));
m.insert("fees".to_string(), Value::Str("https://exchange.blockchain.com/fees".to_string()));
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("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".to_string()));
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::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.0045".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10000".to_string()), &[]), self.parse_number(Value::Str("0.0035".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("0.0018".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("0.0018".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("500000".to_string()), &[]), self.parse_number(Value::Str("0.0018".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000000".to_string()), &[]), self.parse_number(Value::Str("0.0018".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("2500000".to_string()), &[]), self.parse_number(Value::Str("0.0018".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000000".to_string()), &[]), self.parse_number(Value::Str("0.0016".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("25000000".to_string()), &[]), self.parse_number(Value::Str("0.0014".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000000".to_string()), &[]), self.parse_number(Value::Str("0.0011".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("500000000".to_string()), &[]), self.parse_number(Value::Str("0.0008".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000000000".to_string()), &[]), self.parse_number(Value::Str("0.0006".to_string()), &[])])]));
m.insert("maker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.004".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10000".to_string()), &[]), self.parse_number(Value::Str("0.0017".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("0.0015".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("0.0008".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("500000".to_string()), &[]), self.parse_number(Value::Str("0.0007".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000000".to_string()), &[]), self.parse_number(Value::Str("0.0006".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("2500000".to_string()), &[]), self.parse_number(Value::Str("0.0005".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000000".to_string()), &[]), self.parse_number(Value::Str("0.0004".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("25000000".to_string()), &[]), self.parse_number(Value::Str("0.0003".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000000".to_string()), &[]), self.parse_number(Value::Str("0.0002".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("500000000".to_string()), &[]), self.parse_number(Value::Str("0.0001".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000000000".to_string()), &[]), self.parse_number(Value::Str("0".to_string()), &[])])]));
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".to_string()));
m.insert("TRC20".to_string(), Value::Str("TRX".to_string()));
m.insert("ALGO".to_string(), Value::Str("ALGO".to_string()));
m.insert("ADA".to_string(), Value::Str("ADA".to_string()));
m.insert("AR".to_string(), Value::Str("AR".to_string()));
m.insert("ATOM".to_string(), Value::Str("ATOM".to_string()));
m.insert("AVAXC".to_string(), Value::Str("AVAX".to_string()));
m.insert("BCH".to_string(), Value::Str("BCH".to_string()));
m.insert("BSV".to_string(), Value::Str("BSV".to_string()));
m.insert("BTC".to_string(), Value::Str("BTC".to_string()));
m.insert("DCR".to_string(), Value::Str("DCR".to_string()));
m.insert("DESO".to_string(), Value::Str("DESO".to_string()));
m.insert("DASH".to_string(), Value::Str("DASH".to_string()));
m.insert("CELO".to_string(), Value::Str("CELO".to_string()));
m.insert("CHZ".to_string(), Value::Str("CHZ".to_string()));
m.insert("MATIC".to_string(), Value::Str("MATIC".to_string()));
m.insert("SOL".to_string(), Value::Str("SOL".to_string()));
m.insert("DOGE".to_string(), Value::Str("DOGE".to_string()));
m.insert("DOT".to_string(), Value::Str("DOT".to_string()));
m.insert("EOS".to_string(), Value::Str("EOS".to_string()));
m.insert("ETC".to_string(), Value::Str("ETC".to_string()));
m.insert("FIL".to_string(), Value::Str("FIL".to_string()));
m.insert("KAVA".to_string(), Value::Str("KAVA".to_string()));
m.insert("LTC".to_string(), Value::Str("LTC".to_string()));
m.insert("IOTA".to_string(), Value::Str("MIOTA".to_string()));
m.insert("NEAR".to_string(), Value::Str("NEAR".to_string()));
m.insert("STX".to_string(), Value::Str("STX".to_string()));
m.insert("XLM".to_string(), Value::Str("XLM".to_string()));
m.insert("XMR".to_string(), Value::Str("XMR".to_string()));
m.insert("XRP".to_string(), Value::Str("XRP".to_string()));
m.insert("XTZ".to_string(), Value::Str("XTZ".to_string()));
m.insert("ZEC".to_string(), Value::Str("ZEC".to_string()));
m.insert("ZIL".to_string(), Value::Str("ZIL".to_string()));
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".to_string()).clone());
m.insert("404".to_string(), Value::Str("OrderNotFound".to_string()).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.clone()]).await;
let mut marketIds: Value = object_keys(&markets);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_436: bool = true;
while { if !__for_first_436 { i = add(&i, &Value::Int(1)); } __for_first_436 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut market: Value = self.safe_value(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: Value = self.safe_string_k(market.clone(), "status", &[]);
if is_equal(&marketState, &Value::Str("open".to_string())) {
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.clone()]);
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.clone()]);
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.clone()]);
let mut minOrderSizePreciseString: Value = crate::precise::Precise::stringMul(&minOrderSizeString, &minOrderSizeScalePrecisionString);
let mut minOrderSize: Value = self.parse_number(minOrderSizePreciseString.clone(), &[]);
// maximum order size
let mut maxOrderSize: Value = Value::Null;
let mut maxOrderSizeRaw: Value = self.safe_string_k(market.clone(), "max_order_size", &[]);
if !is_equal(&maxOrderSizeRaw, &Value::Str("0".to_string())) {
let mut maxOrderSizeScaleString: Value = self.safe_string_k(market.clone(), "max_order_size_scale", &[]);
let mut maxOrderSizeScalePrecisionString: Value = self.parse_precision(&[maxOrderSizeScaleString.clone()]);
let mut maxOrderSizeValueString: Value = crate::precise::Precise::stringMul(&maxOrderSizeRaw, &maxOrderSizeScalePrecisionString);
maxOrderSize = self.parse_number(maxOrderSizeValueString.clone(), &[]);
}
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), market.clone());
m.insert("id".to_string(), marketId.clone());
m.insert("numericId".to_string(), numericId.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
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.clone());
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.clone(), &[]));
m.insert("price".to_string(), self.parse_number(pricePrecisionString.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(), 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.clone());
m.insert("max".to_string(), maxOrderSize.clone());
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.clone(), &[limit.clone(), params.clone()]).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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("depth".to_string()), limit.clone());
}
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_l3_symbol(&[__ws_arg_0]).await;
return self.parse_order_book(response.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[Value::Null, Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("px".to_string()), Value::Str("qty".to_string())]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("depth".to_string()), limit.clone());
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_l2_symbol(&[__ws_arg_1]).await;
return self.parse_order_book(response.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[Value::Null, Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("px".to_string()), Value::Str("qty".to_string())]);
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.clone(), &[market.clone(), Value::Str("-".to_string())]);
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.clone());
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.clone());
m.insert("close".to_string(), Value::Null);
m.insert("last".to_string(), last.clone());
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.clone());
m.insert("quoteVolume".to_string(), Value::Null);
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_tickers_symbol(&[__ws_arg_2]).await;
return self.parse_ticker(response.clone(), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut tickers: Value = self.public_get_tickers(&[params.clone()]).await;
return self.parse_tickers(tickers.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_order_state(&self, mut state: Value) -> Value {
let mut states: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OPEN".to_string(), Value::Str("open".to_string()));
m.insert("REJECTED".to_string(), Value::Str("rejected".to_string()));
m.insert("FILLED".to_string(), Value::Str("closed".to_string()));
m.insert("CANCELED".to_string(), Value::Str("canceled".to_string()));
m.insert("PART_FILLED".to_string(), Value::Str("open".to_string()));
m.insert("EXPIRED".to_string(), Value::Str("expired".to_string()));
m
});
return self.safe_string(states.clone(), state.clone(), &[state.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);
//
// {
// "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(order.clone(), Value::Str("ordType".to_string()), &[]);
let mut statusId: Value = self.safe_string_k(order.clone(), "ordStatus", &[]);
let mut state: Value = self.parse_order_state(statusId.clone());
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Str("-".to_string())]);
let mut exchangeOrderId: Value = self.safe_string_k(order.clone(), "exOrdId", &[]);
let mut price: Value = ternary(is_true(&(!is_equal(&type_var, &Value::Str("market".to_string())))), self.safe_string_k(order.clone(), "price", &[]), 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.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("datetime".to_string(), datetime.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), state.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("average".to_string(), average.clone());
m.insert("amount".to_string(), Value::Null);
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), remaining.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("trades".to_string(), Value::List(vec![]));
m.insert("fees".to_string(), Value::List(vec![]));
m.insert("info".to_string(), order.clone());
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 is_equal(&self.markets, &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.clone()]);
let mut uppercaseOrderType: Value = to_upper(&orderType);
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("clOrdId".to_string()), &[self.uuid16(&[])]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("ordType".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("clOrdId".to_string())]), &[]);
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a side argument".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ordType".to_string(), uppercaseOrderType.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), to_upper(&side));
m.insert("orderQty".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m.insert("clOrdId".to_string(), clientOrderId.clone());
m
});
let mut triggerPrice: Value = self.safe_value_n(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPx".to_string()), Value::Str("stopPrice".to_string())]), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPx".to_string()), Value::Str("stopPrice".to_string())]), &[]);
if is_equal(&uppercaseOrderType, &Value::Str("STOP".to_string())) || is_equal(&uppercaseOrderType, &Value::Str("STOPLIMIT".to_string())) {
if is_equal(&triggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" createOrder() requires a stopPx or triggerPrice param for a ".to_string())), &uppercaseOrderType), &Value::Str(" order".to_string()))));
}
}
if !is_equal(&triggerPrice, &Value::Null) {
if is_equal(&uppercaseOrderType, &Value::Str("MARKET".to_string())) {
add_element_to_object(&mut request, &Value::Str("ordType".to_string()), Value::Str("STOP".to_string()));
} else if is_equal(&uppercaseOrderType, &Value::Str("LIMIT".to_string())) {
add_element_to_object(&mut request, &Value::Str("ordType".to_string()), Value::Str("STOPLIMIT".to_string()));
}
}
let mut priceRequired: bool = false;
let mut stopPriceRequired: bool = false;
if is_equal(&get_value(&request, &Value::Str("ordType".to_string())), &Value::Str("LIMIT".to_string())) || is_equal(&get_value(&request, &Value::Str("ordType".to_string())), &Value::Str("STOPLIMIT".to_string())) {
priceRequired = true;
}
if is_equal(&get_value(&request, &Value::Str("ordType".to_string())), &Value::Str("STOP".to_string())) || is_equal(&get_value(&request, &Value::Str("ordType".to_string())), &Value::Str("STOPLIMIT".to_string())) {
stopPriceRequired = true;
}
if is_true(&priceRequired) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if is_true(&stopPriceRequired) {
add_element_to_object(&mut request, &Value::Str("stopPx".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
}
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_orders(&[__ws_arg_3]).await;
return self.parse_order(response.clone(), &[market.clone()]);
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.clone(), &[params.clone()]);
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.clone());
m.insert("info".to_string(), response.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
let mut marketId: Value = self.market_id(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), marketId.clone());
}
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete_orders(&[__ws_arg_5]).await;
return Value::List(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_fees(&[params.clone()]).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_437: bool = true;
while { if !__for_first_437 { i = add(&i, &Value::Int(1)); } __for_first_437 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
add_element_to_object(&mut result, &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".to_string());
return self.fetch_orders_by_state(state.clone(), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).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".to_string());
return self.fetch_orders_by_state(state.clone(), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).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".to_string());
return self.fetch_orders_by_state(state.clone(), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), state.clone());
m.insert("limit".to_string(), Value::Int(100));
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("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders(&[__ws_arg_6]).await;
return self.parse_orders(response.clone(), &[market.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);
//
// {
// "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(trade.clone(), Value::Str("side".to_string()), &[]);
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.clone(), market.clone(), Value::Str("-".to_string())]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "fee", &[]);
if !is_equal(&feeCostString, &Value::Null) {
let mut feeCurrency: Value = get_value(&market, &Value::Str("quote".to_string()));
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.clone());
m.insert("currency".to_string(), feeCurrency.clone());
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), tradeId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), datetime.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), trade.clone());
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
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 mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.market_id(symbol.clone()));
market = self.market(symbol.clone());
}
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut trades: Value = self.private_get_fills(&[__ws_arg_7]).await;
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
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 !is_equal(&rawAddress, &Value::Null) {
let mut addressParts: Value = split(&rawAddress, &Value::Str(";".to_string()));
// 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.clone(), Value::Int(1), &[]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("code".to_string())));
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m
});
Value::Null
}
pub fn parse_transaction_state(&self, mut state: Value) -> Value {
let mut states: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("COMPLETED".to_string(), Value::Str("ok".to_string()));
m.insert("REJECTED".to_string(), Value::Str("failed".to_string()));
m.insert("PENDING".to_string(), Value::Str("pending".to_string()));
m.insert("FAILED".to_string(), Value::Str("failed".to_string()));
m.insert("REFUNDED".to_string(), Value::Str("refunded".to_string()));
m
});
return self.safe_string(states.clone(), state.clone(), &[state.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);
//
// 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.clone(), &[currency.clone()]);
let mut state: Value = self.safe_string_k(transaction.clone(), "state", &[]);
if is_true(&Value::Bool(in_op(&transaction, &Value::Str("depositId".to_string())))) {
type_var = Value::Str("deposit".to_string());
id = self.safe_string_k(transaction.clone(), "depositId", &[]);
} else if is_true(&Value::Bool(in_op(&transaction, &Value::Str("withdrawalId".to_string())))) {
type_var = Value::Str("withdrawal".to_string());
id = self.safe_string_k(transaction.clone(), "withdrawalId", &[]);
}
let mut feeCost: Value = ternary(is_true(&(is_equal(&type_var, &Value::Str("withdrawal".to_string())))), self.safe_number_k(transaction.clone(), "fee", &[]), Value::Null);
let mut fee: Value = Value::Null;
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(), feeCost.clone());
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.clone());
m.insert("id".to_string(), id.clone());
m.insert("txid".to_string(), txid.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
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.clone());
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.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), self.parse_transaction_state(state.clone()));
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.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amount.clone());
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("beneficiary".to_string(), address.clone());
m.insert("sendMax".to_string(), Value::Bool(false));
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_withdrawals(&[__ws_arg_9]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("from".to_string()), since.clone());
}
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_withdrawals(&[__ws_arg_10]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdrawalId".to_string(), id.clone());
m
});
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_withdrawals_withdrawal_id(&[__ws_arg_11]).await;
return self.parse_transaction(response.clone(), &[]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("from".to_string()), since.clone());
}
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deposits(&[__ws_arg_12]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut depositId: Value = self.safe_string_k(params.clone(), "depositId", &[id.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("depositId".to_string(), depositId.clone());
m
});
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut deposit: Value = self.private_get_deposits_deposit_id(&[__ws_arg_13]).await;
return self.parse_transaction(deposit.clone(), &[]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut accountName: Value = self.safe_string_k(params.clone(), "account", &[Value::Str("primary".to_string())]);
params = self.omit(params.clone(), Value::Str("account".to_string()), &[]);
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.clone(), &[params.clone()]);
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_value(response.clone(), accountName.clone(), &[]);
if is_equal(&balances, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&add(&self.id, &Value::Str(" fetchBalance() could not find the \"".to_string())), &accountName), &Value::Str("\" account".to_string()))));
}
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_438: bool = true;
while { if !__for_first_438 { i = add(&i, &Value::Int(1)); } __for_first_438 = false; is_less_than(&i, &get_array_length(&balances)) } {
let mut entry: Value = get_value(&balances, &i);
let mut entry: Value = get_value(&balances, &i);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "currency", &[]);
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(entry.clone(), "available", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(entry.clone(), "balance", &[]));
add_element_to_object(&mut result, &code, account.clone());
}
}
return self.safe_balance(result.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id.clone());
m
});
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_order_id(&[__ws_arg_15]).await;
return self.parse_order(response.clone(), &[]);
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 requestPath: Value = add(&Value::Str("/".to_string()), &self.implode_params(path.clone(), params.clone()));
let mut url: Value = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), &requestPath);
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if is_equal(&api, &Value::Str("public".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
} else if is_equal(&api, &Value::Str("private".to_string())) {
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 is_true(&(is_equal(&method, &Value::Str("GET".to_string())))) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
} else {
body = self.json(query.clone());
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
}
}
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
}
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 is_equal(&response, &Value::Null) {
return Value::Null;
}
let mut text: Value = self.safe_string_k(response.clone(), "text", &[]);
if !is_equal(&text, &Value::Null) {
if is_equal(&text, &Value::Str("Insufficient Balance".to_string())) {
panic!("{}", crate::exchange_errors::insufficient_funds(add(&add(&self.id, &Value::Str(" ".to_string())), &body)));
}
}
let mut errorCode: Value = self.safe_string_k(response.clone(), "status", &[]);
let mut errorMessage: Value = self.safe_string_k(response.clone(), "error", &[]);
if !is_equal(&code, &Value::Null) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &self.json(response.clone()));
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorCode.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), errorMessage.clone(), feedback.clone());
}
return Value::Null;
Value::Null
}
}