If you want to buy something worth a certain amount, the best method is to overestimate by more than the expected slippage. We have a method on the SDK to estimate the required fromAmount you need to get a toAmount on the destination chain. It uses coingecko prices to approximate a number.
Get a fromAmount based on fromToken, toToken and toAmount.