I'm writing a smart contract function that rewards users some rate of interest/reward for holding my stablecoin over owning competitors (Dai, Tether, etc). What is the most efficient manner to calculate this in a
collect_interest function? I've studied how the Dai Savings Rate (DSR) and compound.finance work, and I think my implementation would need to be slightly different because users don't deposit the stablecoin into a contract like DSR or compound. They simply earn interest/rewards for owning the stablecoin in their address. The amount of stablecoin they own in their address can vary across time so their reward can vary as a result, and the function would have to check which windows of time the user has already collected interest/rewards so they don't collect interest more than once for each period.
Is this too complicated or too inefficient/costly? Should I just replicate compound/DSR and have holders of my stablecoin deposit it into an
interest_rate smart contract and receive a 1:1
interest_rate_ERC20 token like compound? Or is there a simple way to do this that I'm not seeing? Thanks in advance, even just pointing me to an example link would help.