fix: add missing refresh_hwm call in process_deposit_junior - #122
Conversation
process_deposit refreshes the epoch high-water mark after updating pool state (lines 564-569, PERC-313), but process_deposit_junior did not. Junior deposits increase total_pool_value() without ratcheting epoch_high_water_tvl, leaving the HWM-based withdrawal floor calculated against a stale (lower) peak. If a loss event occurs before the next senior deposit or withdrawal, the peak TVL from the junior deposit is permanently lost from HWM tracking, weakening the drain protection. Added the same refresh_hwm block after pool state updates, matching the pattern in process_deposit exactly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
process_depositrefreshes the epoch high-water mark after updating pool state (lines 564-569, PERC-313)process_deposit_juniordoes not, despite also increasing TVL viatotal_deposited,total_lp_supply,junior_total_lp, andjunior_balancetotal_pool_value()without ratchetingepoch_high_water_tvl, leaving the HWM-based withdrawal floor calculated against a stale (lower) peakSeverity
MEDIUM — weakens HWM drain protection asymmetrically (senior deposits refresh HWM, junior deposits do not)
Fix
Added the same
refresh_hwmblock after pool state updates, matchingprocess_depositexactly:Placement: after all 4 pool state mutations (lines 1930-1947), before deposit PDA logic (line 1960). Uses the
clockalready read at line 1949.Verification
process_deposit(lines 564-569)total_pool_value()cannot realistically return None at this point (deposit just increased it)_reserved[16..31]— no byte conflicts with tranche state (_reserved[32+])Test plan
cargo build— compiles cleanlycargo clippy— zero warnings🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes