Skip to content

Feat/strategy versioning migration helper#215

Open
Escelit wants to merge 3 commits into
Dgetsylver:mainfrom
Escelit:feat/Strategy-versioning-migration-helper
Open

Feat/strategy versioning migration helper#215
Escelit wants to merge 3 commits into
Dgetsylver:mainfrom
Escelit:feat/Strategy-versioning-migration-helper

Conversation

@Escelit
Copy link
Copy Markdown
Contributor

@Escelit Escelit commented May 30, 2026

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, calls receive_migration. Gated by from.require_auth().
  • receive_migration(to, amount): accepts pre-funded tokens, re-leverages, mints V2 shares.
  • STRATEGY_VERSION constant + get_version() in storage.
  • Bug fix: is_full_close was checking user_shares >= total_shares, which is never true for a sole depositor due to FIRST_DEPOSIT_LOCKUP. Fixed to total_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 healthy
  • test_migrate_with_pool_rate_change — migration after time + new borrowers change rates
  • test_migrate_requires_user_auth — attacker cannot migrate another user's position
  • test_get_version_returns_one — freshly deployed strategy reports version 1

47/47 tests pass.

Acceptance criteria

  • ✅ Migration preserves HF and balances within rounding
  • ✅ Per-user, gated by user's signature
  • ✅ Tests cover migration with live pool-state changes

Closes #54

Escelit added 3 commits May 30, 2026 10:40
- 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
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@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! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D13: Strategy versioning + migration helper

1 participant