In other words, if the price is fair, the yield of your futures contract should be the same as the market risk-free interest rate.
Otherwise, arbitrageurs will appear and change prices until the rate of return is equal to the risk-free rate of return in the market, and there will be no arbitrage opportunities.
The basic formula is continuous compound interest formula. Exp stands for continuous compound interest. T-t is the time when you hold this asset.
If the underlying asset provides a continuous dividend yield with an annual interest rate of Q, that is to say, you will get a certain amount of remuneration during holding the contract to ensure that your total yield on this contract is equal to the risk-free yield. So use r-q.