Rate pairs

Rate pairs are comprised of a “from” and “to" currency and the rates history between those two currencies. When you activate the Conversion Extension, it automatically adds a list of global rate pairs which allow the wallet to display the value of currencies in a user’s accounts in their chosen display currency e.g. showing what their EUR account balance is in USD.

Rate pairs are always defined in relation to a base currency, which in Rehive is always USD.

Whenever a value in the wallet is converted for display in a different currency, the wallet will always use Rate pairs for this calculation. The only exception is when making a conversion transaction - that will use Conversion pairs to get the value instead.

You can override a global rate pair with a custom rate pair. With a custom rate pair, you can directly modify the rate or how the rate is calculated.

Custom rate pairs

Custom rate pairs can be used to define a rate between “from” and “to” currencies which are not included in the global rate pairs list e.g. between USD and a custom points currency. To set a custom rate for a custom points currency to be 1/100th the value of USD you would create a custom rate pair and set the rate to 0.01.

Path

You can use the path functionality in custom rate pairs to make the rate of a custom rate pair track the rate of another global or custom rate pair e.g. to make testnet bitcoin’s exchange rate to USD track the same rate as livenet bitcoin to USD. This path would simply be USD:XBT

Conversion pairs

In order to allow users to make conversion transactions in the wallet, admins need to create conversion pairs. Conversion pairs define:

  1. Which currencies users can convert between (the "from currency" and "to currency").
  2. In which direction conversions can be done i.e. from USD to EUR, or from EUR to USD. In order to allow users to convert both ways, two separate sets of conversion pairs would need to be set up.

Conversion pairs can be configured to calculate the conversion rate between the two currencies in 3 ways:

  1. Auto - The rate will automatically be retrieved from an available global or custom rate pair e.g. a conversion pair of USD:ZAR will use the rate of the global rate pair USD:ZAR, unless a custom one has been specified which would override the global rate pair. This will be the most commonly used setting.
  2. Rate - Set a fixed value rate. This will ignore any rate between global or custom rate pairs and only use this value always for conversion transactions.
  3. Path - This is an advanced field. It can be used to dynamically calculate a rate based on an expression. The expression can be either a basic mathematical expression or can combine mathematical expressions and functions defined by Rehive. Please contact Rehive if you would like assistance with paths. Here are some examples:
  • {{ rates|get:'USD:ZAR' }} / {{ rates|get:'USD:EUR' }} EUR:ZAR

    This path emulates what happens when “Auto” is selected for the currency pair EUR:ZAR. It first gets the ZAR to USD rate, then gets the EUR to USD rate, and derives the EUR to ZAR rate by dividing the ZAR to USD rate by the EUR to USD rate. This happens because Rehive’s base currency for rates is USD.
  • {{ rates|get:'USD:ZAR' }} + 1

    This path is an example of USD:ZAR + a fixed value. It pads the rate by 1. e.g. if the rate for USD : ZAR is 17.05, the above path would output a rate of 18.05.
  • {{ rates|get:'USD:ZAR' }} * 0.98

    This path would make the rate between USD and ZAR be 98% of the actual rate. You might do this if you wanted to provide a slightly discounted conversion rate.
  • ({{ rates|get:'USD:ZAR' }} / {{ rates|get:'USD:EUR' }}) + ({{ rates|get:'USD:ZAR' }} / {{ rates|get:'USD:EUR' }} * 0.1 )

    This path first calculates the rate of EUR to ZAR by getting the USD:ZAR rate and dividing it by the USD:EUR rate (because the base rate is always in USD):
    ({{ rates|get:'USD:ZAR' }} / {{ rates|get:'USD:EUR' }})
    It then calculates the rate of EUR to ZAR (the same way as above) and multiplies it by 0.1 to get 10% of the rate of EUR to ZAR:
    ({{ rates|get:'USD:ZAR' }} / {{ rates|get:'USD:EUR' }} * 0.1 )
    It then adds those two values together:
    ({{ rates|get:'USD:ZAR' }} / {{ rates|get:'USD:EUR' }}) + ({{ rates|get:'USD:ZAR' }} / {{ rates|get:'USD:EUR' }} * 0.1 )
    This creates a final rate of the EUR to ZAR rate + 10%.
    E.g. if the rate or EUR to ZAR is 17.05, the calculation will be as follows:
    (17.05) + (17.05 * 0.1) = 18.755
    This path is so long because it is deriving the rate of EUR to ZAR from the base rates of each currency relative to USD.

Quote duration
When creating a conversion pair an admin can stipulate a quote duration. This is the period of time for which a rate will remain fixed while the user decides if they want to complete the transaction. The default duration is 10 minutes if a duration is not specified.

Operational account

When creating a conversion pair an admin must set an operational account which will be used to facilitate the conversions. This account should have a healthy balance of the currencies that will be converted between. The below example will illustrate how the Conversion Extension uses the operational account:

A user wants to convert 1 USD to EUR. The quoted rate is 1 EUR for 1.1669 USD. If they convert their 1 USD they will receive 0.86 EUR. They accept the conversion quote. The Conversion Extension makes the following transactions in order to facilitate the conversion:

First, a debit of the user’s USD account for 1 USD and a credit to the operational account for 1 USD.

Second, a debit on the operational account for 0.86 EUR and a credit to the user’s EUR account for 0.86 EUR.

The user wanting to do the conversion and the operational account facilitating the conversion both need to have an account with EUR and USD currencies.

Conversions

Conversions are a list of complete or quoted conversions. A quoted conversion is either a currently pending conversion which has not yet been completed or an expired conversion quote where the quote duration ran out (whether because a user took too long or they decided not to complete the conversion). Admins can see the user who initiated the conversion, which currencies they wanted to convert between, the from and to amount, the rate at the time at which the exchange quote was requested, and the current status of the conversion.

Did this answer your question?