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 want | Call |
|---|---|
| Quote asset → crvUSD swap | VirtualPool.get_dy(1, 0, dx) |
| Quote crvUSD → asset swap | VirtualPool.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 state | LT.liquidity() returns (admin, total, ideal_staked, staked) |
| Emergency-path quote | LT.preview_emergency_withdraw(shares) |
| Gauge ERC-4626 (staker shares) | LiquidityGauge.convertToShares/convertToAssets/previewDeposit/previewRedeem |
| Oracle price | PriceOracle.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;_wvariants (e.g.AMM.price_w) are mutating and update EMA state. Do not call mutating functions in quote paths. LT.preview_depositrequires adebtparameter. Typical LT-call estimate:debt ≈ assets × oracle_price / 10**asset_decimals, denominated in crvUSD wei. Example: 1 asset with 18 decimals at a100_000e18oracle price uses about100_000e18crvUSD debt. The AMM'sL = 2target isdebt ≈ 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 theMarketstruct:{asset_token, cryptopool, amm, lt, price_oracle, virtual_pool, staker}(7 fields, in this order —Factory.vy:32). Noaggfield; resolve the crvUSD aggregator fromFactory.agg()orLT.agg().Factory.market_count()— upper bound for iteration.- Gauge lookup: read
stakerfrom the market struct, or callLT.staker()directly.GaugeController.gaugesis aaddress[1_000_000_000]enumerated by index, not a mapping by LT address — do not callgauges(lt_address).
There is no Factory.get_market_info function; iterate over markets(i) directly.