Divergences as a grading of the formal variational calculus