I don't know all the rules, but it basically is based on previous years salary.
It's why Dwayne Wade left so much money on the table. The lower salary he took so Miami could get the big 3 effect his max money every year after. And it's a percentage of the previous year. So the loss of money escalates too.