You have exceeded the Integer.Max value, which results in the sign being flipped, making everything negative. A common issue with any program has some form of accumulating growth.
There are work arounds, such as capping how big the numbers get. But to allow arbitrary large values above that will likely require the dev to do a big refactor and use some variation of BigNumber throughout their code.