As a matter of course, I avoid long term contracts. Despite best intentions, nobody knows where they will be or what they will want in two years. If you offer a discounted rate, you still carry risk, at a discount despite no assurance that the contract might be cut in X months.
Even if there is a clause to remunerate you if the project was to terminate early, a client could well just assign you to another project, or just make your life hell to encourage you to leave (so they could avoid remunerating you for shortening the contract).
If you like the client, offer a 10% discount on your normal rate. The two year commitment from you is a promise that your rate will stay unchanged for the period of the contract (you still have to cover your own health, pension, sick pay holiday pay etc... these expenses don't just go away and your client might need reminding of this).
If you are based in Europe, you may not realise that the two year contract is a client trying to bend the law. EU Employment dictates something like maximum two contracts within two years maximum time frame - after that, employer can be compelled to provide health/pension/sick/holiday pay like they would a fulltime employee. Your client might be trying to avoid this (by offering you one long contract knowing full well they can throw you overboard if business or other conditions change).