But where does the ambiguity arise from in this case?
I would argue that the grammar is (pretty much) unambiguous, that the for grammatical construction means that wheat is to be given in return for sheep. I don’t think most people would usually read that grammatical construction as wheat for the purpose of getting sheep. I think the ambiguity lies not in the grammar, but in not knowing which of two people has each of the two things.