Coin conversion

From Minter Wiki


In the Minter network, coin conversion is an exchange of any coin that is issued in the network for another one. Since custom coins created in the Minter network are provided with a reserve in BIP, they can be instantly converted back to BIP or to any other coin issued in the network.

Immediately after issue, the coin has real value that is provided by the reserve and an economic component. Moreover, the reserve creates both absolute and instant liquidity for all market participants, since each coin can be exchanged for any other one in just a couple of clicks and without an intermediary. This principle is described in detail in the article Perpetual Coin Offering (PCO).

Every time people exchange one coin for another one, they burn (reduce) the emission of one coin and transfer the BIP reserve to another one (issue), making the latter one more expensive.

Services for coin conversion

There’s no need for any external and third-party services to convert tokens in the Minter network. This operation can be carried out in any of the available wallets: the Console, Android wallet, iOS wallet.

Coin conversion in the Console

The most advanced functionality for the coin conversion in the Minter network is presented in the Console on the Conversion tab.

ConsoleConvert.png

Conversion options:

  • Sale of the coins - we can indicate the exact number of coins for sale and choose a coin that is different from the one being sold as commission payment;
  • Sale of all coins - it is enough for us to click one button for the commission to be automatically taken out of the number of coins sold and for all the remaining coins to be exchanged. This option is convenient to avoid “crumbs” forming in your wallet;
  • Purchase of coins - The option for the accurate indication of the number of coins purchased. It is similar to the first option and is convenient when you need to buy a certain number of coins (making a payment for some service, for example).

In any of the options above you have to:

  • Choose a coin for sale from the list of coins available in your wallet;
  • Write the Ticker of the coin. It is better to copy-paste it from the services mentioned above to avoid any spelling mistakes causing you to receive a completely different coin;
  • Indicate the number of coins to buy/sell.

Coin conversion on the mobile wallet

Android wallet and iOS wallet have virtually the same functionality. The coin conversion is performed by clicking the Convert button that is located at the bottom of the Coin tab.

Android convert.jpg

Clicking it causes a window with two tabs to appear:

  • SPEND tab - similar to the “Sale of the coins” option in the Console
  • GET tab - similar to the “Purchase of coins” option in the Console

Commission for the conversion

Commission for the conversion is fixed and is 0.10 BIP.

It does not depend on the number of coins exchanged or which coins are participating in the exchange.

It is also possible to send up to 1024 bytes of useful data in the Message field. There’s a commission of 0.002 BIP for each byte.

In the code, transaction costs are calculated in units. 1 BIP equals to 1000 units. Therefore, you can find the following transaction cost values: TypeSellCoin 100 units TypeSellAllCoin 100 units TypeBuyCoin 100 units

Formulas used for the conversion

Technically, there are two steps to the coin conversion:

  • calculation of the number of BIP received when selling tokens offered for exchange
  • purchase of tokens for the amount of BIP that was calculated during the first step

For example, we want to exchange 20 000 MSCAN for the TEAM coins, in which case the program calculates the number of BIP that we can receive when selling 20 000 MSCAN. We’re able to receiver 54 639 BIP at the moment of writing of this article. Then the number of TEAM coins that we can purchase for 54 639 BIP is calculated.

Calculation of the cost of the sale

E = reserve * (1 - (1 - sellAmount / supply) ^ (100 / crr)), where

  • E - number of BIP received;
  • reserve - reserve of the coin in BIP;
  • sellAmount - number of coins sold;
  • supply - volume of coins in circulation;
  • crr - CRR coins

In the case of the example where we sell 20 000 MSCAN, at the moment of the sale the coin has the following parameters:

  • reserve - 5 033 000 BIP
  • sellAmount - 20 000 BIP
  • supply - 2 453 000 MSCAN
  • crr - 75%

We substitute these values in the formula and get the following:

E = 5 033 000 BIP * (1 - (1 - 20 000 MSCAN / 2 453 000 MSCAN) ^ (100 / 75%)) = 54 639,47 BIP (result is rounded to 2 decimal places)

Calculation of the purchase price for a certain number of BIP

E = supply * ((1 + deposit / reserve) ^ (crr / 100) - 1), where

  • E - number of BIP received;
  • supply - volume of coins in circulation;
  • deposit - amount of BIP spent on the purchase;
  • reserve - reserve of the coin in BIP;
  • crr - CRR coins

In the case of the example where we purchase TEAM tokens, at the moment of the purchase the coin has the following parameters:

  • reserve - 14 654 732 BIP
  • deposit - 54 639,47 BIP
  • supply - 1 761 000 TEAM
  • crr - 50%

We substitute these values in the formula and get the following:

E = 1 761 000 TEAM * ((1 + 54 639,47 BIP / 14 654 732 BIP) ^ (50% / 100) - 1) = 3 279,85 BIP (result is rounded to 2 decimal places)

Calculation of the purchase price of a certain number of coins

deposit = reserve * (((wantReceive + supply) / supply)^(100/crr) - 1), where

  • wantReceive - number of coins for purchase;
  • supply - volume of coins in circulation;
  • deposit - number of coins for purchase;
  • reserve - reserve of the coin in BIP;
  • crr - CRR coins

In the case of the example where we purchase TEAM tokens, at the moment of the purchase the coin has the following parameters:

  • reserve - 14 654 732 BIP
  • wantReceive - 2000 TEAM
  • supply - 1 761 000 TEAM
  • crr - 50%

We substitute these values in the formula and get the following: deposit = 14 654 732 BIP * (((2 000 TEAM + 1 761 000 TEAM) / 1 761 000 TEAM)^(100/50%) - 1) = 33 306,20 BIP (result is rounded to 2 decimal places)

Simulation of the process of the conversion

For instructions on how to use Minter Calculator, go to the Minter Calculator article

To simulate the processes described in the Formulas used for the conversion section we have to load the Minter Calculator and issue a coin we plan to convert.

Симуляция покупки чашечки кофе.png

After that, we go to the Exchange tab and there we can see the second test coin CUP. CUP’s parameters are predefined and cannot be changed. That way the user can see how the conversion occurs when paying for a cup of coffee worth 1 CUP with any custom token that has arbitrary parameters.

Transactions types during the conversion

In the code, the transaction is shown as follows:

  TypeSellCoin        0x02
  TypeSellAllCoin     0x03
  TypeBuyCoin       0x04

Transaction for the sale of a certain number of coins

Type: 0x02

During an operation of selling one coin (owned by the sender) in favor of another coin in the Minter network, the code will contain the following data:

type SellCoinData struct {
    CoinToSell          [10]byte
    ValueToSell         *big.Int
    CoinToBuy           [10]byte
    MinimumValueToBuy   *big.Int
}
  • CoinToSell - Ticker of the coin being sold
  • ValueToSell - Number of coins for sale
  • CoinToBuy - Ticker of the coin being purchased
  • MinimumValueToBuy - The minimum value for the purchase

Transaction for the sale of all coins

Type: 0x03

During an operation of selling all existing coins of one type (belonging to the sender) in favor of another coin in the Minter network, the code will contain the following data:

type SellAllCoinData struct {
    CoinToSell          [10]byte
    CoinToBuy           [10]byte
    MinimumValueToBuy   *big.Int
}
  • CoinToSell - Ticker of the coin being sold
  • CoinToBuy - Ticker of the coin being purchased
  • MinimumValueToBuy - The minimum value for the purchase

Transaction for the purchase of coins

Type: 0x04

During an operation of purchasing coins of one type with coins of another type (belonging to the sender), the code will contain the following data:

type BuyCoinData struct {
    CoinToBuy           [10]byte
    ValueToBuy          *big.Int
    CoinToSell          [10]byte
    MaximumValueToSell  *big.Int
}
  • CoinToBuyl - Ticker of the coin being purchased
  • ValueToBuyl - Number of coins for purchase
  • CoinToSell - Ticker of the coin being sold
  • MinimumValueToSell - The minimum value for the sale