Lionel Messi has agreed a new contract with Barcelona which will make him the best-paid player in the world.