Nicky Hayden has agreed a contract extension and will stay with Ducati's works MotoGP squad for 2013.