Uniswap / sdk-core

⚙️ Code shared across TypeScript Uniswap SDK versions
MIT License
121 stars 354 forks source link

Price Basic Math functions #66

Open Florian-S-A-W opened 1 year ago

Florian-S-A-W commented 1 year ago

The Price class inherits add(), subtract() and divide() from the Fraction class, as well as comparison functions (LT, GT,...). All of these functions therefore take Fraction as the second argument.

Only the multiply function is overwritten and accepts Price<TQuote, TOtherQuote> as a second argument.

This is nearly the exact opposite behaviour of what I would intuitively expect. It makes sense to multiply or divide a Price with a Fraction, BigIntish or even Percent, but it makes no sense to add, divide or compare two totally different Price Objects and get a Fraction object in return. What is the reason for this design decision?