{binance} Dealing with Dust
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Dust refers to the fragments of coins which are too small to use for transactions. In the fiat world the equivalent would be those worthless coins with too little value to actually buy anything, that take up space in your wallet and end up scattered across parking areas.
Binance allows you to convert dust into BNB. In this post I discuss the functions in {binance}
which support this operation.
I’ve got a bit of dust in my wallet.
For some coins (like USDT) the dust motes are too small to do anything. However, others like BTC and BUSD can be converted into BNB. We’ll sweep up the fragments of BTC using {binance}
.
First load and authenticate.
library(binance) authenticate( key = Sys.getenv("BINANCE_API_KEY"), secret = Sys.getenv("BINANCE_API_SECRET") ) packageVersion("binance") [1] ‘0.0.2’
Sweeping the Dust
Now call wallet_dust_transfer()
.
(dust <- wallet_dust_transfer("BTC")) # A tibble: 1 × 3 total_transfered total_service_charge transfer_result <dbl> <dbl> <list> 1 0.00036845 0.00000736 <tibble [1 × 6]>
At first glance the numbers in the response don’t look right. But on further inspection, that’s because they are in BNB not BTC.
We can delve a little deeper by looking at the transfer_result
element.
dust$transfer_result [[1]] # A tibble: 1 × 6 tran_id from_asset amount transfered_amount service_charge_amount operate_time <dbl> <chr> <dbl> <dbl> <dbl> <dttm> 1 82958275470 BTC 0.00000285 0.00036845 0.00000736 2021-10-28 04:55:02
Logging the Dust
You can only transfer dust once every six hours. It’s useful to see a record of when and how much dust has been transferred.
(dribblets <- wallet_dust_log()) # A tibble: 2 × 5 operate_time total_service_charge_amount total_transfered_amount trans_id details <dttm> <dbl> <dbl> <dbl> <list> 1 2021-10-27 13:49:53 0.00000233 0.000117 82823948070 <tibble [1 × 6]> 2 2021-10-28 04:55:03 0.00000736 0.000368 82958275470 <tibble [1 × 6]>
More than one coin can be swept up at once. If there are multiple coins involved then you’ll see them in the details.
bind_rows(dribblets$details) # A tibble: 2 × 6 from_asset amount transfered_amount service_charge_amount operate_time trans_id <chr> <dbl> <dbl> <dbl> <dttm> <dbl> 1 ENJ 0.025 0.000117 0.00000233 2021-10-27 13:49:53 82823948070 2 BTC 0.00000285 0.000368 0.00000736 2021-10-28 04:55:03 82958275470
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.