0

I am building a smart contract which keep the token holder's eths for a while and give them rewards when they withdraw. The reward is given from the ethers collected by early withdraw of people. If someone made withdraw before the time period expires then he has to pay penalty fee and that penalty fee will be distributed to the token holders who have their deposits in contract currently at the moment when penalty fee was paid.

My question is that, how shall I do it efficiently to distribute penalty fee? The reason to ask this question is:

if penalty fee is so small then dividing it at that moment among all token holders will make each share even more smaller and i am afraid if the solidity doesn't write 0 instead of 0.9 weis (may be)

The second point i am thinking of is that how to efficiently allocate the rewards to stakers currently present in contract? If the people who have their deposit in contract (stakers) is above hundred or thousands, then alloting the reward to each one of them will need me to iterate over the complete array or something, this will require more gas and I am not sure if it will always be successful even for million stakers?

I need to keep a record that which penalty fee is deserved by which stakers.

I am looking towards the best efficient and low gas consumption implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.