Let's assuming that I have an existing database that retaings fiat currency transaction as described below with decimal (18, 4)
.
Now, I would like to record bitcoin, ethereum and erc20 token transactions.
Transaction
------------------
TransactionID
CurrencyID
UserID
DebitAmount decimal(18, 4)
CreditAmount decimal(18, 4)
The decimal precision of cryptocurrency is suggested as follows:
decimal (16, 8) -- bitcoin
decimal (30, 18) -- ethereum / erc20 token
I am thinking of just:
Treating bitcoin, ethereum, erc20 token as new currency in the
Currency
table.Changing the
DebitAmount
andCreditAmount
directly todecimal(30, 18)
.Applying
decimal(30, 18)
data type changes to all the tables that retain currency amount.
My questions are:
Any possible impact to original currency amount conversion that I need to look after for when I increase the precision (eg. currency rate change
DebitAmount * 1.023
)?Am I doing this in the "correct" way?
Is there any other better approach/alternative to this?