Upgrades and Migration
I. Key Improvements in V2
Wrapped M (wM) fundamentally operates as a non-rebasing token where yield is realized through manual claiming, a characteristic distinct from the native M token's automatic rebasing. The V2 implementation builds upon this established model with several important enhancements:
- Re-enabling Earning: V2 allows earning to be re-enabled after being disabled
- Admin-Managed Earners: Introduction of EarnerManager for delegated administration
- Fee Mechanism: Ability for admins to take fees from yield
- Principal-Based Accounting: Changed from lastIndex tracking to principal amount tracking
- Explicit Claim Recipients: Added ability for users to explicitly set yield recipients
- Gas Efficiency: Optimized storage layout and operations
II. Migration from V1
The migration from V1 to V2 involved several key transformations:
Account Model Change
- V1: Used last interaction index for earning accounts
- V2: Uses principal amount for earning accounts
- Migration formula:
principal = balance ÷ lastIndex
Index Handling
- V1: Used an array for enable/disable indices
- V2: Uses enableMIndex and disableIndex slots
- Migration preserved earning state and index values
Migration Process
The migration was handled through a specialized migrator contract that:
- Identified all earning accounts in V1
- Converted their account structure to the V2 format
- Preserved their earning status and equivalent yield position