OriginProtocol / ousd-analytics

Web application to pull statistics on OUSD from the blockchain.
8 stars 3 forks source link

PoY-v0.75 accounting #351

Closed HrikB closed 1 year ago

HrikB commented 1 year ago

The relevant accounting/data exposed for step 0.75 in Proof of Yield.

We want to be able fill out this section. image

In this PR, I made a change to how the change (in percent) from one day to another was calculated. Previously, change was calculated by finding the difference in between rebasing_credits_per_token at the beginning and end of the time period, and dividing by the rebasing_credits_per_token at the beginning of the time period to receive a percentage.

change = 1 - (s.rebasing_credits_per_token / last_snapshot.rebasing_credits_per_token)

However, later using this value to compute the total yield resulted in a discrepancy between the total yield, and the sum of the yields from the rebase events.

s.gain = change * (s.computed_supply - s.non_rebasing_supply)

This isn't great since I imagine the purpose of this section in PoY is to show that the rebase events do add up. So now I calculate change using the sum of the rebase events.

change = Decimal(sum(event['amount'] for event in s.rebase_events) / 1e18) / (s.computed_supply - s.non_rebasing_supply)