Negative Interest: Zombie Edition#721
Conversation
efdaae5 to
6713d9b
Compare
Hyperdrive Gas Benchmark
This comment was automatically generated by workflow using github-action-benchmark. |
jrhea
left a comment
There was a problem hiding this comment.
This is fantastic! I'd be good if you pasted the spec text into the PR description. I'll wait to approve until you have time to make changes we discussed
a90309b to
60742ab
Compare
Another way to express this is that both receive their fair share of the remaining zombie reserves: |
Negative Interest: 🧟 Edition
When
_applyCheckpointis used to close positions at maturity, we apply the share proceeds of closing these positions to the share reserves. At this point, the reserves will reflect any negative interest that accrued during the life of these positions.Whenever a new checkpoint is minted, the zombie interest mechanism will deduct positive interest that accrues on the matured positions. Thus, after applying the checkpoint, the base amount reserved for the zombie positions will be equal the total base proceeds required to pay out all of the zombie positions. This fact makes zombie positions sensitive to negative interest that accrues in the current checkpoint as the following example demonstrates.
Example
Suppose that Hyperdrive has no outstanding longs or shorts,$c = 1$ , $z = 1,000$ , and $z_{zombie} = 0$ .
checkpointis called. Alice's proceeds are deducted from the share reserves and placed into the zombie share reserves.checkpointis called and the zombie interest is deducted from the zombie share reserves and placed into the share reserves.Proposed Fix #1 (Doesn't Work)
Whenever zombie interest accrues, we record the maximum share price at which we collected zombie interest,$c_{max}$ . Having this variable around allows us to detect when negative interest accrued on the zombie share reserves and also has the side benefit of letting us easily collect zombie interest across checkpoint gaps.
Using$c_{max}$ , we apply the full negative interest haircut to zombie longs and shorts. In the example, Alice's share proceeds would be adjusted as:
This is smaller than the zombie share reserves. The discrepancy of$0.02$ is caused by rounding, and the true result would be much closer to the zombie share reserves.
Problem
The problem with this fix is that it doesn't track which zombie positions were effected by the negative interest. Consider the following example:
If Alice and Bob both redeemed their matured positions, the negative interest haircut would be applied to both of them. This means that Alice would receive$1000 \cdot (1 + \tfrac{1.04 - 1.05}{1.04}) = 990.47$ . Bob would receive $100 \cdot (1 + \tfrac{1.04 - 1.05}{1.04}) = 99.04$ . Collectively, this is equal to $\tfrac{990.47 + 99.04}{1.04} = 1047.60$ , which is less than the zombie share reserves.
To summarize the problem, this solution incorrectly socializes losses across the entire zombie share reserves, which leaves some of the zombie share reserves unspent if all of zombie positions are closed after negative interest accrues.
Proposed Fix #2 (Works)
Anytime we move matured positions into (or out of) the zombie share reserves, we add (or subtract) the share proceeds to the zombie share reserves,$z_{zombie}$ AND we add (or subtract) the base proceeds to the new field called "zombie base reserves," $x_{zombie}$ .
When we collect zombie interest, all we do is take the difference of$c \cdot z_{zombie}$ and $x_{zombie}$ , check to see the difference is greater than zero, and move that amount of base to the share reserves.
When a trader closes a matured position, we check to see if$c \cdot z_{zombie} < x_{zombie}$ . If the inequality holds, then negative interest has accrued on the zombie share reserves and we discount the trader's base proceeds by $\tfrac{c \cdot z_{zombie}}{x_{zombie}}$ . Otherwise, we just pay out the base proceeds normally.
Let's try the example from "Proposed Fix #1" and see if we get a different result:
If Alice and Bob both redeemed their matured positions, we discount both of them by the ratio$\tfrac{1.04 \cdot 1,048.53}{1,100} = \tfrac{1090.47}{1,100}$ . This means that Alice would receive $1,000 \cdot \tfrac{1090.47}{1,100} = 991.33$ . Bob would receive $100 \cdot \tfrac{1090.47}{1,100} = 99.1$ . Collectively, this is equal to $\tfrac{991.33 + 99.1}{1.04} = 1048.49$ , which is approximately equal to the zombie share reserves (the small discrepancy is caused by rounding to 2 significant digits).
This solution isn't perfect considering that Bob still takes a hit due to negative interest; however, it does ensure that all of the zombie share reserves can be paid out. Doing the accounting perfectly (by properly attributing negative interest to each checkpoint) appears to be computationally infeasible on Ethereum (I'm happy to be proven wrong here, but I haven't thought of a way to do it). IMO this solution is good enough.