A function to evaluate whether a potential transaction is profitable