Ported chain oracle from matlab