casesandberg / play-money

https://play-money-api.vercel.app
6 stars 4 forks source link

Address floats #21

Closed casesandberg closed 2 weeks ago

casesandberg commented 1 month ago

As mentioned in https://github.com/casesandberg/play-money/pull/20:

One thing that this didn't try to address, but will need to be handled soon, is that the AMM amounts are floats. I think ideally all money should be integer (or perhaps, fixed point decimal).

Likely we want to be using a special decimal datatype instead of number, or multiply everything by 100 and use straight intergers. I did a little digging and decimal.js and bignumber.js seem to be well maintained and pretty popular. Heres a wiki about the differences of them: https://github.com/MikeMcl/big.js/wiki.

casesandberg commented 3 weeks ago

It turns out Prisma has built-in support for Decimal.js so I think that may be the best way to go for now. I will do a spike to see what it would look like