Skip to main content

Price

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 wants/giveswants/gives between the amount givesgives of base tokens promised by an offer and the amount wantswants of quote tokens it requests.

On the bids side, however, the price is the reciprocal of the wants/giveswants/gives ratio, i.e. price = gives/wantsgives/wants. This is because a bid wants base tokens and offers quote tokens and thus the ratio wants/giveswants/gives is in base/quote.

Thus, a price corresponds the wants/giveswants/gives %%ratio|ratio%% of an offer in the following way:

  • For an ask, price=ratio=wants/givesprice = ratio = wants/gives
  • For a bid, price=1/ratio=gives/wantsprice = 1/ratio = gives/wants.
Example

On a WETH/DAI market, prices are expressed in DAI per WETH (DAI/WETH), eg. 2,224 DAI/WETH.

Beware decimals!

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.

References