zeitgeist icon indicating copy to clipboard operation
zeitgeist copied to clipboard

Allow negative numbers and fractions in scalar markets

Open maltekliemann opened this issue 2 years ago • 4 comments

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)?

maltekliemann avatar Sep 17 '22 13:09 maltekliemann

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.

maltekliemann avatar Sep 18 '22 15:09 maltekliemann

I wonder if this should be solved on the UI level.

maltekliemann avatar Sep 23 '22 13:09 maltekliemann

I am absolutely convinced that this should be solved at the UI level.

maltekliemann avatar Oct 05 '22 22:10 maltekliemann

We resolved to not use negative numbers.

maltekliemann avatar Oct 16 '22 10:10 maltekliemann