osmosis-labs / isotonic

Smart Contracts for the Lendex Protocol
MIT License
1 stars 0 forks source link

Rounding improvements #126

Closed hashedone closed 2 years ago

hashedone commented 2 years ago

Adresses #40

It looks like changing initial multiplier to 1:100_000 really improves the calculation and it makes sense. Obviously on some bigger numbers it would give the off by one problems, as we cannot get perfect division precision. Don't close #40 yet, as now it should be verified if the problem doesn't occur on reasonable values.

Additionally there is a problem that this change may fake solving the #125. Reason is, that making better calculations may completely hide an error, but if at some point calculations would get not even and there would be some rounding problem, the problem would come back, just on bigger values. Therefor I suggest figuring out #125 before this one, so it is obvious that problem is not just postponed.

Also - the additional problem occurred on distribution, because now big scaled amounts became denominator in scaling calculations, and it ended up in having intermediate m^2 / n^10 with significant m and n. Solution was to make distribution scaling less efficient, but more decimal-friendly.

ueco-jb commented 2 years ago

Additionally there is a problem that this change may fake solving the https://github.com/confio/isotonic/issues/125.

Most likely nope, as I suggested earlier - it was frontend doing their own math caused that issue. https://github.com/confio/isotonic-demo-app/blob/main/src/utils/queryClient.js#L114-L118

ueco-jb commented 2 years ago

@hashedone you ignored my comment.