I think there is one mistake in your script. Pledge is also awarded with rewards. So you dont need to substract it from the active stake. Besides of that i think it looks good.
I think there is one mistake in your script. Pledge is also awarded with rewards. So you dont need to substract it from the active stake. Besides of that i think it looks good.