Skip to content

Commit 40a0c80

Browse files
authored
Merge pull request #48 from tonkeeper/update-price-docs
Enhance rates service documentation with new pools and formulas
2 parents 953e4b6 + ba3a16f commit 40a0c80

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pages/tonapi/rest-api/rates.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const getStaticProps = loadStatic;
77

88
# Rates<SwaggerLink tag={SWAGGER_TAGS.RATES} />
99

10-
**Rates service** provides access to exchange rates for various tokens on the TON blockchain. This service calculates token prices using data from our indexer and liquidity pools such as Stonfi and Dedust, offering a comprehensive view of verified tokens, their reserves, and holder counts.
10+
**Rates service** provides access to exchange rates for various tokens on the TON blockchain. This service calculates token prices using data from our indexer and liquidity pools such as Stonfi, Dedust, SwapCoffee, Tonco, Bidask and Mooncx, offering a comprehensive view of verified tokens, their reserves, and holder counts.
1111

1212
<Callout type="warning" emoji="⚠️">
1313
The rates provided are for informational purposes only. Do not use this data for financial transactions.
@@ -19,12 +19,16 @@ Our Rates service utilizes a systematic approach to gather and process data:
1919

2020

2121
#### Data Sources:
22-
- By leveraging the [analytics service](/tonconsole/analytics) in tonconsole, we obtain data on pools from Stonfi and Dedust.
22+
- By leveraging the [analytics service](/tonconsole/analytics) in tonconsole, we obtain data on pools from Stonfi, Dedust, SwapCoffee, Tonco, Bidask and Mooncx.
2323
- The collected information includes token **_addresses_**, **_reserves_**, and the **_number of holders_** for verified tokens.
2424

2525
#### Price Calculation:
2626
- For standard pools: We apply the formula $xy = k$, where $x$ and $y$ are volumes of two assets in the pool, and $k$ is a constant.
2727
- For Dedust stable pools: We use a modified formula $x^3y + y^3x = k$ to account for the specifics of these pools.
28+
- For Stonfi weighted constant product pool: We use standart formula ($xy = k$) with weight value $w0$ from the pool settings $x^{w_0}y^{1 - w_0} = k$.
29+
- For Stonfi stable pools: We work with the following formula $4A(x + y) + D = 4AD + \frac{D^3}{4xy}$, where $A$ is amplifier from pool's settings and $D$ is a constant, so it much more complicated to calculate $D$ value, so we use iteratively, calculating $D$ more accurate each step.
30+
- For Stonfi weighted stable pools: We use a bit simplified formula for stable pools with rate $r$ and weight $w0$ parameters from pool's settings $(x + ry)A + x^{w0}y \cdot (ry)^{1 - w0} = k$.
31+
- For Bidask pools: We get already calculated price from the pool data, butwe need to proccess this value using this formula ${(\frac{P}{2^{128}})}^2 = price$, where $P$ is the value of price that need to be proccessed.
2832

2933
You can view the implementation of these calculations <ExternalLink href={GITHUB_LINKS.RATES_PRICE_CALCULATION_CODE}>here</ExternalLink> .
3034

@@ -46,4 +50,4 @@ Send this information to <ExternalLink href={LINKS.ZAKHAR_TG}>@zakhar_petukhov</
4650

4751
<SchemaLoader tag={SWAGGER_TAGS.RATES} />
4852

49-
Remember, while this service provides valuable insights into token rates on the TON blockchain, it should not be used as the sole basis for financial decisions or transactions.
53+
Remember, while this service provides valuable insights into token rates on the TON blockchain, it should not be used as the sole basis for financial decisions or transactions.

0 commit comments

Comments
 (0)