1. Jean-Luc Picard
  2. nxt
  3. Issues

Issues

Issue #205 new

Monetary System Documenation

riker
created an issue

This document replaces #136

Overview

The "Currency" entity is the basic building block of the NXT Monetary System, currency has a unique name and code and uniqueness is guaranteed by the protocol, currencies can be deleted and their code can be reused under certain conditions.

The total currency supply is divisible into currency units. Like assets, currency units supports decimal positions implemented as a client side feature. The maximum number of currency units which can be issued per currency is similar to NXT i.e. 10^9 * 10^8. The actual maximum units supply is set by the currency issuer. The currency issuer is the account which issues the currency and pays the issuance fee. The issuer is responsible for setting the currency properties and in some configurations has additional control over the currency usage. Like asset balance, currency units can be transferred between accounts.

Currency Properties

The currency entity supports several properties. Properties can be mixed and matched in various ways to compose the currency type. The currency type then controls the inner workings of the currency. The list of available currency properties is as follows:

EXCHANGEABLE - the currency can be exchanged with NXT. Holders of the currency can publish an exchange offer specifying the buy and sell rate of the currency much the same as banks or currency exchanges publish their exchange rates . Each account can publish only a single exchange offer at any given time. Exchange offers has an expiry block after which they are no longer in effect. Buyers and sellers can issue exchange requests to match published exchange offers. Unlike asset bid/ask orders, exchange requests are not saved, they are either executed immediately (fully or partially) or not executed at all. A match of exchange offer with a buy or sell exchange request creates an exchange entity which represents the transfer of currency units in return to NXT balance and causes the relevant account balances to update. Issuing an exchange offer reduces the NXT and currency balance of the offering account temporarily until the offer expires. Exchange offers also specifies a limit on the number of exchanged units which can be larger than the number of units offered. When a buy exchange request matches an exchange offer the number of units offered for sell is reduced and the number of units offered for buy is increased as long as the limit has not been reached. Once the exchange limit of an exchange offer has been reached, This exchange offer can no longer be used.

CONTROLLABLE - currency property suitable for currencies which need to track an external entity. It imposes the following limitations on the currency (1) Currency can be transferred only to/from the issuer account (2) only the issuer account can publish exchange offers. The issuer account can issue a large (practically infinite) supply of units in advance, then transfer units to accounts, or offer to exchange units, to reflect actual transactions which take place in an external system. The large supply of units in the issuer account can be used to mimic the effect of creating units out of nowhere to support features such as creating new units and interest payments.

RESERVABLE - currency units are not issued immediately. Instead the currency issuer sets a block height by which the currency is to be issued and a limit of NXT per unit needed in order to issue the currency. Currency "founders" then spend their NXT to reserve their currency stake. If the amount of NXT per unit needed in order to issue the currency is not reserved before reaching the block height the issuance is cancelled and funds are returned minus fees. If the required reserve is allocated, the currency is issued and units are split between founders according to their proportional stake of invested NXT. In case of rounding, leftovers are sent to the issuer account. See below discussion of usage scenarios for Reservable currency.

CLAIMABLE - currency units of resereable currency can later be claimed at the same NXT per unit rate reached when reserving the currency. The ability to claim a currency at a certain rate imposes some practical limits on the rates in which users would want to exchange it. However claimable currency can also be exchanged if only for the purpose of exchanging the whole currency supply, so that the currency can be deleted.

MINTABLE - currency can be minted using proof of work algorithms much the same as Bitcoin. Unlike Bitcoin mining, minting currency does not secure the network (this is done by NXT). Minting is used solely for creating new currency units and serve as the only mechanism to increase the number of available units after the currency issuance.

NON_SHUFFLEABLE - this property indicates that in the future this currency cannot participate in coin shuffling. By default currencies are allowed to participate in shuffling.

Properties are combined into an Integer bit mask designated as the Currency type.

Currency Exchange

For exchangeable currency, each currency holder account, can publish a single exchange offer specifying the buy rate and sell rate vs NXT and the number of units she is willing to exchange (which cannot exceed her available currency units and NXT balance). Users can observe all currency exchange offers (intuitively similar to fiat exchange offices) and try to match them with buy/sell exchange requests. An exchange offer has an expiration height, as well as a limit on the total number of units which can be exchanged. When units are bought from an exchange offer the number of units to sell increases automatically and vise versa. The publisher can also limit the total transaction volume of currency units traded for a specific exchange offer.

Deleting a Currency

Since the available currency codes are limited to 3, 4 or 5 uppercase letters, the total number of codes is limited to 26^3 + 26^4 + 26^5 - 1 = 12355927 unique values (The code "NXT" is reserved), it is likely that some of these codes will have value by themselves. Therefore deleting a currency is possible under certain conditions depending on the currency type. Users may re-issue a currency, or delete a currency and then issue a new currency, with the same code but with different properties. In order to delete or re-issue a currency an account must poses all the currency units (and additional conditions apply based on the currency type)

Creating new Currency Units

The only way to create new currency units after issuing a currency is using proof of work minting. Other methods of creating units are susceptible to denial of service attacks and/or sock puppets and are therefore not allowed. The controlable currency type provides a partial solution for creating new units, by allowing the currency issuer account to treat her supply as a treasury and only consider units outside of this account as the total currency supply. This approach requires users to trust the currency issuer which can increase the currency supply at any time.

Minting

Users can issue minting requests in order to mint additional currency units. Each minting request triggers a hash calculation based on the submitted data and the currency hash algorithm. The resulting hash code is compared to the target value derived from the current currency difficulty. Minimal and maximal currency difficulty values and minting algorithm are specified when issuing the currency and cannot be changed later. The expected number of hash calculations (i.e. difficulty) of minting the first unit is 2^minDifficulty while the difficulty of minting the last unit is 2^maxDifficulty. Difficulty increases linearly from min to max based on the ratio between the current number of units and the total supply. Difficulty increases linearly with the number of units minted per CurrencyMint request, small minters can mint only a few units per request while large minters can mint large number of units per request. The number of units per minting request is limited to 1/10000 of the total unit supply. Minting is limited to a single minting transaction per block/account/currency. Currency issuers can specify initial supply of units as a "pre-mint" supply assigned to the issuer account then use crowd funding by making the currency RESERVABLE and EXCHANGEABLE. Once the currency becomes active the delta between the current supply (reserved supply) and total supply can be minted. The NRS provides a Java based, reference implementation mInter, which can be used for minting. In practice we expect users to enhance this minter to calculate hash codes using their Asics or GPUs, trying to match the current target, and once solving a hash, submit a currency mint transaction (thus paying a fee).
If indeed the hash code is smaller than the target the currency units are credited to the sender account.

See documentation of the reference implementation "Mint Worker" utility here #207

Store of Value

The combination of RESERVABLE and CLAIMABLE properties can be used to allocate initial value for a currency by locking NXT. Once the currency is activated the reserved NXT are locked and the only way to release them is to claim back the currency units in return to NXT. This provides the currency a value based on the locked NXT balance. Note: locked NXT do not participate in forging, therefore, in theory its possible that large amount of NXT becomes locked as currency store of value thus reducing the amount of NXT used for securing the network, we are aware of this problem and we'll monitor it closely. We do not expect this to become a major problem any time soon.

Crowd Funding

The combination of RESERVABLE and EXCHANGEABLE properties can be used for crowd funding, in this configuration the NXT balance reserved by founders, is not locked, instead it is sent to the currency issuer account once the currency becomes active. The issuer can use these NXT for its operations and the founders cannot claim back their currency units, only exchange it based on the published exchange offers. Currency issuers can specify the initial supply as "pre mine" and founders get share the difference between the reserve supply (also named "pre-activation" supply) and the initial supply.

Fees

Currency issuance fee is based on the length of the currency code.

3 Letters - 25000 NXT

4 Letters - 1000 NXT

5 Letters - 40 NXT

Re-issuing an existing currency with different properties costs 40 NXT regardless of the number of the currency code length. All other currency transactions (as of today) has a fee of 1 NXT.

API Documentation

This section is relevant to API and client developers.

### Transaction APIs ###

issueCurrency

issue a new currency or re-issue an existing currency with different properties. The currency unique id is the transaction id of the issueCurrency request.

currencyReserveIncrease

reserve NXT to become a founder

currencyReserveClaim

claim currency units back to NXT based on the currentReservePerUnitNQT rate

publishExchangeOffer

publish an offer for currency exchange by specifying the buy and sell rates you are willing to pay

currencyBuy

buy currency units for NXT by matching one or more exchange offers for selling currency for NXT

currencySell

sell currency units for NXT by matching one or more exchange offers for buying currency for NXT

currencyMint

issue a request to mint additional currency units

transferCurrency

transfer currency units between accounts

deleteCurrency

delete a currency

### Query APIs ###

getAccountCurrencies

getAccountCurrencyCount

getAllCurrencies

getCurrency

getCurrencies

getCurrencyFounders

getCurrencyIds

getCurrenciesByIssuer

getCurrencyAccounts

getCurrencyAccountCount

getExchanges

getExchangesByExchangeRequest

getAllExchanges

getCurrencyTransfers

getBuyOffers

getSellOffers

getOffer

getAccountExchangeRequests

getMintingTarget

transferCurrency

deleteCurrency

searchCurrencies

Unit conversion

Currency is measured in units and like assets has decimal positions, however the blockchain maintains currency balances as a whole number (QNT). Therefore, for example, in case a currency has 2 decimal positions and the client has reserved 123.45 units. The "units" value submitted in the API call should be 12345. APIs using NXT balances should send the value measured in NQT as usual. When specifying "rate" the API calculates the ratio between NXT balance in NQT and currency balance in QNT. Starting in version 1.5 the user interface for the rate fields shows the MS currency as the "base currency" and NXT as the "quote currency". The rate represents how much NXT is needed to purchase 1 MS currency unit.

Example: For a currency with 2 decimal positions. When submitting a buy exchange request for 12.34 units at a rate of 5.6 [NXT/Unit] the values submitted to the currencyBuy transaction should be: units = 1234 i.e. units without decimal position or 12.34 * 10^2 rateNQT = 5600000 i.e. rate converted to NQT then divided by decimal position or 5.6 * 10^8 / 10^2

In order to prevent rounding problems when submitting information to the server, the UI enforces the following rule: If a currency has D decimal positions. Unit values cannot have more than D decimal positions and rate values cannot have more than (8-D) decimal positions. Therefore when issuing a currency, we do not recommend specifying more than 4 decimal digits so that conversion rates are also divisible to at least 4 decimal digits.

Limitations

The following functions are not supported in this release but may become supported in the future: Direct exchange between currencies Buying assets and aliases using currency units Paying transactions fees as currency units instead of NXT Considering the proof of work invested in currencies when comparing an NXT fork

Disclaimer

  1. Before issuing a currency we recommend issuing a currency with the same properties on the testnet and experimenting with all parameters since these cannot be changed without deleting the currency.

  2. This documentation reflects the actual code implemented as of this date.

Comments (19)

  1. Log in to comment