Skip to main content

Ratio

The ratio inbound_tkn_amount/outbound_tkn_amount between the amount outbound_tkn_amount promised by an offer and the amount inbound_tkn_amount it requests. The unit of ratios on an %%offer list|offer-list%% outbound_tkn-inbound_tkn is thus inbound_tkn/outbound_tkn.

A ratio corresponds to a %%price|price%% in the follow way:

  • For an ask, price=ratioprice = ratio
  • For a bid, price=1/ratioprice = 1/ratio.
Example

On a WETH/DAI market:

  • The price would be expressed in DAI per WETH (DAI/WETH)
    • Eg. 2,224 DAI/WETH
  • On the asks side WETH-DAI (selling WETH or buying DAI), the ratio equals the price and has unit DAI/WETH
    • Eg. 2,224 DAI/WETH
  • On the bids side DAI-WETH (buying WETH or selling DAI), the ratio equals 1/price and has unit WETH/DAI.
    • Eg. 0.0004496 WETH/DAI
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