complete calculateSupply function