Do you still love him? Would you love him if he was to improve?
Ask him to knock the coke on the head for you and your children. Surely if he is half a brain left he will acknowledge that he is being affected in a negative way from it and it is damaging not only his own life , but yours and your kids too.
You will probably see that his mood and behaviour improves with time the longer he manages to go without taking it. If he's not willing to stop , or at least , try stopping or seriously cutting down , and be very clear that you are serious about it , then maybe you should look to get out of there.
You have admitted to doing coke with him yourself only recently, something that all but 1 (I think) of the previous posters acknowledged.The rest just wheeled out the stock answers of leave this bastard immediately as he is scum and it's better for the kids to have no dad than this loser. I'm not judging you,and he sounds a bit of a nightmare at the moment tbf, but given you did it with him, you probably accept that a lot of things are alright in moderation. Coke and moderation don't really go hand in hand though and so many people are regular users these days and with that so many people are spending half their lives coming down , paranoid , bad tempered, withdrawn. It's not a good drug and it's likely to be mixed with all kinds of shite these days anyway. Plus it costs a fortune that could be spent on the kids or family bills.
Good luck. Whatever course you choose.