When the treasurer of any city of the second class or village holds funds of any such city or village in excess of the amount required for maintenance or set aside for betterments and improvements, the mayor and city council or the village board of trustees may, by resolution, direct and authorize the treasurer to invest such surplus funds in the outstanding bonds or registered warrants of such city or village, in bonds and debentures issued either singly or collectively by any of the twelve federal land banks, the twelve intermediate credit banks, or the thirteen banks for cooperatives under the supervision of the Farm Credit Administration, or in interest-bearing bonds or the obligations of the United States. The interest on such bonds or warrants shall be credited to the fund out of which such bonds or warrants were purchased.