Return the left combined with the right.
Check the kind of this value and throw if it is not the expected kind.
Is the value the identity element?
Does left equal right?
Is the left greater than or equal to the right?
Get the representation for the identity element (often 0 or an empty array)
Return what remains after removing the right from the left. If something in the right was not in the left, we throw an error.
All of the difference in how digital asset amount are manipulated can be reduced to the behavior of the math on values. We extract this custom logic into mathHelpers. MathHelpers are about value arithmetic, whereas AmountMath is about amounts, which are the values labeled with a brand. AmountMath use mathHelpers to do their value arithmetic, and then brand the results, making a new amount.
The MathHelpers are designed to be called only from AmountMath, and so all methods but coerce can assume their inputs are valid. They only need to do output validation, and only when there is a possibility of invalid output.