LTMigrator
LTMigrator.vy— upgrade path without forcing users to withdraw.
Constants / Immutables
| Name | Notes |
|---|---|
STABLECOIN | crvUSD |
FACTORY_OWNER | MFOwner — validates LTs are factory-issued |
External functions
| Signature | Purpose |
|---|---|
preview_migrate_plain(lt_from, lt_to, shares_in, debt_coefficient) → shares_out | View — unstaked path |
preview_migrate_staked(lt_from, lt_to, shares_in, debt_coefficient) → shares_out | View — staked path |
migrate_plain(lt_from, lt_to, shares_in, min_out, debt_coefficient) | Execute unstaked migration |
migrate_staked(lt_from, lt_to, shares_in, min_out, debt_coefficient) | Execute staked migration |
debt_coefficient default 1e18. Scale down (e.g. 0.9e18) to migrate with reduced leverage.
Reverts
| String | Cause |
|---|---|
lt_to deprecated | Target LT has been disabled in the factory owner (disabled_lts[lt_to] == True). The DAO sets this when winding a market down via lt_allocate_stablecoins(lt, 0). Migrate to a different LT. |
not enough out | shares_out < min_out in staked migration |
Flow
- Validate both LTs belong to a factory (via
FACTORY_OWNER.lt_in_factory()) and that the target is not disabled (disabled_lts[lt_to] == False). collect_fees()on source AMM (so fee accruals do not contaminate measurements).lt_from.withdraw(shares_in, 0)→ receive asset + debt unwound through Cryptoswap.- Temporarily inflate target's
stablecoin_allocationtomax((pool_value + additional_crvusd) × 2.2, previous_allocation)on target LT — gives the deposit headroom against theAMM.max_debt() / 2cap. lt_to.deposit(assets, debt × debt_coefficient / 1e18, min_out, receiver)into target.- Restore allocation to its previous value.
- For staked: unstake from source gauge before, re-stake into target gauge after.