I've seen this thinking before: So the moral question is, 'if we can give animals (1) artificial/unnatural, but (2) reasonably enjoyable, and (3) relatively pain free,' for (4) some benefit to the machine of society, is that just? Interestingly, many modern liberal thinkers say no, but when this same moral questioning is applied to humans, you run into what the anti-liberal terrorist Ted Kraczynski was arguing about.
In other words, as of now you and I both live and probably work in society, sacrificing our natural freedom and state in nature to enjoy comforts and safety of our technological civilization; and yes, to die in a hospital rather than in nature.
Anyways I'm not suggesting any answers, just juxtaposing the same ideas applied unequally, which suggests an implicit collective answer of 'yes'to your question; or at least a tolerance to that answer.
And it's unfortunately partially unworldly thinking about these social contracts anyways: in the real world, farms are still grossly mistreating animals, as does civilization to people, where outcomes stem too often from money and violence; not always from social contracts / commitments to morals--which brings us full circle to the life of Tesla and his struggles with bullying.
I would be fuming if somebody electrocute me, that's for sure; but much better than if they kill me with a rusty axe. That would be very impolite and unforgeivable.