Real Madrid captain Federico Valverde has agreed a new contract which will run until 2031, the club confirmed on Friday.