Skip to main content
What are conversion pairs?

An overview of what conversion pairs are and how they work.

Helghardt Avenant avatar
Written by Helghardt Avenant
Updated over 3 years ago

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 to help you get started:

Getting the rate for converting from EUR to ZAR

{{ rates|get:'USD:ZAR' }} / {{ rates|get:'USD:EUR' }}

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.

Bonus or more favorable rates

{{ 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 to ZAR is 17.05, the above path would output a rate of 18.05.

The user would get 1 more ZAR than they would get from the regular rate. This acts like a bonus.

To make a less favorable rate, change the + to a -

Less favorable rate

{{ 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 the user to get less ZAR from their USD than they would from the regular rate.

If the original rate for USD to ZAR is 17.05, this path would output a rate of 16.70, meaning the user would get less ZAR for their USD.

Complicated more favorable 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 of EUR to ZAR is 17.05, the calculation will be as follows:
(17.05) + (17.05 * 0.1) = 18.755, meaning the user will get more ZAR for their EUR.

To create a less favorable rate where the user would get less ZAR for their EUR, change the + to -

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.

Read the full overview article to understand where conversion pairs fit in to the Conversion Extension as a whole.

Did this answer your question?