1) Masturbation is Haram ( prohibited) in Islam. You can’t pray namaz after masturbation unless you have done Ghusl e Janabat.
It is Farz (wajib) to do Ghusl after evacuating semen either while you are sleeping or awake.
2) As long as its not a semen and has no sign of being semen its pak but make sure masturbation is HARAM and it will invalidate your fast and then there is a huge Kaffara you have fast 2 months (60) fasts continuously. So don’t do that sin again.