Proper folding of deeply knotted proteins has a very low success rate even in structure-based models which favor formation of the native contacts but have no topological bias. By employing a structure-based model, we demonstrate that cotranslational folding on a model ribosome may enhance the odds to form trefoil knots for protein YibK without any need to introduce any non-native contacts. The ribosome is represented by a repulsive wall that keeps elongating the protein. On-ribosome folding proceeds through a a slipknot conformation. We elucidate the mechanics and energetics of its formation. We show that the knotting probability in on-ribosome folding is a function of temperature and that there is an optimal temperature for the process. Our model often leads to the establishment of the native contacts without formation of the knot.