Skip to content

Commit

Permalink
Clarify Ratio and Price terms, especially wrt decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
espendk committed Jan 10, 2024
1 parent 2725c3e commit a15a2ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/developers/terms/price.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@ Thus, a _price_ corresponds the $wants/gives$ %%ratio|ratio%% of an offer in the
On a WETH/DAI market, prices are expressed in DAI per WETH (DAI/WETH), eg. 2,224 DAI/WETH.
:::

:::warning 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](../contracts/technical-references/tick-ratio.md) page for a detailed explanation, including formulae for converting between these representations.
:::

## References
* Technical reference for [ticks, ratios, and prices](../contracts/technical-references/tick-ratio.md)
10 changes: 9 additions & 1 deletion docs/developers/terms/ratio.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Ratio
hoverText: The ratio $wants/gives$ between the amount $gives$ promised by an offer and the amount $wants$ it requests.
---

The _ratio_ $wants/gives$ between the amount $gives$ promised by an offer and the amount $wants$ it requests. The unit of ratios on an %%offer list|offer-list%% `outbound_tkn-inbound_tkn` is thus `inbound_tkn/outbound_tkn`.
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:

Expand All @@ -21,6 +21,14 @@ On a WETH/DAI market:
* Eg. 0.0004496 WETH/DAI
:::

:::warning 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](../contracts/technical-references/tick-ratio.md) page for a detailed explanation, including formulae for converting between these representations.
:::


## References
* Technical reference for [ticks, ratios, and prices](../contracts/technical-references/tick-ratio.md)

0 comments on commit a15a2ca

Please sign in to comment.