Feat/strategy versioning migration helper#215
Open
Escelit wants to merge 3 commits into
Open
Conversation
- Add Safe Max button next to leverage slider; snaps to highest leverage where projected HF >= user-configured floor - Add HF floor input in settings dropdown (default 1.2, min 1.01) - Persist floor value in localStorage under safeMaxHfFloor key
- Sort by asset, leverage, HF, unrealised P&L; second click reverses - Compact view renders a one-row-per-position table; expanded keeps cards - Sort column, direction, and view preference persisted in localStorage - P&L column shows unrealised gain/loss when a PnL entry exists
- migrate(from, to_strategy): burns V1 shares, unwinds Blend position atomically, transfers equity to V2, calls receive_migration on V2. Gated by from.require_auth(). - receive_migration(to, amount): accepts pre-funded tokens from V1, re-leverages, mints V2 shares. - STRATEGY_VERSION constant + get_version()/set_version() in storage. - Fix is_full_close detection: sole depositor has user_shares == total_shares - FIRST_DEPOSIT_LOCKUP, not total_shares. Use total_shares - user_shares <= LOCKUP to correctly trigger the single-sweep full-close path and avoid per-step HF failures after interest accrual. - Tests: test_migrate, test_migrate_with_pool_rate_change, test_migrate_requires_user_auth, test_get_version_returns_one. All 47 tests pass. Closes Dgetsylver#54
|
@Escelit Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Implements D13: atomic per-user V1→V2 migration without exit/re-entry.
Changes
migrate(from, to_strategy): burns V1 shares, unwinds Blend position atomically, transfers equity to V2, callsreceive_migration. Gated byfrom.require_auth().receive_migration(to, amount): accepts pre-funded tokens, re-leverages, mints V2 shares.STRATEGY_VERSIONconstant +get_version()in storage.is_full_closewas checkinguser_shares >= total_shares, which is never true for a sole depositor due toFIRST_DEPOSIT_LOCKUP. Fixed tototal_shares - user_shares <= LOCKUP, correctly triggering the single-sweep full-close path and avoiding HF error #1205 after interest accrual.Tests
test_migrate— basic migration, balance within 2%, V2 HF healthytest_migrate_with_pool_rate_change— migration after time + new borrowers change ratestest_migrate_requires_user_auth— attacker cannot migrate another user's positiontest_get_version_returns_one— freshly deployed strategy reports version 147/47 tests pass.
Acceptance criteria
Closes #54