Skip to main content

Quote & Route

View functions you can rely on.

Reliable quote surface

LT.vy exposes preview/quote view functions. Note LT is ERC-4626-like but not strictly compliant — signatures are custom and some ERC-4626 methods (previewMint, previewRedeem, mint, redeem) do not exist on LT. They DO exist on LiquidityGauge (the staker), which is strictly ERC-4626.

What you wantCall
Quote asset → crvUSD swapVirtualPool.get_dy(1, 0, dx)
Quote crvUSD → asset swapVirtualPool.get_dy(0, 1, dx)
Quote deposit (assets -> shares)LT.preview_deposit(assets, debt, raise_overflow=True) — reverts on overflow; pass False for a soft quote (returns 0 when debt would exceed AMM.max_debt() / 2)
Quote redemption (shares → assets, live Cryptoswap)LT.preview_withdraw(tokens) — parameter is share count
Current PPS (oracle-priced, sandwich-resistant)LT.pricePerShare()
Liquidity bucket stateLT.liquidity() returns (admin, total, ideal_staked, staked)
Emergency-path quoteLT.preview_emergency_withdraw(shares)
Gauge ERC-4626 (staker shares)LiquidityGauge.convertToShares/convertToAssets/previewDeposit/previewRedeem
Oracle pricePriceOracle.price()

LT.preview_withdraw(tokens) runs calc_withdraw_fixed_out against current Cryptoswap state — its output includes TRD and realised slippage. LT.pricePerShare() uses LEVAMM's value_oracle — oracle-priced, TRD-free.

Integrator notes

  • For withdrawal routing, prefer preview_withdraw — it is the realistic redemption. pricePerShare() is an upper bound.
  • TRD: 1 − preview_withdraw(1e18) / pricePerShare().
  • Preview functions are @view; _w variants (e.g. AMM.price_w) are mutating and update EMA state. Do not call mutating functions in quote paths.
  • LT.preview_deposit requires a debt parameter. Typical LT-call estimate: debt ≈ assets × oracle_price / 10**asset_decimals, denominated in crvUSD wei. Example: 1 asset with 18 decimals at a 100_000e18 oracle price uses about 100_000e18 crvUSD debt. The AMM's L = 2 target is debt ≈ LP collateral value / 2; the LT call adds the volatile leg plus the borrowed stable leg, so the borrowed leg is roughly the volatile leg's oracle value.

Routing metadata

  • Factory.markets(i) — returns the Market struct: {asset_token, cryptopool, amm, lt, price_oracle, virtual_pool, staker} (7 fields, in this order — Factory.vy:32). No agg field; resolve the crvUSD aggregator from Factory.agg() or LT.agg().
  • Factory.market_count() — upper bound for iteration.
  • Gauge lookup: read staker from the market struct, or call LT.staker() directly. GaugeController.gauges is a address[1_000_000_000] enumerated by index, not a mapping by LT address — do not call gauges(lt_address).

There is no Factory.get_market_info function; iterate over markets(i) directly.