  A crucial phase during planetary growth is the migration when the planetary
core has been assembled, but the planet did not open a deep gap yet. During
this phase the planet is subject to fast type-I migration, which is mostly
directed inwards, and the planet can lose a significant fraction of its
semi-major axis. The duration of this phase is set by how long the planetary
envelope needs to contract until it reaches a mass similar to the mass of the
planetary core, which is when runaway gas accretion can set in and the planet
can open a deeper gap in the disc, transitioning into the slower type-II
migration. This envelope contraction phase depends crucially on the planetary
mass and on the opacity inside the planetary envelope. Here we study how
different opacity prescriptions influence the envelope contraction time and how
this in turn influences how far the planet migrates through the disc. We find
within our simulations that the size distribution of the grains as well as the
chemical composition of the grains crucially influences how far the planet
migrates before it can reach the runaway gas accretion phase. Grain size
distributions with larger grain sizes result in less inward migration of the
growing planet, due to faster gas accretion enabled by more efficient cooling.
In addition, we find that planets forming in water poor environments can
contract their envelope faster and thus migrate less, implying that gas giants
forming in water poor environments might be located further away from their
central star compared to gas giants forming in water rich environments. Future
studies of planet formation that aim to investigate the chemical composition of
formed gas giants need to take these effects self consistently into account.
