A price describes what an offer request per unit it delivers. Prices on a market are expressed in quote per base (
quote/base) for both asks and bids (as indicated by the base-quote terminology), allowing prices to be directly compared across asks and bids.
On the asks side, this is fairly natural: The price is the ratio between the amount of base tokens promised by an offer and the amount of quote tokens it requests.
On the bids side, however, the price is the reciprocal of the ratio, i.e. price = . This is because a bid wants base tokens and offers quote tokens and thus the ratio is in
Thus, a price corresponds the ratio of an offer in the following way:
- For an ask,
- For a bid, .
On a WETH/DAI market, prices are expressed in DAI per WETH (DAI/WETH), eg. 2,224 DAI/WETH.
As always when dealing with ERC-20 tokens, care must be taken to handle decimals appropriately.
Just as for token amounts, ratios and prices have both raw and user representations.
See the Ticks, ratios, and prices page for a detailed explanation, including formulae for converting between these representations.
- Technical reference for ticks, ratios, and prices