I'm confused. What is the distinction between craving/hating (desire/aversion) and "ego"? I am inclined to believe that ego, i.e. one's false sense of an independent separate eternal self, learns and developes craving/aversion, beginning during childhood. Perhaps there is no distinction, and the query is really a matter of semantics. Might "ego" be the noun that represents the verbs "craving and hating"; or, might the ego represent a broader condition than craving and hating? The word "ego" brings to mind "I me mine" identity, which might include "craving/hating".
The three poisons, greed, anger, and delusion, constitute the base-causes for beings stuck in samsara. Of these, delusion is the root cause from which greed and aversion arise. Avidya (delusion) is the root chain of the Twelve Nidanas , from which all other conditions for continued becoming arise.
Through the arising of these twelve nidanas, based on ignorance/misapprehension of reality as it is, the constituent parts of what we consider an "ego" arise ( consciousness/perceptions of the sense organs, feelings, sensations, etc.)
From this misapprehension of reality (ignorance) as either pleasant and something worth possessing, or unpleasant and unfit to endure, desire and anger arise.
I hope this helps clear this up!