Applying rates
Learn how to record transaction between two asset classes
Overview
While the default expectation is to record transactions between ledger balances of the same asset class, i.e., currency, Blnk also allows you to be able to record transactions between ledger balances of different asset classes using the rate
parameter in your transaction request payload.
Note, the Double Entry principle only requires that there’s a corresponding credit entry for every debit entry and vice versa. However, it is up to you if you want to apply exchange rates between balances using
rate
or not.
How to apply “rate”
Consider a transaction record sending NGN 500.23 from a Naira balance (bal_ngn
) to a Dollar balance (bal_usd
).
The first thing is to determine the exchange rate value against the source
, i.e., by how much should you multiply the amount to convert from the source’s currency to the destination’s currency.
In this case, 1 NGN = 0.00081 USD. This means the value for our rate is “0.00081”.
If the source is bal_usd
and the destination is bal_ngn
, the exchange rate will be 1 USD = 1,200 NGN. This means the amount (in USD) will be multiplied by 1,200 to compute the equivalent NGN amount.
Here’s a sample request payload with rate applied:
What happens next?
- Blnk applies the rate to the amount: 500.23 * 0.00081 = 0.41
- Blnk applies the precision to the converted amount: 0.41 * 100 = 41
- Blnk records the amount as
41
inbal_usd
, and computes its respective balances. - Blnk records the amount as
50023
inbal_ngn
(after applying precision) and computes its respective balances.
To learn more about precision, read Understanding precision.
Things to Note
-
Only send money between balances whose different asset classes have the same
precision
value, i.e., NGN to USD work fine because the precision value for their lowest unit possible is 100. However, NGN to BTC is not advisable. -
It is encouraged to always specify your
precision
value in your transaction payload to ensure consistency in how your balance is computed.
See also
Balance monitoring
Set up balance monitors in your ledger
Record a transaction
Learn how to record a transaction
Understanding precision
Improve the correctness of your ledger
Managing notifications
Set up how you receive notifications
Need help?
Are you stuck? Do you have a question that isn’t answered in this doc? Have you run into a problem you can’t solve? Want to file a bug report?
Join our Discord server and share your questions/thoughts with other developers building financial applications like you.
Was this page helpful?