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:

  • {{ 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.

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

Did this answer your question?