# How pay and receive amounts are calculated in transactions

This article explains how amounts are calculated in the **Pay** and **Receive** fields in the B2CORE UI when transactions involve currency conversions.

For such transactions, the resulting amounts depend on the following:

* The **rounding rules** applied to the amount in the **Pay** and **Receive** fields.
* The configured **currency scales** defining the number of decimal places supported for both the source and target currencies involved in a transaction.

## Rounding rules

For the **Pay** and **Receive** fields, different rounding rules are applied in B2CORE:

* The **Pay** field: the amount is always **rounded up**. This ensures that the broker does not lose profit due to rounding differences.
* The **Receive** field: the amount is always **rounded down** according to the scale of the target currency.

## Currency scales

All currencies used for transactions in B2CORE have configured **scales**, which define the number of allowed decimal places. The scale determines the precision of rounding for any transaction involving that currency.

You can configure the scale for each currency by navigating to **Currencies** > **Currencies**, opening the currency details, and setting the required value in the **Precision** field.

For example:

* **THB** (Thai Baht): scale `0` (no decimals)
* **USD** (US Dollar): scale `2` (two decimals)

## Example

Suppose a client initiates a deposit to a **USD** wallet and pays in **THB** (Thai Baht).

* When **THB** has a scale of `0` (no decimals):
  * Enter **245 USD** in the **Receive** field → the **Pay** field displays **7,968 THB**.
  * Enter **7,968 THB** in the **Pay** field → the **Receive** field displays **245.01 USD**.

<figure><img src="https://514898401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGoRxAprhHu1goANW7FXt%2Fuploads%2Fgit-blob-030b25ab46cf58a99e354e2d6cef1748bb2ba2ae%2Fthb-with-scale-0.png?alt=media" alt="THB with scale 0"><figcaption><p>THB with scale 0</p></figcaption></figure>

* When **THB** has a scale of `1` (one decimal):
  * Enter **245 USD** in the **Receive** field → the **Pay** field displays **7,967.4 THB**.
  * Enter **7,967.4 THB** in the **Pay** field → the **Receive** field displays **245 USD**.

<figure><img src="https://514898401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGoRxAprhHu1goANW7FXt%2Fuploads%2Fgit-blob-7f276b68706b6a6849946239b996403cef8b71b8%2Fthb-with-scale-1.png?alt=media" alt="THB with scale 1"><figcaption><p>THB with scale 1</p></figcaption></figure>

The mismatch occurs because the scale of `0` can't preserve decimal values, while scales of `1` or higher allow fractional amounts, resulting in more precise conversions.
