OriginProtocol / oeth.com

Frontend for oeth.com
2 stars 1 forks source link

Add today back to Proof of Yield #100

Open micahalcorn opened 1 year ago

micahalcorn commented 1 year ago

For #47, we decided to leave "today" off of the 30-day history (first page) of Proof of Yield. This was to avoid an unhappy experience we had back in the day when /apy would show an APY that fell throughout the day. Here's why that was happening:

🟨 = hour (+/- 300 blocks) ♻️ = rebase

Scenario A 🟨 🟨 ♻️ 🟨 🟨

Scenario B 🟨 🟨 ♻️ 🟨 🟨 🟨 🟨 🟨 🟨

Our APY calculation looks at the change in OETH supply, which is affected by rebases and transfers but not affected by growth in underlying collateral (pending rebase). It calculates the change in OETH supply since the last day, then it extrapolates this out into a full day of blocks and annualizes it. In scenario A, the change is effectively multiplied by SIX (24 hours in a day divided by 4 hours passed = 6). In scenario B, the change is effectively multiplied by THREE (24 hours divided by 8 hours passed = 3). As a result, the APY from A expects to have a rebase every 4 hours. The APY from B expects to have a rebase every 8 hours. In reality, there is unlikely to be a second rebase unless a large mint or redeem occurs.

If my understanding is correct, this is basically time-weighting the yield and projecting that the same earning rate will be experienced throughout the day. This is not what this page should do. It should report the actual amount of yield distributed within the given period. I think the way to fix it would be for the "today" line to account for when the last rebase had occurred (not including the prior day), figure out how many blocks had passed since then, and assume that there are no more rebases coming.