Each league has a set salary cap. If you go over it, you pay into a pool that gets distributed to all teams below the salary cap. If you are under it, you receive money from that pool. The amount that goes into a pool and gets distributed can vary due to number of teams contributing, amount of contribution, number of teams taking from said total amount.