Skip to content

🐞 [Bug]: TFT price inconsistencies #1410

@sameh-farouk

Description

@sameh-farouk

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).

  • Fix tfgrid-sdk-go calculator package
  • Check if the same issue exists in tfgrid-sadk-ts packages or other components.

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

Metadata

Metadata

Assignees

Labels

type_bugSomething isn't working

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions