Skip to main content

LTMigrator

LTMigrator.vy — upgrade path without forcing users to withdraw.

Constants / Immutables

NameNotes
STABLECOINcrvUSD
FACTORY_OWNERMFOwner — validates LTs are factory-issued

External functions

SignaturePurpose
preview_migrate_plain(lt_from, lt_to, shares_in, debt_coefficient) → shares_outView — unstaked path
preview_migrate_staked(lt_from, lt_to, shares_in, debt_coefficient) → shares_outView — 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

StringCause
lt_to deprecatedTarget 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 outshares_out < min_out in staked migration

Flow

  1. 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).
  2. collect_fees() on source AMM (so fee accruals do not contaminate measurements).
  3. lt_from.withdraw(shares_in, 0) → receive asset + debt unwound through Cryptoswap.
  4. Temporarily inflate target's stablecoin_allocation to max((pool_value + additional_crvusd) × 2.2, previous_allocation) on target LT — gives the deposit headroom against the AMM.max_debt() / 2 cap.
  5. lt_to.deposit(assets, debt × debt_coefficient / 1e18, min_out, receiver) into target.
  6. Restore allocation to its previous value.
  7. For staked: unstake from source gauge before, re-stake into target gauge after.