You lose everything that you have downloaded and all of your saved game data will be erased. Friends and purchase content from the PlayStation Store will be un tounched. But if you are going along with restoring your system make sure to deactivate your account first.
If you got your game saves saved via cloud then you should be good.
No thats wasnt very obvious. That why i added. But nice try though.