Skip to main content
This is the field-by-field type reference for @inflexion/sdk. For the conceptual treatment of why reads never throw and writes never crash at construction, read Degradation envelopes first — this page is the dense lookup behind it. Two contracts run through every type: a read returns a typed degraded envelope you must narrow before touching the payload; a write either throws a clear error on call (LP/MM) or returns a WriteResult carrying the unsigned tx (Depositor). Every shape below is one of those two stories.
All types are exported from the SDK barrel — export * from './types.js', the quote helpers from ./quote.js, and the math port namespaced as cvamm. Import directly:

1. The five envelope types

Everything fallible the SDK returns is one of exactly five shapes. Three are read envelopes (Degraded<T>, Priceable<T>, ApiPending), one is a read precision flag (NonceStatus), and one is the write-result union (WriteResult).

1.1 Degraded<T>

The general-purpose read envelope for failures that are environmental (no RPC, an uninitialised vol oracle) rather than price-specific. Narrow on available.
boolean
required
Discriminant. true ⇒ the payload T is present and safe to read; false ⇒ only reason is present.
string
Present only on the available: false branch. In practice drawn from DegradeReason — typically 'no-rpc' or 'vol-uninitialized'.
Returned by depositor.getVaultState, getPosition, getRegime, and data.getSurfaceSigmaRef.

1.2 Priceable<T> / NotPriceable

Distinct from Degraded<T> because the dominant failure is the live price P0P_0 being unavailable. Every read that derives P0P_0 catches an OracleManager.getPrice revert (stale feed, sequencer down) and returns NotPriceable { reason: 'oracle-degraded' } rather than throwing.
boolean
required
Discriminant. true ⇒ payload T present; false ⇒ a NotPriceable.
DegradeReason
On the failure branch. The closed DegradeReason union — for Priceable typically 'oracle-degraded', 'market-unknown', or 'position-unknown'.
string
Optional human-readable elaboration on the failure (e.g. the underlying revert string).
Returned by lp.resolveGeometry, previewPremium, getPayoffCurve, the nested ilToDate inside getProtectionStatus, and hedge.greeks / suggestHedgeChecked.
Envelopes nest. getProtectionStatus returns ProtectionStatus | { available: false; reason }, and its ilToDate field is itself a Priceable<{ il; payout; capHit }>. A swap can be known while its mark-to-market IL is not priceable this block.

1.3 ApiPending

The most deliberate envelope in the SDK. Every DataClient history method returns it whenever its backing source is absent — for example if SUBGRAPH_URL is unset. Rather than fabricate a number, it returns the route and the exact query that would be sent — so the UI renders “coming from <route>” and the API is wired in with zero re-derivation. The subgraph is now deployed and indexing, so these history surfaces are served live through the hosted API; the envelope remains the typed degraded fallback when a backing is missing.
false
required
Always false. Returned when a surface’s backing source is absent (e.g. SUBGRAPH_URL unset).
'no-history-source'
required
Fixed literal — the DegradeReason for the no-history-source case.
string
required
The API route this call hits (e.g. '/data/load-surface'). Render it as the source.
unknown
required
The exact query object that would be sent — the caller’s args, normalised. The API can be wired with no re-derivation.
string
Optional note (e.g. “off-chain telemetry by design” for getDemandRequests).
Structures ship from day one; the full DYNAMICS (pool-vs-MM spread as a forward-vol signal) mature with multiple competing MMs and volume. The dataset begins at the single redeploy; the off-chain telemetry halves begin at the first interaction logged.What Inflexion offers today is the architecture and the first public view into the microstructure of the DeFi LP volatility-risk premium — not yet a mature dataset:
  • Structures are present day-one. All five non-circular behavioral signals are defined and queryable from launch.
  • Dynamics mature with volume. The richer signal — the pool-vs-MM spread read as a forward-vol indicator — only sharpens once multiple market makers compete and real flow accumulates.
  • The dataset begins at the single redeploy, and the off-chain telemetry halves begin at the first interaction logged. History is served live from the subgraph via the API; if a backing (subgraph URL / RPC / telemetry) is absent, surfaces degrade to a typed pending state — never an error.

1.4 NonceStatus

Not a pass/fail envelope — it always returns — but it carries a precision flag that degrades, and that distinction is load-bearing for MMs.
boolean
required
Whether the nonce bit is set on-chain via Core.isNonceUsed(mm, nonce).
'coarse' | 'precise'
required
'coarse' from the on-chain bitmap alone: the bit is set on both a fill and a cancel, and SwapCreated/SwapRouted carry no quoteId/nonce, so filled cannot be distinguished from cancelled on-chain alone. 'precise' from the now-deployed subgraph, which indexes the now-live QuoteFilled event.
string
required
Human-readable elaboration (e.g. 'nonce bit set (fill OR cancel)').
MM fill attribution is COARSE on-chain — structural, not a bug.
  • Limit. mm.isQuoteFilled(mm, nonce) returns precision: 'coarse'.
  • Why. The bitmap nonce is set on both fill and cancel; SwapCreated/SwapRouted carry no quoteId/nonce.
  • Mitigation. The precise path is the now-live QuoteFilled event (swapId, mm, quoteId, nonce, loadBps), emitted since the 2026-06-05 deploy and indexed by the now-deployed subgraph, queryable as precision: 'precise'. capacityRemaining also reads the exact on-chain consumedNotional (invariant I7) for the number that actually matters.

1.5 WriteResult

The DepositorClient write union. The factory always constructs, even with no signer — makeWalletClient returns undefined rather than crashing.
{ to: Hex; data: Hex; value: bigint }
required
The transaction calldata. On 'deferred-no-wallet' this is the unsigned tx for an external signer; on 'sent'/'error' it is the calldata that was submitted.
Hex
Present only when status === 'sent' — the broadcast transaction hash.
'sent' | 'deferred-no-wallet' | 'error'
required
'sent' — broadcast (txHash present). 'deferred-no-wallet' — no signer; calldata returned in tx for external signing. 'error' — an on-chain revert surfaced as a value, not a throw (e.g. the JuniorBelowLocked gate on withdraw).
string
On 'error', the revert reason / underlying message.
Per-surface write semantics differ by intent. Only DepositorClient returns WriteResult. LP/MM writes (lp.buyProtection, lp.settle, lp.poke, mm.cancelNonces) throw a clear error on the call when there is no wallet — there is no sensible “deferred” semantics for “buy this protection now”. See guardrails.

2. StagedWrite — multi-step deferred writes

depositor.rebalance(from, to, shares) returns a StagedWrite: step 1 (requestWithdrawal) is sent, while steps 2 (withdraw) and 3 (deposit) are returned unsent across the on-chain cooldown — the caller resubmits them once withdrawalCooldown elapses. The pattern keeps a cooldown-gated, multi-tx flow honest without the SDK holding state across the wait.

3. DegradeReason — the closed union

Every reason on a Priceable / Degraded / ApiPending failure is drawn from one closed union, so the UI can exhaustively switch on it:

4. Core domain types

The success-branch payloads carried inside the envelopes above. All dUSDC figures are 6-decimal raw bigints (1 dUSDC = 1_000_000n); all WAD ratios are 1e18; sqrtPriceX96 is Uniswap Q64.96. See decimals & units.

4.1 LpGeometry

The frozen geometry of a position-for-market — the unit the protocol prices. Returned inside Priceable<{ geometry: LpGeometry }> from lp.resolveGeometry.
bigint
Uniswap v3 position NFT id.
Hex
Position token0 address (from NPM.positions).
Hex
Position token1 address.
number
Pool fee tier (e.g. 500).
number
Lower tick of the range.
number
Upper tick of the range.
bigint
Position liquidity LL — read at creation and frozen on-chain (invariant I6: settlement never re-reads the NFT).
bigint
Lower-bound sqrt price (Q64.96), from tickLower.
bigint
Upper-bound sqrt price (Q64.96), from tickUpper.
bigint
Entry sqrt price (Q64.96), the oracle-derived P0P_0.
bigint
a=(Pa/P0)2a = (\sqrt{P_a}/\sqrt{P_0})^2 in WAD — the lower normalised price ratio.
bigint
b=(Pb/P0)2b = (\sqrt{P_b}/\sqrt{P_0})^2 in WAD — the upper normalised price ratio.
bigint
token0 amount implied at entry by LL and P0P_0 (ILMath.getAmountsForLiquidity).
bigint
token1 amount at entry.
bigint
MaxIL — the load-bearing payout cap and the unit of risk, pure geometry, dUSDC 6-dec (ILMath.computeMaxIL). See MaxIL.
boolean
sqrtP0 >= sqrtPa && sqrtP0 <= sqrtPb — the createSwap in-range gate. Out-of-range entries are rejected at creation.
aa and bb are the whole of the geometry the Φ-sum fair value needs. Because MaxIL is L-independent in the fair-rate sense, two positions sharing (a,b,duration)(a, b, \text{duration}) are fungible to an underwriter — which is why an MM quote is per-market, never per-NFT.

4.2 EligiblePosition

A row from lp.listEligiblePositions — one (position × duration) pair. Carries the LpGeometry (or the price-degraded state) plus the resolved marketId and a convenience inRange?: boolean that is undefined when the oracle is degraded.

4.3 PreviewResult

The priced quote returned inside Priceable<PreviewResult> from lp.previewPremium. All premiums are dUSDC 6-dec, capped at MaxIL.
Hex
The resolved market.
bigint
The cap — every premium is min(·, maxIL).
bigint
The on-chain Φ-sum fair premium from FairValueOracle.fairPremium — never reimplemented off-chain.
bigint
The fair rate (WAD) — fair premium per unit MaxIL.
bigint
The reference volatility σ_ref (WAD) the price was struck against.
bigint
Path-A pool premium: cvamm.premiumFromLoad(fairPremium, totalLoad) capped at MaxIL — exactly _pricePathAFromFair on-chain.
bigint
Path-B MM premium: cvamm.pathBPremium(fairPremium, loadBps, maxIL). Present only when a live signed MM quote beat the pool; absent if the engine is unreachable.
bigint
required
The cheaper of premiumA / premiumB — what the LP actually pays.
'A' | 'B'
required
Which rail produced best. Path B only when an MM quote won.
The math: premiumA=min⁡(⌈fairPremium⋅(1+totalLoad)⌉, MaxIL)\text{premiumA} = \min(\lceil \text{fairPremium} \cdot (1 + \text{totalLoad}) \rceil,\ \text{MaxIL}) and premiumB=min⁡(⌈fairPremium⋅(1+loadBps/10000)⌉, MaxIL)\text{premiumB} = \min(\lceil \text{fairPremium} \cdot (1 + \text{loadBps}/10000) \rceil,\ \text{MaxIL}) — same fair value, same cap, different load. See the pricing stack.

4.4 ProtectionStatus

Returned by lp.getProtectionStatus as ProtectionStatus | { available: false; reason }.
number
required
On-chain swap status: 0 UNINITIALIZED, 1 ACTIVE, 2 SETTLED.
boolean
required
mm == convexityVault — the swap was underwritten by the pool, not an MM.
Priceable<{ il; payout; capHit }>
required
Mark-to-market IL — itself a Priceable, so it can be not priceable while the swap is known. payout = min(il, maxIL); capHit = payout < il.
true
required
Carries Claim A — the qualified no-bad-debt guarantee — on the LP surface only.
LPs are always paid with no bad debt in FULL mode — qualified: capped payoff + solvent USDC + oracle/settlement liveness.The no-bad-debt guarantee is exact only under the full clause:
  • FULL collateralization — the underwriter has posted exactly MaxIL per swap, locked for the life of the position.
  • Capped payoff — the payout is min(realized_IL, MaxIL). The cap is load-bearing: it is what makes payout ≤ collateral hold by construction.
  • Solvent USDC — the collateral numeraire (dUSDC) holds its peg and remains redeemable.
  • Oracle / settlement liveness — the price oracle stays live and settle() runs within the protocol’s settlement window.
  • No rehypothecation breach — locked collateral stays instantly liquid; it is never routed to utilization-gated venues.
Stated without these qualifiers, the guarantee is not correct.

4.5 PayoffCurve

Returned inside Priceable<PayoffCurve> from lp.getPayoffCurve — ILMath.computeIL evaluated over a sqrt-price grid with the cap applied. Each point carries the price and the capped payout min(IL(P_T), MaxIL).

4.6 ClaimableFees

Returned by lp.getClaimableFees as ClaimableFees | { available: false }. Reads checkpointed tokensOwed0/1 from NPM.positions.
ClaimableFees UNDER-states.
  • Limit. The on-chain figure is only the last-checkpointed tokensOwed, not live accrual.
  • Why. Precise fee accounting needs indexed pool events.
  • Mitigation. The precise figure is served by the now-deployed subgraph; the on-chain value remains a conservative lower bound.

5. Depositor domain types

5.1 VaultState

Returned inside Degraded<VaultState> from depositor.getVaultState. Every success branch carries capitalNotGuaranteed: true.
bigint
Total pool assets, dUSDC 6-dec.
bigint
Senior-tranche assets.
bigint
Junior-tranche assets (first-loss buffer).
bigint
Collateral locked against active swaps. Invariant I5: locked ≤ deposited; junior-first waterfall keeps totalLocked ≤ juniorAssets.
bigint
Idle, instantly-liquid collateral.
bigint
Utilisation =locked/total= \text{locked}/\text{total} (WAD).
bigint
Concentration (HHI dispersion) of locked collateral (WAD).
bigint
Base load by σ_ref regime band (WAD).
bigint
Utilisation-skew load component (WAD).
bigint
Dispersion-skew load component (WAD).
bigint
baseLoad+utilSkew+dispSkew\text{baseLoad} + \text{utilSkew} + \text{dispSkew}, clamped to maxLoadBps (= invariant I10).
Record<Hex, bigint>
Colour map keyed by caller-supplied marketIds. Free collateral is pool-wide fungible, so this is HHI/concentration colour, not a per-market budget.
bigint
σ_ref EWMA (WAD).
Regime
The current volatility regime band.
bigint
Instantaneous yield (WAD). Subgraph-only ⇒ omitted from the on-chain read; served by the now-deployed subgraph via the API.
true
required
Carries Claim B on every depositor state read.
Depositor capital is NOT guaranteed: the junior tranche is first-loss; the senior tranche is structurally protected from underwriting loss only, not systemic tail.Underwriting capital — whether supplied to the pooled cvAMM vault (Path A) or posted directly by a market maker (Path B) — is at risk:
  • Junior tranche — first-loss. Junior depositors absorb underwriting losses first and buffer the senior tranche.
  • Senior tranche — protected from underwriting loss, exposed to the systemic tail. The senior tranche is structurally shielded from ordinary underwriting loss while junior capital buffers, but it still takes the systemic tail once the junior buffer is exhausted.
No-bad-debt is a guarantee to the LP being paid (see the FULL-mode payout clause), not a guarantee that depositor or MM capital is preserved.

5.2 DepositorPosition

Returned inside Degraded<DepositorPosition> from depositor.getPosition(owner). Carries seniorShares / juniorShares and their convertToAssets valuations (seniorAssets / juniorAssets), plus capitalNotGuaranteed: true.

5.3 LoadParams

The cached on-chain load-curve parameters, read from Core.loadParams by every surface. Carries the regime bands, the base-load-by-regime table, the utilisation-knee + convex-exponent curve, the dispersion cap, and maxLoadBps — the I10 ceiling every quote’s loadBps must respect. These are read on-chain, never hardcoded; the off-chain cvamm port consumes them to reproduce the load stack byte-equal.

5.4 Tranche / TRANCHE_ENUM

The string tranche selector and its on-chain enum mapping. Junior is first-loss; senior is protected from underwriting loss only (the junior-first waterfall) — never from the systemic tail. See tranches.

5.5 Regime

The volatility-regime enum derived from σ_ref against the LoadParams bands (cvamm.regimeOf). Selects the base-load band in the load stack.

6. MM domain types

6.1 MarketConfig

Returned by mm.getMarketConfig(marketId) as MarketConfig | undefined (undefined when token0 == address(0)). The immutable, post-freeze market parameters: token0, token1, fee, durationSeconds, oracle token. Cached because configs are immutable after freeze.

6.2 PricingGeometry (input) and MmMarketPricing (result)

PricingGeometry is the geometry input to mm.getMarketPricing:
bigint
required
Lower price ratio aa (WAD).
bigint
required
Upper price ratio bb (WAD).
bigint
required
Hedge tenor.
bigint
required
The cap / unit of risk, dUSDC 6-dec.
Hex
Optional override for the σ_ref token.
MmMarketPricing is the result: fairPremium, fairRateWad, sigmaRefWad, poolPremium (= ⌈fairPremium⋅(1+totalLoad)⌉\lceil \text{fairPremium}\cdot(1+\text{totalLoad})\rceil capped at MaxIL — the floor an MM must undercut), maxIL, load: LoadBreakdown, totalLoadBps, the per-component baseLoadWad / utilSkewWad / dispSkewWad, util, conc, and regime.

6.3 PoolLoadTick / LoadBreakdown

PoolLoadTick is the geometry-free “load to beat” from mm.getPoolLoadToBeat / streamPoolLoadToBeat: the pure pool floor an MM must undercut — totalLoadBps plus the baseLoad / util / disp decomposition — needing no position geometry, because the load percentage is geometry-independent. LoadBreakdown is that per-component decomposition. See why a quote is per-market.

6.4 Greeks

The finite-difference greeks from mm.greeksForSwap, hedge.greeks, and getBook({ withGreeks: true }). δ/γ finite-difference the deployed ILMath.computeIL of the capped payoff min⁡(IL(PT),MaxIL)\min(\text{IL}(P_T), \text{MaxIL}) (reported per unit price-ratio P/P0P/P_0, decimals-independent); vega/θ finite-difference the on-chain FairValueOracle.fairRate(a, b, σ, T) (vega per 1.0 vol, theta per year) — never a reimplemented Φ-sum. See greeks & hedging.

6.5 SigmaComponents

Returned by mm.getSigmaComponents(token) as SigmaComponents | undefined — the EWMA decomposition behind σ_ref from VolOracle.sigmaComponents.

6.6 Other MM result shapes

  • BookResult — mm.getBook(mm, opts?): the MM’s swap book from an on-chain nextSwapId/swaps scan, optionally with greeks.
  • SignQuoteResult — mm.signQuote(...): { envelope, belowPoolChecked, poolLoadBps?, i10Ok: true }.
  • MmQuoteError — thrown by signQuote; code ∈ { 'i10-exceeded', 'not-below-pool', 'pool-load-unreadable', 'no-signer', 'bad-nonce' }.
  • StreamHandle — the { stop() } returned by every polling stream (watchFills, quoteStream, streamPoolLoadToBeat).

7. The SignedQuote type — the EIP-712 shape

Re-exported via @inflexion/sdk and @inflexion/sdk/quote. The field order, types, and domain MUST match InflexionCore.SIGNED_QUOTE_TYPEHASH exactly or createSwap / createSwapRouted rejects the signature. See quote signing.
Hex (address)
required
The market maker EOA / contract that signed and posts collateral.
Hex (bytes32)
required
The market the quote prices. Per-market, never per-NFT — the quote carries no tokenId.
number (uint16)
required
The MM’s load over the on-chain fair premium. Must satisfy ≤ loadParams.maxLoadBps (I10) and (to win) be below the live pool load.
number (uint16)
required
Lower bound of the MaxIL-ratio band the MM will fill.
number (uint16)
required
Upper bound of the MaxIL-ratio band.
bigint (uint128)
required
The oracle price the MM signed against — the Fork-2 band anchor. createSwap reverts iff live PP deviates beyond priceBandBps (I9).
number (uint16)
required
The allowed deviation of live price from quotePrice at fill.
number (uint8)
required
CollateralModel: FULL = 0, PARTIAL = 1. FULL is the only supported mode in v1.
number (uint16)
required
PARTIAL-mode collateral ratio (unused while v1 is FULL-only).
bigint (uint128)
required
Capacity in numéraire (dUSDC 6-dec). On-chain consumedNotional[quoteId] ≤ maxNotionalV0 (I7).
bigint (uint64)
required
Absolute expiry timestamp; on-chain bound to now + [5,15]s.
Hex (bytes32)
required
The capacity-tracking id consumedNotional is keyed by.
bigint (uint256)
required
Bitmap nonce (word << 8) | bit, bit ∈ [0, 255]. Build with encodeNonce(word, bit).
TS field types are not uniform — get them right or signing fails. quotePrice, maxNotionalV0, validUntil, and nonce are bigint; loadBps and the other *Bps plus model are plain number (< 2^53, safe). On the wire (QuoteWire) bigints become decimal strings — convert back to bigint with decodeQuote before re-signing or verifying.

Supporting quote types & helpers


8. Worked example — narrowing every envelope


Where to go next

Degradation envelopes

The conceptual treatment — why reads never throw and writes fail clearly.

Guardrails

The write-safety model — build* calldata, deferred results, never-merge claims.

LP reference

Every LpClient method that produces LpGeometry, PreviewResult, ProtectionStatus.

Data reference

The live data surfaces and the five behavioral signals, with the ApiPending fallback.

Quote helpers

signQuote, quoteDigest, verifyQuote, and the SignedQuote ⇄ QuoteWire codec.

Decimals & units

Why every premium/collateral figure is a 6-dec raw bigint and ratios are WAD.