Less than two years ago, Jeremy Lin was an undrafted free agent just looking to make an NBA team.

Halfway through his second year, Lin is the talk of the NBA and on his way to a big payday.

Lin is making $762,195 this season, which is the league minimum for a player in his second year. When Lin's contract is up at the end of the season, you can be sure numerous teams will be competing to sign the young point guard.

What do the Knicks have to do to keep Lin? Can any team sign him?

At the end of the season, Lin becomes a restricted free agent. This means that other NBA teams are allowed to make an offer to Lin, but the Knicks can match any offer.

Lin, however, does not have Bird Rights. This means New York can't offer him any contract they want. Bird Rights allow teams to make contract offers to their own players that exceed salary cap limitations. Lin does not fall under this rule because the Knicks claimed him off waivers.

The good news for the Knicks is they probably won't have to pay him too much. Under what is being called the Arenas Rule, there's a limit to what other teams can offer Lin. If Lin signs a contract with another team, he won't be able to make more than the league average salary.

New York would not be able to pay Lin whatever it wants, but they'll be able to match whatever other teams can offer him. The Knicks would be able to use their mid-level exception to sign Lin. This exception is slightly higher than the league average salary.

The Knicks would be able to offer Lin more than the mid-level exception, but they would have to clear enough salary cap space in order to do so.

If Lin continues to play at a high level, the Knicks will likely offer him a deal worth about $5 million a year.

A week and a half ago, most Knicks fans wouldn't have cared if the team released Lin. Now, Lin is a fan favorite and people are wondering about his future.

Since Lin entered the Knicks starting lineup, New York has paid him just over $12,000 per game.

Wherever he ends up next season, you can be sure he'll be making a lot more than that.