timewave-computer / rebalancer

Other
3 stars 0 forks source link

Switch to Std SignedDecimal #78

Closed Art3miX closed 5 months ago

Art3miX commented 5 months ago

Switched to the std version of SignedDecimal.

All tests are passing. All manual testing results in almost the same result as the last rebalance.

1 account executes the same trades, but one of the trades amount is actually different: 4910110 on live rebalance compared to 4910080 in simulation. This is a little weird to me, because we are fetching the exact prices and configs from mainnet, meaning the rebalancer calculation should result in the exact same trades and trade amounts, and they generally do, except for a single trade in 1 account. That account have another trade to be executed, which does gives the exact same result, and the total value of the account is also exactly the same.

This leads me to believe there is a very small rounding difference (as you can see, its a 80 uDENOM diff), which makes sense given the previous SignedDecimal was handling operation on the unsigned decimal version, while the Std implementation is handling signed 128 operations.

stiiifff commented 5 months ago

LGTM

Art3miX commented 5 months ago

@stiiifff Implemented a check to make sure PID values are not negative