ripple / ripple-lib-extensions

[Deprecated] A collection of extensions to ripple-lib. Instead, see https://github.com/XRPLF/xrpl.js
https://github.com/XRPLF/xrpl.js
22 stars 31 forks source link

What's the point of having XRPValue and IOUValue? #39

Open r0bertz opened 5 years ago

r0bertz commented 5 years ago

I thought the unit of XRPValue was drops. But it is not.

The only difference this makes is that when either of them is multiplied or divided by an XRPValue, that XRPValue is turned into drops before actually doing the multiplication or division. And this is not right.

Amount.prototype.ratio_human from the old ripple-lib core api had to work around this by multiplying the numerator by 1e6 if the denominator is XRPValue. This doesn't make sense to me.

r0bertz commented 5 years ago

And multiplying an IOUValue by 1e6 can cause the resulted value exceeds the max value for IOUValue.

However, I did find that in some places the unit is drops. For example, in the data returns from ripple-lib-orderbook's trade event.

But the fact that XRPValue is turned into drops before doing multiplication or division seems to suggest that it should not be in drops.

This is super confusing.