4 ms·
Disclosure: I'm CTO of BitMEX, a Bitcoin derivatives exchange built on kdb+/q. We don't compete directly with itBit or any of the exchanges I mention below (we
by STRML 10y ago
Disclosure: I'm CTO of BitMEX, a Bitcoin derivatives exchange built on kdb+/q. We don't compete directly with itBit or any of the exchanges I mention below (we don't do spot trading, they don't do derivatives) but we are in a similar space.
Audits matter. Your books should always sum zero. Time and time again, we've seen bugs like this across the space: there was the infamous Bitcoinica "infinite leverage" bug [1], a rounding error in another's order sizes, and it's theorized that a similar bug was leveraged in the downfall of MtGox to create virtually infinite balances and use it to buy Bitcoin up to $1000 in 2013.
Whether it's in your engine or outside of it, whether it's a Bitcoin product or any other financial product, make sure there is something - somewhere - that is regularly summing up all accounts and ensuring that every cent or satoshi is accounted for.
We run such a system at every execution. If the system doesn't sum zero, we shut down. It's happened three times in two and a half years, each time due to tiny mathematical errors in our liquidation process, each time for less than 10,000 satoshis (~$0.10). We sleep much better at night knowing it's there.
Audits would catch the error caused by float math. And of course, don't do float math.
1. I can't find the original reference to it, but it was originally possible to simply edit the DOM to submit any leverage amount you pleased (such as 100,000x; never trust the client!) and then run your account massively into profit - or bankruptcy.
- deleted 10y ago[deleted]
- hudon 10y agoThat's definitely great to have. Or once the system gets too big and it becomes infeasible to sum all accounts, you can also just make sure that you will never create a transaction where the entries within it do not sum to 0 (and make sure your entries are either all written or none).
- deleted 10y ago[deleted]
- SomeStupidPoint 10y agoWhy would you ever use floats for finance? That's like the industry that epitomizes the usecase for fixed point!
- rhinoceraptor 10y agoIt seems logical if you don't understand how floating points work under the hood.
- contingencies 10y agoYeah. I was the first employee / architect at Kraken (left 2015) and can confirm that these issues were similarly very much at the forefront of our minds in the design phase before we even dared to soft open. (Frankly given the clear demand for Satoshi level accuracy it seems strange to have missed this one!)