Distributing dividends via smart contracts is difficult with a large number of shareholders. A naive implementation could look something like this:
for s in shareholders:
dividend = s.shares/total_shares * total_dividends
This is not practical when the number of shareholders is large because you will quickly reach the block gas limit. Instead you can use a pull system, allowing users to claim their dividends directly, but this method requires a large number of transactions.
Another alternative method to distribute the value of dividends is to use the dividend to directly increase the value of the shares. One example of how this might be done is the following:
- Collect fees in ETH or any other token.
- Every week create an auction which buys shares with the collected ETH.
- Once the auction completes, provably burn the purchased shares.
Periodically buying and burning shares with fees collected has a similar effect to sending ETH directly. It is not quite the same, but still it's a good trick to have in your cryptoeconomic toolbelt. There are a bunch of variations on this mechanism & analysis that can be done; however, I'll leave that to you, dear reader ✨