From 5130d288944457d53624d787ef8125b64c233852 Mon Sep 17 00:00:00 2001 From: kaladin <335095@niuitmo.ru> Date: Wed, 8 Oct 2025 19:18:07 +0300 Subject: [PATCH 1/8] add stub --- docs.json | 5 ++--- ecosystem/rpc/price.mdx | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 ecosystem/rpc/price.mdx diff --git a/docs.json b/docs.json index a7f43643..784e54f3 100644 --- a/docs.json +++ b/docs.json @@ -238,7 +238,8 @@ "openapi": "./ecosystem/rpc/ton-center-http-api-v-3.yaml" } ] - } + }, + "ecosystem/rpc/price" ] }, { @@ -298,12 +299,10 @@ "group": "Jettons", "pages": [ "standard/tokens/jettons/overview", - "standard/tokens/jettons/how-it-works", "standard/tokens/jettons/comparison", "standard/tokens/jettons/mintless/overview", "standard/tokens/jettons/mintless/how-to-deploy" - ] }, { diff --git a/ecosystem/rpc/price.mdx b/ecosystem/rpc/price.mdx new file mode 100644 index 00000000..841f06dd --- /dev/null +++ b/ecosystem/rpc/price.mdx @@ -0,0 +1,5 @@ +--- +title: "Jetton prices API" +--- + +Stub From 41ca614aadddfa616235945fd78babc832de908f Mon Sep 17 00:00:00 2001 From: kaladin <335095@niuitmo.ru> Date: Thu, 9 Oct 2025 17:06:57 +0300 Subject: [PATCH 2/8] fill article --- ecosystem/rpc/price.mdx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ecosystem/rpc/price.mdx b/ecosystem/rpc/price.mdx index 841f06dd..af0e27a4 100644 --- a/ecosystem/rpc/price.mdx +++ b/ecosystem/rpc/price.mdx @@ -2,4 +2,20 @@ title: "Jetton prices API" --- -Stub +In this article we will discuss different ways to retrieve Jettons historical prices on Decentralized Exchanges, DEXes. + +Each swap operation, either between native asset (Toncoin) and jetton or between two distinct jettons, has its price. This price is calculated by the internal DEX math algorithm, called AMM. Some services require information about previous swaps on the blockchain to use it in their internal business logic or to simply show statistics to users. + +## Off-chain API + +The most often use case for price API is to fetch jetton info on the web2 backend and use aggregated data inside the service. There are several historical jetton prices providers in TON: + +- [dTon](https://docs.dton.io/about-pnl) +- [CoinGecko](https://www.coingecko.com/en/api/ton) +- [Dyor.io](https://dyor.io/tonapi) + +You can find detailed information about API usage technical details in provider docs. + +## On-chain API + +Currently it is not possible to retrieve **historical** jetton prices on-chain - since TON contracts [are limited by storage](/guidebook/from-ethereum#limited-contract-storage) it is quite hard to implement such API fully on-chain. However it is possible to retrieve **current** prices via Request-Response pattern on some DEXes, refer to specific service documentation to learn more about it. From eab08e27808ee10de44d202e7e5a1dbfeaabe658 Mon Sep 17 00:00:00 2001 From: kaladin <335095@niuitmo.ru> Date: Mon, 13 Oct 2025 12:06:34 +0300 Subject: [PATCH 3/8] real time and fixes --- ecosystem/rpc/price.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ecosystem/rpc/price.mdx b/ecosystem/rpc/price.mdx index af0e27a4..e333dd84 100644 --- a/ecosystem/rpc/price.mdx +++ b/ecosystem/rpc/price.mdx @@ -4,7 +4,7 @@ title: "Jetton prices API" In this article we will discuss different ways to retrieve Jettons historical prices on Decentralized Exchanges, DEXes. -Each swap operation, either between native asset (Toncoin) and jetton or between two distinct jettons, has its price. This price is calculated by the internal DEX math algorithm, called AMM. Some services require information about previous swaps on the blockchain to use it in their internal business logic or to simply show statistics to users. +Each swap operation, either between native asset (Toncoin) and jetton or between two distinct jettons, has its price - fixed exchange rate of one asset to another. This price is calculated by the internal DEX math algorithm, called [AMM](https://www.coinbase.com/learn/advanced-trading/what-is-an-automated-market-maker-amm). Some services require information about previous swaps on the blockchain to use it in their internal business logic or to simply show statistics to users. ## Off-chain API @@ -16,6 +16,8 @@ The most often use case for price API is to fetch jetton info on the web2 backen You can find detailed information about API usage technical details in provider docs. +There is no established solution for real-time jetton swap market data, however one can explore [CoinGecko websocket API](https://docs.coingecko.com/websocket). + ## On-chain API Currently it is not possible to retrieve **historical** jetton prices on-chain - since TON contracts [are limited by storage](/guidebook/from-ethereum#limited-contract-storage) it is quite hard to implement such API fully on-chain. However it is possible to retrieve **current** prices via Request-Response pattern on some DEXes, refer to specific service documentation to learn more about it. From a60a900ebf8b3fc8048986c51e6437cab59d70d8 Mon Sep 17 00:00:00 2001 From: kaladin <335095@niuitmo.ru> Date: Mon, 13 Oct 2025 12:20:06 +0300 Subject: [PATCH 4/8] add example --- ecosystem/rpc/price.mdx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ecosystem/rpc/price.mdx b/ecosystem/rpc/price.mdx index e333dd84..998e3e95 100644 --- a/ecosystem/rpc/price.mdx +++ b/ecosystem/rpc/price.mdx @@ -21,3 +21,33 @@ There is no established solution for real-time jetton swap market data, however ## On-chain API Currently it is not possible to retrieve **historical** jetton prices on-chain - since TON contracts [are limited by storage](/guidebook/from-ethereum#limited-contract-storage) it is quite hard to implement such API fully on-chain. However it is possible to retrieve **current** prices via Request-Response pattern on some DEXes, refer to specific service documentation to learn more about it. + +For example, on DeDust DEX it is possible to retrieve pool information on-chain with internal message with following [TL-B](/language/TL-B/overview): + +```tlb +provide_pool_state#6e24728d query_id:uint64 include_assets:Bool = InMsgBody; + +take_pool_state#bddd4954 query_id:uint64 reserve0:Coins reserve1:Coins total_supply:Coins + assets:(Maybe ^[ asset0:Asset asset1:Asset ]) = InMsgBody; +``` + +Here is smart contract snippet on [Tolk](/language/tolk) of how you would send "provide" message: + +```tolk +struct (0x6e24728d) ProvideDeDustPool { + queryId: uint64 + doIncludeAssets: bool +} + +fun main() { + val requestDeDustPoolInfoMsg = createMessage({ + body: ProvideDeDustPool { queryId: 1, doIncludeAssets: true }, + bounce: true, + dest: dedustPoolAddress, + value: 0, + }); + + requestDeDustPoolInfoMsg.send(SEND_MODE_CARRY_ALL_REMAINING_MESSAGE_VALUE); +} + +``` From f8bc1a04e0b7f518efc0c127dc39513d134eea63 Mon Sep 17 00:00:00 2001 From: Anton Trunov Date: Tue, 14 Oct 2025 12:18:07 +0400 Subject: [PATCH 5/8] Update ecosystem/rpc/price.mdx --- ecosystem/rpc/price.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem/rpc/price.mdx b/ecosystem/rpc/price.mdx index 998e3e95..6dd75fac 100644 --- a/ecosystem/rpc/price.mdx +++ b/ecosystem/rpc/price.mdx @@ -22,7 +22,7 @@ There is no established solution for real-time jetton swap market data, however Currently it is not possible to retrieve **historical** jetton prices on-chain - since TON contracts [are limited by storage](/guidebook/from-ethereum#limited-contract-storage) it is quite hard to implement such API fully on-chain. However it is possible to retrieve **current** prices via Request-Response pattern on some DEXes, refer to specific service documentation to learn more about it. -For example, on DeDust DEX it is possible to retrieve pool information on-chain with internal message with following [TL-B](/language/TL-B/overview): +For example, on the [DeDust](https://dedust.io) DEX it is possible to retrieve pool information on-chain using an internal message with following [TL-B](/language/TL-B/overview) schema: ```tlb provide_pool_state#6e24728d query_id:uint64 include_assets:Bool = InMsgBody; From 34702dd948c0201a520a9a5e71a644524c89dd40 Mon Sep 17 00:00:00 2001 From: Anton Trunov Date: Tue, 14 Oct 2025 12:18:30 +0400 Subject: [PATCH 6/8] Update ecosystem/rpc/price.mdx --- ecosystem/rpc/price.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem/rpc/price.mdx b/ecosystem/rpc/price.mdx index 6dd75fac..7749dc10 100644 --- a/ecosystem/rpc/price.mdx +++ b/ecosystem/rpc/price.mdx @@ -22,7 +22,7 @@ There is no established solution for real-time jetton swap market data, however Currently it is not possible to retrieve **historical** jetton prices on-chain - since TON contracts [are limited by storage](/guidebook/from-ethereum#limited-contract-storage) it is quite hard to implement such API fully on-chain. However it is possible to retrieve **current** prices via Request-Response pattern on some DEXes, refer to specific service documentation to learn more about it. -For example, on the [DeDust](https://dedust.io) DEX it is possible to retrieve pool information on-chain using an internal message with following [TL-B](/language/TL-B/overview) schema: +For example, on the [DeDust](https://dedust.io) DEX it is possible to retrieve pool information on-chain using an internal message with the following [TL-B](/language/TL-B/overview) schema: ```tlb provide_pool_state#6e24728d query_id:uint64 include_assets:Bool = InMsgBody; From 2edef2d5aed2c8c1882cf293155f4d0894fcdd2a Mon Sep 17 00:00:00 2001 From: Anton Trunov Date: Tue, 14 Oct 2025 12:19:25 +0400 Subject: [PATCH 7/8] Update ecosystem/rpc/price.mdx --- ecosystem/rpc/price.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem/rpc/price.mdx b/ecosystem/rpc/price.mdx index 7749dc10..a69cbbf4 100644 --- a/ecosystem/rpc/price.mdx +++ b/ecosystem/rpc/price.mdx @@ -31,7 +31,7 @@ take_pool_state#bddd4954 query_id:uint64 reserve0:Coins reserve1:Coins total_sup assets:(Maybe ^[ asset0:Asset asset1:Asset ]) = InMsgBody; ``` -Here is smart contract snippet on [Tolk](/language/tolk) of how you would send "provide" message: +Here is a smart contract snippet in [Tolk](/language/tolk) illustrating how you can send the 'provide' message: ```tolk struct (0x6e24728d) ProvideDeDustPool { From 57cb27dfe88984149d393709932ca968f685561e Mon Sep 17 00:00:00 2001 From: Anton Trunov Date: Tue, 14 Oct 2025 12:19:58 +0400 Subject: [PATCH 8/8] Update ecosystem/rpc/price.mdx --- ecosystem/rpc/price.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/ecosystem/rpc/price.mdx b/ecosystem/rpc/price.mdx index a69cbbf4..b5245951 100644 --- a/ecosystem/rpc/price.mdx +++ b/ecosystem/rpc/price.mdx @@ -49,5 +49,4 @@ fun main() { requestDeDustPoolInfoMsg.send(SEND_MODE_CARRY_ALL_REMAINING_MESSAGE_VALUE); } - ```