There is always oxygen present.  Perhaps not in quantities to sustain aerobic life, but to some capacity.  The tooth passes fluid through diffusion channels and tubules constantly, and oxygen can be preferentially bound to by numerous materials. Also the restoration process itself can introduce oxygen, and sometimes energy in the form of light or other, that can cause or quicken the blackening.  GI restorations are designed to be porous and allow some transfer.