A new contract is a win for everyone other than madrid.
If he gets 300k a week out of them, plus sign on bonus, he'd be looking at 20m for this season vs the 44k a week he'd be on otherwise. Manu put a 20m release clause on it and then regardless of whether they'd not be making a profit next summer if the clause was triggered, they wouldnt look like amateurs as they wouldve sold him for 20m - no one would write about that they may have ended up paying that amount to get him to sign - rather than looking like the club that ballsed up his transfer then lost him for nothing, plus they may get a more focussed player for the season.
Mendes would be happy cos he'd get his money from the contract extension, and then also from him going to madrid, plus he'd then be able to demand more than 300k a week off madrid whereas now madrid know giving him 150k would still be 300% increase on his current contract.
Madrid would then either have to end up paying more than they prolly would had he gone on a free or have to find a new gk. The risk for de gea is if madrid then decided he wasnt worth it, then he'd be stuck in manchester, albeit on a good contract.