Retrieves detailed information for a specified currency from the KuCoin API asynchronously, including chain-specific details for multi-chain currencies.
Usage
get_currency_impl(
base_url = get_base_url(),
currency,
chain = NULL,
.__coro_env_parent__ = <environment>
)
Arguments
- base_url
Character string; base URL for the KuCoin API. Defaults to
get_base_url()
.- currency
Character string; currency code (e.g.,
"BTC"
,"USDT"
).- chain
Character string (optional); specific chain for multi-chain currencies (e.g.,
"ERC20"
,"TRC20"
).
Value
Promise resolving to a data.table
containing:
currency
(character): Unique currency code.name
(character): Short name of the currency.fullName
(character): Full name of the currency.precision
(integer): Decimal places for the currency.confirms
(integer or NULL): Block confirmations required.contractAddress
(character or NULL): Contract address for tokenized currencies.isMarginEnabled
(logical): Margin trading enabled status.isDebitEnabled
(logical): Debit enabled status.Chain-specific fields (e.g.,
chainName
,withdrawalMinSize
) from thechains
list.
Details
Workflow Overview
Query Construction: Builds a query string with the optional
chain
parameter usingbuild_query()
.URL Assembly: Combines
base_url
,/api/v3/currencies/
, thecurrency
code, and the query string.HTTP Request: Sends a GET request with a 10-second timeout via
httr::GET()
.Response Processing: Validates the response with
process_kucoin_response()
and extracts the"data"
field.Data Conversion: Splits
"data"
into summary fields andchains
data, combining them into adata.table
.
Usage
Utilised to obtain metadata (e.g., precision, chain support) for a specific currency on KuCoin.
Examples
if (FALSE) { # \dontrun{
main_async <- coro::async(function() {
# Bitcoin details
btc <- await(get_currency_impl(currency = "BTC"))
print(btc)
# USDT on ERC20 chain
usdt_erc20 <- await(get_currency_impl(currency = "USDT", chain = "ERC20"))
print(usdt_erc20)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }