fix: keep AggMonetaryPolicy4 EMA discount active#159
Draft
AlbertoCentonze wants to merge 1 commit intomasterfrom
Draft
fix: keep AggMonetaryPolicy4 EMA discount active#159AlbertoCentonze wants to merge 1 commit intomasterfrom
AlbertoCentonze wants to merge 1 commit intomasterfrom
Conversation
|
Note: This analysis is qualitative; immutables aren't accounted for (static analysis on predeployment bytecode). Runtime bytespace changescurve_stablecoin/mpolicies/AggMonetaryPolicy4.vy
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AggMonetaryPolicy4even when current PegKeeper debt drops back to zero, so the rate adjustment decays smoothly instead of being bypassed in a single step.expimplementation withsnekmate's WAD exponential helper while keeping the previous zero/overflow wrapper semantics.Context
Previously, the debt-ratio adjustment was only applied when
pk_debt > 0. That meant the policy could accumulate a nonzero debt-ratio EMA, but as soon as current PegKeeper debt went back to zero the EMA term stopped affecting the rate immediately.The change here makes the rate calculation always read the existing debt-ratio EMA. This preserves the intended smoothing behavior: once the PegKeeper discount has built up, it fades out gradually instead of disappearing in one update.
Edge Case Note
When aggregate controller debt is observed as zero, this change intentionally leaves
ratio = 0rather than introducing more invasive handling around EMA updates.That state should be rare in practice because it requires all controllers tracked by this policy to report zero or unreadable debt at the same time. In that case, letting the EMA slowly remove the PegKeeper discount is acceptable and keeps the change narrowly scoped to the bypass issue.