The academy have developed tools for code verification, state modeling and formal proofs. The choice of using a javascript fork for financial contracts is deliberately dumb and will result in the craziest bugs we could imagine.
Formal proofs will not save you if the assumptions are wrong. You can formally prove a bug that you thought is a feature.
You could at the very least model impossible states and check they won't happen. The assumptions are not that hard to model either, there are not that many moving parts.