Closed dimalinux closed 1 year ago
Patch coverage: 85.24
% and project coverage change: +0.01
:tada:
Comparison is base (
65f75c2
) 58.74% compared to head (29849e8
) 58.75%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
When making an offer between XMR and ETH, it is impossible for the maker to propose min/max values in XMR that can not be represented in whole WEI units. This is because XMR is limited to 12 decimal places and the exchange rate is capped at 6 decimal places. This doesn't prevent all problems though. The taker can chose a value between the maker's min/max values that, when converted to ETH, result in fractional piconeros when divided by the exchange rate. We could allow rounding in this case (not done in this PR), as long as our code never expects
provided = ToETH(ToXMR(provided))
. This inverse-equal expectation could happen if, for example, the taker looks at the maker-locked XMR balance, converts it back to ETH and then compares the converted amount. If the piconero amount was rounded down for the locked amount, when converting back to ETH the value will be less than what the taker provided. In this PR, we just restrict taker values that could result in fractional piconero calculations to avoid these subtle rounding issues.When making an offer between XMR and an ER20 token, even the existing maker limitations were insufficient. Some tokens, mainly stablecoins, only have 6 decimal places. That means that a maker could provide min/max values that, when converted into the token, would be more precise than the token supports. If rounding is used (not done in this PR), we'd need to be careful that min values are rounded up and max values are rounded down in the token units. Otherwise, the reverse calculation from the rounded token units leads to out-of-offer-range values when converting back to XMR.
In this PR we restrict all min/max amounts to values that are fully reversible:
x = ToXMR(ToEth(x))
. We also restrict all taker provided amounts to values that are fully reversible:y = ToETH(ToXMR(y))
.If the taker tries to provide an amount that is not fully reversible, we include the closest possible alternative value that is reversible in the error message, as computing this value would be non-trivial for end users to do on their own.