What happened?
I see the calculator package uses the (rounded) current market price when converting USD to TFT for estimating deployment prices.
|
// USDtoTFT converts USD amount to TFT based on the current price |
|
func (c *Calculator) USDtoTFT(usd float64) (float64, error) { |
|
tftPrice, err := c.substrateConn.GetTFTPrice() |
|
if err != nil { |
|
return 0, errors.Wrap(err, "failed to get TFT price") |
|
} |
|
// convert from unit-USD to TFT |
|
tftPriceUSD := float64(tftPrice) / mUSDToUSD |
|
return usd / tftPriceUSD, nil |
|
} |
However, the on-chain billing uses the average TFT price (aggregated from recent prices) clamped between pre-configured Min and Max. It is not the “current” market price, nor always min or max; it’s the bounded average.
Logic:
- Reads
pallet_tft_price::AverageTftPrice::<T>::get() (mUSD).
- Clamps it to the configured bounds:
- tft_price = max(
AverageTftPrice, MinTftPrice)
- tft_price = min(tft_price,
MaxTftPrice)
These inconsistencies will lead to varying prices. Currently, the calculator assumes 1 TFT to be 5 mUSD (current rounded market price), while on-chain, after applying the above logic, it assumes 1 TFT to be 10 mUSD (which is the configured minimum on-chain).
which network/s did you face the problem on?
Dev
Twin ID/s
No response
Version
No response
Node ID/s
No response
Farm ID/s
No response
Contract ID/s
No response
Relevant log output
What happened?
I see the calculator package uses the (rounded) current market price when converting USD to TFT for estimating deployment prices.
tfgrid-sdk-go/grid-client/calculator/calculate.go
Lines 494 to 503 in 31c9f95
However, the on-chain billing uses the average TFT price (aggregated from recent prices) clamped between pre-configured Min and Max. It is not the “current” market price, nor always min or max; it’s the bounded average.
Logic:
pallet_tft_price::AverageTftPrice::<T>::get() (mUSD).AverageTftPrice,MinTftPrice)MaxTftPrice)These inconsistencies will lead to varying prices. Currently, the calculator assumes 1 TFT to be 5 mUSD (current rounded market price), while on-chain, after applying the above logic, it assumes 1 TFT to be 10 mUSD (which is the configured minimum on-chain).
which network/s did you face the problem on?
Dev
Twin ID/s
No response
Version
No response
Node ID/s
No response
Farm ID/s
No response
Contract ID/s
No response
Relevant log output
NA