This is data mined, so I can't guarantee the reliability of this, but the cost to upgrade any spawner is (current level)^2*300 coins and (current level)+5 materials.
Which means that the total cost of a spawner is (initial cost)+(current level-1)(current level)(current level*2-1)*50 coins and (current level)(current level-1)/2+5*(current level-1) materials.
Which means that the total cost of a spawner is (initial cost)+(current level-1)(current level)(current level*2-1)*50 coins and (current level)(current level-1)/2+5*(current level-1) materials.