Mint USDX Using BNB (Ledger Guide)

Scott Stuart
4 min readJun 16, 2020

--

Kava is a cross-chain DeFi lending platform enabling stablecoin loans to users of major cryptocurrencies. In order to mint USDX, the USD-pegged stablecoin on Kava, you need to move your BNB to Kava. This guide will show you how to open a CDP and mint USDX on Kava using Ledger Nano S and the command-line interfaces (CLI) for Binance chain and Kava.

Note: Minting USDX using Ledger requires some knowledge of the command line interface (CLI), you may also reference kava.io for other options to mint USDX.

Mint USDX with you Ledger Nano S

1. Install bnbcli and kvcli

First you need to install bnbcli and kvcli, the command-line interfaces for Binance Chain and Kava.

a.) Binance Chain

To download the bnbcli, we will use the official node binaries and download v0.6.2 (note that v0.6.3 has a bug that makes it incompatible with ledger) for Mac. If you are on windows or linux, adjust the url to your operating system.

wget https://github.com/binance-chain/node-binary/raw/master/cli/prod/0.6.2/mac/bnbcli# verify the shasum
shasum -a 256 bnbcli
# af7d895b50ea996325e1788a093769f111f655f5753331be4128f5050d1ea144
# make the file executable
chmod +x bnbcli
# verify version
./bnbcli version
# Binance Chain Release: 0.6.2;Binance Chain Commit: 7182ae6; Cosmos Release: =v0.25.0-binance.19; Tendermint Release: =v0.31.5-binance.2;

b.) Kava

Requires golang 1.13+

# clone the kava repo
git clone https://github.com/kava-labs/kava && cd kava
git checkout v0.8.1
make install
# verify the installation
kvcli version --long
# name: kava
# server_name: kvd
# client_name: kvcli
# version: 0.8.1
# commit: 869189054d68d6ec3e6446156ea0a91eb45af09c
# build_tags: netgo,ledger
# go: go version go1.13 darwin/amd64

2. Install Ledger Apps

Using Ledger Live, install the Binance chain and cosmos apps on your ledger. I have tested with:

  • binance chain app v1.1.6
  • cosmos app v1.5.3 and v2.14.0. Note that v2.14.0 has a bug where the messages don’t display properly — but it does work.

3. Transfer BNB to Kava

Kava and Binance chain use a protocol called BEP3 to transfer BNB (using fast atomic swaps) between the chains. Note that the deputy processes that manages the bridge between Kava and Binance chain is run by Binance.

We will use the following addresses in this example:

# Users address on binance-chain (key name: userkey-bc): bnb19763hpfdrjnudy3zyd4lz3h8k95y6ym9jkxnz4# Deputy address on binance-chian: bnb1jh7uv2rm6339yue8k4mj9406k3509kr4wt5nxn# Users address on kava (key name: userkey-kava):
kava1vftgwrsy464700h2lj52xranj0ven5lrs76jjx
# Deputy address on kava: kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6

a.) Add binance address from ledger (with Binance chain app open):

./bnbcli keys add userkey-bc --ledger --account 0

b.) Add kava address from ledger (with cosmos app open)

kvcli keys add userkey-kava --ledger --account 0 --legacy-hd-path

c.) We will transfer 3 BNB. At the time of writing, 1 BNB = ~$16 USD

# Create bep3 swap for 3BNB./bnbcli token HTLT --amount "300000000:BNB" --recipient-addr bnb1jh7uv2rm6339yue8k4mj9406k3509kr4wt5nxn --cross-chain true --from userkey-bc --recipient-other-chain "kava1vftgwrsy464700h2lj52xranj0ven5lrs76jjx" --sender-other-chain "kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6" --expected-income "300000000:BNB" --height-span 10001 --chain-id=Binance-Chain-Tigris --node=tcp://dataseed1.binance.org:80

This will return

Random number (keep this secret!): 443305478a56f81bdc7a7136fd4c3eba58739ad90f07fa64f4c3938c5c9e63c7Timestamp: 1592245410Random number hash: ced412d9cde8b084a378a60712665f271a654a841211375b59b78669a27dea68

Write these down before proceeding! If you lose them, you won’t be able to process the transfer on kava and you will have to send a refund transaction on binance chain. Your funds will not be at risk, but you will have to wait 10001 blocks on binance chain to get your refund.

4: Claim BNB on Kava

You now have a swap waiting to be claimed on kava. First, you need to calculate what the swap-id on kava will be using kvcli.

a.) Calculate the swap id:

# The syntax is kvcli query bep3 calc-swapid [random-number-hash] [sender] [sender-other-chain]# Where random number hash is the value that was returned by bnbcli HTLT create command# sender is the user's address on binance chain
# senderOtherChain is the deputy's address on kava
kvcli q bep3 calc-swapid ced412d9cde8b084a378a60712665f271a654a841211375b59b78669a27dea68 bnb19763hpfdrjnudy3zyd4lz3h8k95y6ym9jkxnz4 kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6

This will return a swap-id that looks like:

a69394823f1ac2386dc55bce1de43b66cdf225ae138d51e9d2ffb43922b5bc03

b.) Claim the swap on Kava:

# The syntax is kvcli tx bep3 claim [swap-id] [random-number]
# Where swap-id is the value we calculated above
# And random number is the value that was returned by bnbcli HTLT create command
kvcli tx bep3 claim a69394823f1ac2386dc55bce1de43b66cdf225ae138d51e9d2ffb43922b5bc03 443305478a56f81bdc7a7136fd4c3eba58739ad90f07fa64f4c3938c5c9e63c7 -- from userkey-kava

After the transaction is accepted, you can view your bnb balance on kava. Note the deputy takes a fee of 0.00001BNB per swap, so you won’t have exactly 3BNB.

kvcli q account kava1vftgwrsy464700h2lj52xranj0ven5lrs76jjx# Will return something like
address: kava1vftgwrsy464700h2lj52xranj0ven5lrs76jjx
coins:
- denom: bnb
amount: "299999000"
public_key: kavapub1addwnpepqdl9u5uavhvdfxse2c6j6r03v9yh600qq4r8s36jr4r3e0d93kkmgm7q28w
account_number: 205
sequence: 2

Great! You now have BNB on Kava!

5. Mint USDX by Creating a CDP

You can now open a cdp. In this example, we’ll open a cdp for the minimum possible amount — 10USDX (note 1000000usdx on kvcli = 1USDX). Since we have about ~$50 in BNB as collateral, this will give us a collateralization ratio of ~5.0. Note that a CDP must maintain a collateralization ratio above 1.5 or it will be liquidated!

kvcli tx cdp create 299999000bnb 10000000usdx --from userkey-kava --gas 500000

After the transaction is accepted, you can view your cdp:

kvcli q cdp cdp # Will return something like
- cdp:
id: 1
owner: kava1vftgwrsy464700h2lj52xranj0ven5lrs76jjx
collateral:
denom: bnb
amount: "299999000"
principal:
denom: usdx
amount: "10000000"
accumulated_fees:
denom: usdx
amount: "102"
fees_updated: 2020-06-15T18:39:10.657126801Z
collateral_value:
denom: usdx
amount: "48805959"
collateralization_ratio: "4.880595956438548281"

Congrats! You’ve now minted USDX using Ledger!

Stay in touch!

Disclaimer: This content is provided for informational purposes only, and should not be relied upon as legal, business, investment, or tax advice. You should consult your own advisers as to those matters. References to any securities or digital assets are for illustrative purposes only, and do not constitute an investment recommendation or offer to provide investment advisory services. Furthermore, this content is not directed at nor intended for use by any investors or prospective investors, and may not under any circumstances be relied upon when making investment decisions.

--

--