Skip to main content
How does the path field work?

Explains how the path field works in custom rate pairs and conversion pairs.

Helghardt Avenant avatar
Written by Helghardt Avenant
Updated over a week ago

Paths in rate pairs

Path can be used to make the rate of a custom rate pair track the rate of a 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

Paths in conversion pairs

In a conversion pair, the path 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. You can use paths in conversion pairs to make a pair track the rate of another rate pair, to pad a conversion rate to charge a built-in fee, or provide a discounted exchange fee.

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.

Read the full overview article to read more about the Conversion Extension as a whole.

Did this answer your question?