I don't quite get it, but if he's comfortable giving $$ back to Riley (as Udonis Haslem did), then that's his right.
But he probably can't sign a 5yr deal, since he'll be an over-36 year for the fifth year, and that salary will, in effect, raise his cap hit of his "normal" 1st year by ~25%. (Coon CBA #57). If he was to sign a deal starting at, say, the 13.75M that they'd need for Melo to join up, then he could only get about 4/61. As he's already guaranteed 2/41.8M, he's basically betting that he'd earn no more than about 10m/yr over the last 2 years of any future deal.