# Exchange Service

All the exchange rates are represented in the schema below

<table><thead><tr><th>Field</th><th>Type</th></tr></thead><tbody><tr><td><code>baseCurrency</code></td><td><code>Currency Code</code></td></tr><tr><td><code>tagetCurrency</code></td><td><code>Currency Code</code></td></tr><tr><td><code>rate</code></td><td><code>number</code></td></tr><tr><td><code>modifiedDate</code></td><td><p><code>object</code></p><pre class="language-json"><code class="lang-json">{
    "_seconds": 1716120001,
    "_nanoseconds": 188000000
}
</code></pre></td></tr></tbody></table>

#### The Rate

The rate in equations is **not actually the price** but is a number with unit `baseCurrency/targetCurrency` and in all calculations this needs to be taken into factor.

#### Exchange Service calculations

The exchange service calculations are done with the below variables and formulas.

<figure><img src="https://4076969954-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbgpTyn5ehDgNS21U6ST7%2Fuploads%2F1TksE6EP8JAobMmiklVp%2FScreenshot%202024-05-19%20at%2019.20.11.png?alt=media&#x26;token=870da011-61c0-45d3-aded-59e52ce661e6" alt=""><figcaption></figcaption></figure>

#### Rounding Numbers

We round all currencies to 2 decimal point **except** IRT. For **IRT** we round to 0 decimal points

{% hint style="info" %}
All rounding operations are done with strategy `roundDown`
{% endhint %}
