shapeshift / rFOX

rFOX - RUNE rewards for FOX stakers
MIT License
0 stars 0 forks source link

Feat/on chain accounting #40

Closed 0xean closed 1 month ago

0xean commented 1 month ago

Add on-chain accounting for "rewards" a generic unit of account that we can use to reconcile off chain for RUNE distribution. Essentially, they act like points.

Also adds some paranoia with a non-reentrant modifier...

Only last question is should we add the ability to set the REWARD_RATE so that if we end up using these as points, and we have multiple pools as is being discussed with DFC, we can modify the REWARD_RATE to be meaningful.

0xean commented 1 month ago

The only thing that may not be a nitpick is we may want to leverage emitting events more, but at the end of the day we'd still need to go through historical blocks so this may be fluff?

I think we now have two ways to do off-chain accounting.

  1. We get all of the staking and unstaking events and manually process each of them, no archive node required, but a lot of math to get right.
  2. We use the new on-chain accounting and an archive node. Essentially no-math. endRewards - startRewards.

Combining both of these allows us to double check our work and flexibility for different scenarios.