The coevolution of cooperation and structure in biological markets