Hi @antoncoding,
I suggest having a look the discussion in Designing Fixed Point Math in OpenZeppelin Contracts for some potential ideas.
As for ERC20 decimals there were a couple of relevant posts in the discussion:
I'm interested to hear from other members of the community on this topic.