Implement Currency conversion in UI (Also notes on XTX valuation)
The Totem native currency are transaction allocations (XTX) but as this is also an accounting system it requires a currency conversion mechanism.
In order to determine how XTX is valued against other currencies, we take a stable currency approach influenced by Special Drawing Rights (SDR) which permits direct currency to currency conversion through a simple calculation and establishes a value for SDR.
Note about exchange rates and valuations and revaluations using exchange rates.
There is a specific difference between the exchange rate used in settlement transactions and the rates that apply for accounting records. In accounting the are a number of rules set out (for example in USGAAP (ASC830)) that treat unsettled amounts and asset valuations. Currency revaluation may be relevant (i.e. using the rate for the period in which the asset value or liability is calculated rather than the date on which it was recorded). We will not discuss this here as it is quite specific to each organisation.
Calculating the exchange rate of XTX
The underlying currency XTX is the mechanism for recording value into the accounts in Totem. As it follows an SDR-like stability mechanism (with a basket of all known fiat currencies, and some of the major cryptocurrencies) the formula is as follows.
At the time of writing these are the rules for determining the initial value of XTX:
Derive the ISO currency issuance percentage:
-
Convert the
total issued currency per ISO currency
to USD using thesix month moving average exchange rate to USD
to obtain theUSD value of the total issued currency
. -
The
total issued cryptocurrency
is also used as the equivalent fortotal issued currency per ISO currency
for each of the cryptocurrencies in the basket. -
Sum all the
USD value of the total issued currency
to obtain theGlobal Total Issuance in USD
. -
The
ISO currency issuance percentage
=USD value of the total issued currency
/Global Total Issuance in USD
Derive the Notional Quantity of Issued Currency in Bitcoin
- Divide the
USD value of the total issued currency
by thesix month moving average USD price of Bitcoin (BTC)
to obtain theNotional Qty of Issued Currency in BTC
Derive the SDR Rule O-1 for Totem
- Multiply
ISO currency issuance percentage
*XTX factor constant
(currently 0.0006181) to obtain Rule O-1 value per currency.
Derive the BTC Equivalent Value
- Multiply the
Notional Qty of Issued Currency in BTC
*SDR Rule O-1 for Totem
to obtain the BTC equivalent value for each ISO currency ( and cryptocurrency )
Derive the exchange rate 1 BTC = nXTX
- Sum all the
BTC Equivalent Values
. This total is thetotal quantity of XTX required to purchase 1 BTC
.
Derive the USD exchange rate for XTX
- Divide the
six month moving average USD price of Bitcoin (BTC)
bytotal quantity of XTX required to purchase 1 BTC
The results of this calculation at the time of posting is in attached .json
file, but later an off-chain worker will be developed to regularly update these values per this formula.
The calculated exchange rate of XTX to USD is $0.00559106
Converting currency displays in the UI
In the Totem UI there will be a number of selection possibilities for displaying values in currencies. The main one will be in the global settings which sets how currencies are displayed in the application. In future there may be module specific settings.
In general when values are recorded in XTX in the blockchain, a simple conversion is required:
-
Check the global setting: obtain the selected currency of display.
-
Obtain the ratioOfExchange for that currency.
-
Perform the calculation :
( ratioOfExchange for XTX / ratioOfExchange for currency )* amount XTX
During development of blockchain functionality the ratioOfExchange
and the ISO will be recorded in the blockchain with transactions that settle accounting entires in order to book any changes to the exchange rates from the time of recording to when the reporting of financial statements are made.