zeitgeist
zeitgeist copied to clipboard
Allow negative numbers and fractions in scalar markets
Pretty much immediately after launch it seemed to me that we need more flexibility for scalar markets. If you bet on the change of some value in percentage ("How much will Tesla stock price change in Q3?"), then you need negative numbers, unless you want to do something absolutely terrible like: "0 to 100 means -100% to 0% and 100 to 200 corresponds to 0% to 100%."
Something similar goes for having fractions. Otherwise, if you want precision up to 0.1%, you have to do something like: "0 to 1000 means 0% to 100% (in equal increments)."
So, let's replace the u128
type used to bet on scalar markets with:
enum ScalarValue {
Integer(i128),
Fraction(i128, u128),
}
We can also use a full-blown implementation of on-chain rational numbers for the last variant, but I think that's overkill, since we do almost no math with the scalar value.
Edit. Looking at this now, how about we replace it with typedef ScalarFraction = (i128, u128)
?
I guess this will make some things more complicated. Let's say you have a range of numbers, [x, y]? How many fractional values are in that range? If we only consider integers, that's easy. If you're considering some weird subset of the rational numbers, it get's complicated.
I wonder if this should be solved on the UI level.
I am absolutely convinced that this should be solved at the UI level.
We resolved to not use negative numbers.