How to get TON-stTON rate
This section describes how to get stTON rate.
The fundamental TON-stTON rate is calculated using the formula:
stTON rate = ton_total_supply / jetton_total_supply
To retrieve ton_total_supply
and jetton_total_supply
you need to invoke 'get_full_data' method in Financial contract:
// TL-B:
get_full_data#_ = (
jetton_total_supply:Coins
ton_total_supply:Coins
commission_total_supply:Coins
commission_factor:uint16
commission_address:MsgAddressInt
admin_address:MsgAddressInt
transaction_address:MsgAddressInt
content:^Cell
jetton_wallet_code:^Cell
unstake_request_code:^Cell
last_lockup_epoch:uint32
lockup_supply:Coins
next_lockup_supply:Coins
later_lockup_supply:Coins
next_unstake_request_index:uint64
)
https://tonviewer.com/EQDNhy-nxYFgUqzfUzImBEP67JqsyMIcyk2S5_RwNNEYku0k?section=method
See the screenshot:

These two values 0x2524443fb29fa1
and 0x275f0f797cee6d
are hexadecimal representations of jetton_total_supply
and ton_total_supply
. To convert them to decimal and compute the stTON price, you can use the following code in Python:
jetton_total_supply = int("0x2524443fb29fa1", 16)
ton_total_supply = int("0x275f0f797cee6d", 16)
Here is an example in Python:
from pytoniq import LiteClient
async with LiteClient.from_mainnet_config(trust_level=2) as client:
result = await client.run_get_method(
address="EQDNhy-nxYFgUqzfUzImBEP67JqsyMIcyk2S5_RwNNEYku0k",
method="get_full_data",
stack=[],
)
stton_price_in_ton = result[1]/result[0]
Last updated