Calculation of the exchange amount / DONE

General designations:

inAmount - exchange amount is given, with rounding down to the decimal point of the currency specified for the currency is given outAmount - exchange amount is received, rounded down to the decimal point of the currency specified for the currency is received

Rounding example: Currency accuracy 2 sum of 1.234 = 1.23 6.789 = 6.78

rate - bid exchange rate (out / in)

exchange rate can be set manually or by any service, regardless of the source of exchange rates, the commission set in the admin panel is added to the rate. FeePercent - (Commission Percentage)

FeePercent

Also, when calculating the exchange rate, the personalised exchange discount for this client is also taken into account, if any.

Exchange rate calculation formula

The ratio of incoming and outgoing currency exchange rate is further referred to as in and out

Example 1 USD = 80 KZT so in = 1 , out = 80

feeRate = FeePercent / 100;
in = in + (in * feeRate)

discountRate = discount / 100
in = in - (in * discountRate);


RATE = out / in

Example of calculations by formula

Let's take 1 USD = 80 KZT commission 2%

in = 1 , out = 80, FeePercent = 2, discount = 0

2 / 100 = 0.02(feeRate)
1 + (1 * 0.02) = 1.02 (in)

0 / 100 = 0  (discountRate)
1.02 - (1.02 * 0) = 1.02 (in)

80 / 1.02 = 78.431372549 (RATE)

outFeeAmount - Commission amount (to be specified in outAmount currency)

outFeeAmount

Exchange Calculation Formula:

outAmount = (inAmount * rate) - outFeeAmount\

Variable designation

inAmount

The amount of exchange we give away

outAmount

The amount of exchange we get

outFeeAmount

Amount of static commission

FeePercent

Percentage of commission

rate

Exchange rate (out/in)

Last updated