-
+
+
+
+
Projected {paidTo} APY
@@ -117,11 +133,13 @@ function CurveCard({
}
/**
- * V3's target-share editor for the two static premium curves.
+ * V3's endpoint editor for the two static premium curves.
*
* The parent owns every value, bound, callback, and reset decision. This
- * component displays only the operating-target shares and accountant-derived
- * returns; it does not derive a curve anchor, cap, return, or accountant input.
+ * component displays the contract's configurable Y0 and Y100 endpoints plus
+ * accountant-derived returns. The configured YT kink stays in the parent and
+ * is still passed to the accountant; this component does not evaluate either
+ * curve or derive a return.
*/
function DayV3PremiumCurveEditor({
curveOverridden,
@@ -133,9 +151,11 @@ function DayV3PremiumCurveEditor({
liqY100Pct,
liqYtPct,
juniorModeledApy,
- onLiqYtPct,
+ onLiqY0Pct,
+ onLiqY100Pct,
onResetCurve,
- onRiskYtPct,
+ onRiskY0Pct,
+ onRiskY100Pct,
riskCapPct,
riskY0Pct,
riskY100Pct,
@@ -145,50 +165,74 @@ function DayV3PremiumCurveEditor({
targetUtilization,
}: DayV3PremiumCurveEditorProps) {
const [riskEditor, setRiskEditor] = useState({
- draft: riskYtPct,
- source: riskYtPct,
+ draft: { y0: riskY0Pct, yt: riskYtPct, y100: riskY100Pct },
+ source: { y0: riskY0Pct, yt: riskYtPct, y100: riskY100Pct },
});
const [liqEditor, setLiqEditor] = useState({
- draft: liqYtPct,
- source: liqYtPct,
+ draft: { y0: liqY0Pct, yt: liqYtPct, y100: liqY100Pct },
+ source: { y0: liqY0Pct, yt: liqYtPct, y100: liqY100Pct },
});
- const onRiskYtPctRef = useRef(onRiskYtPct);
- const onLiqYtPctRef = useRef(onLiqYtPct);
+ const onRiskY0PctRef = useRef(onRiskY0Pct);
+ const onRiskY100PctRef = useRef(onRiskY100Pct);
+ const onLiqY0PctRef = useRef(onLiqY0Pct);
+ const onLiqY100PctRef = useRef(onLiqY100Pct);
+ useEffect(() => {
+ onRiskY0PctRef.current = onRiskY0Pct;
+ }, [onRiskY0Pct]);
+ useEffect(() => {
+ onRiskY100PctRef.current = onRiskY100Pct;
+ }, [onRiskY100Pct]);
useEffect(() => {
- onRiskYtPctRef.current = onRiskYtPct;
- }, [onRiskYtPct]);
+ onLiqY0PctRef.current = onLiqY0Pct;
+ }, [onLiqY0Pct]);
useEffect(() => {
- onLiqYtPctRef.current = onLiqYtPct;
- }, [onLiqYtPct]);
+ onLiqY100PctRef.current = onLiqY100Pct;
+ }, [onLiqY100Pct]);
// Reset actions and linked URLs can replace the parent value. React's
// documented adjusted-state pattern keeps the local drag draft in sync
// without a second render caused by a setState-in-effect cycle.
- if (!Object.is(riskEditor.source, riskYtPct)) {
- setRiskEditor({ draft: riskYtPct, source: riskYtPct });
+ const riskSource = { y0: riskY0Pct, yt: riskYtPct, y100: riskY100Pct };
+ const liqSource = { y0: liqY0Pct, yt: liqYtPct, y100: liqY100Pct };
+ if (
+ !Object.is(riskEditor.source.y0, riskSource.y0) ||
+ !Object.is(riskEditor.source.yt, riskSource.yt) ||
+ !Object.is(riskEditor.source.y100, riskSource.y100)
+ ) {
+ setRiskEditor({ draft: riskSource, source: riskSource });
}
- if (!Object.is(liqEditor.source, liqYtPct)) {
- setLiqEditor({ draft: liqYtPct, source: liqYtPct });
+ if (
+ !Object.is(liqEditor.source.y0, liqSource.y0) ||
+ !Object.is(liqEditor.source.yt, liqSource.yt) ||
+ !Object.is(liqEditor.source.y100, liqSource.y100)
+ ) {
+ setLiqEditor({ draft: liqSource, source: liqSource });
}
- const riskDraftPct = riskEditor.draft;
- const liqDraftPct = liqEditor.draft;
+ const riskDraft = riskEditor.draft;
+ const liqDraft = liqEditor.draft;
useEffect(() => {
- if (!juniorEnabled || Object.is(riskDraftPct, riskYtPct)) return;
- const timeout = window.setTimeout(
- () => onRiskYtPctRef.current(riskDraftPct),
- 120,
- );
+ if (!juniorEnabled || Object.is(riskDraft.y0, riskY0Pct)) return;
+ const timeout = window.setTimeout(() => onRiskY0PctRef.current(riskDraft.y0), 120);
return () => window.clearTimeout(timeout);
- }, [juniorEnabled, riskDraftPct, riskYtPct]);
+ }, [juniorEnabled, riskDraft.y0, riskY0Pct]);
useEffect(() => {
- if (!slpEnabled || Object.is(liqDraftPct, liqYtPct)) return;
- const timeout = window.setTimeout(
- () => onLiqYtPctRef.current(liqDraftPct),
- 120,
- );
+ if (!juniorEnabled || Object.is(riskDraft.y100, riskY100Pct)) return;
+ const timeout = window.setTimeout(() => onRiskY100PctRef.current(riskDraft.y100), 120);
return () => window.clearTimeout(timeout);
- }, [liqDraftPct, liqYtPct, slpEnabled]);
+ }, [juniorEnabled, riskDraft.y100, riskY100Pct]);
+
+ useEffect(() => {
+ if (!slpEnabled || Object.is(liqDraft.y0, liqY0Pct)) return;
+ const timeout = window.setTimeout(() => onLiqY0PctRef.current(liqDraft.y0), 120);
+ return () => window.clearTimeout(timeout);
+ }, [liqDraft.y0, liqY0Pct, slpEnabled]);
+
+ useEffect(() => {
+ if (!slpEnabled || Object.is(liqDraft.y100, liqY100Pct)) return;
+ const timeout = window.setTimeout(() => onLiqY100PctRef.current(liqDraft.y100), 120);
+ return () => window.clearTimeout(timeout);
+ }, [liqDraft.y100, liqY100Pct, slpEnabled]);
if (!juniorEnabled && !slpEnabled) {
return null;
@@ -199,8 +243,12 @@ function DayV3PremiumCurveEditor({
...(slpEnabled ? ["SLP"] : []),
];
const activeCurveSummary = [
- ...(juniorEnabled ? [`Jr ${pct(riskDraftPct / 100)}`] : []),
- ...(slpEnabled ? [`SLP ${pct(liqDraftPct / 100)}`] : []),
+ ...(juniorEnabled
+ ? [`Jr ${pct(riskDraft.y0 / 100)} / ${pct(riskDraft.y100 / 100)}`]
+ : []),
+ ...(slpEnabled
+ ? [`SLP ${pct(liqDraft.y0 / 100)} / ${pct(liqDraft.y100 / 100)}`]
+ : []),
].join(" · ");
return (
- Adjust the share paid at the {pct(targetUtilization)} operating target.
- Each position's modeled APY updates beside it.
+ Set the yield-share endpoints at 0% and 100% utilization. The
+ contract's fixed {pct(targetUtilization)} kink remains configured in
+ the market, and each position's modeled APY updates beside the controls.
{validationIssues.length > 0 ? (
@@ -272,16 +321,24 @@ function DayV3PremiumCurveEditor({
capPct={riskCapPct}
description="Sets the share of Senior yield paid to Junior as first-loss coverage is used."
docs="coverage"
- onYtPct={(value) =>
- setRiskEditor((current) => ({ ...current, draft: value }))
+ onY0Pct={(value) =>
+ setRiskEditor((current) => ({
+ ...current,
+ draft: { ...current.draft, y0: value },
+ }))
+ }
+ onY100Pct={(value) =>
+ setRiskEditor((current) => ({
+ ...current,
+ draft: { ...current.draft, y100: value },
+ }))
}
paidTo="Jr"
modeledApy={juniorModeledApy}
- targetUtilization={targetUtilization}
- title="Junior yield share"
- y0Pct={riskY0Pct}
- y100Pct={riskY100Pct}
- ytPct={riskDraftPct}
+ title="Junior risk yield curve"
+ y0Pct={riskDraft.y0}
+ y100Pct={riskDraft.y100}
+ ytPct={riskDraft.yt}
/>
) : null}
{slpEnabled ? (
@@ -289,16 +346,24 @@ function DayV3PremiumCurveEditor({
capPct={liqCapPct}
description="Sets the share of Senior yield paid to SLP as exit liquidity is used."
docs="slpTranche"
- onYtPct={(value) =>
- setLiqEditor((current) => ({ ...current, draft: value }))
+ onY0Pct={(value) =>
+ setLiqEditor((current) => ({
+ ...current,
+ draft: { ...current.draft, y0: value },
+ }))
+ }
+ onY100Pct={(value) =>
+ setLiqEditor((current) => ({
+ ...current,
+ draft: { ...current.draft, y100: value },
+ }))
}
paidTo="SLP"
modeledApy={slpModeledApy}
- targetUtilization={targetUtilization}
- title="SLP yield share"
- y0Pct={liqY0Pct}
- y100Pct={liqY100Pct}
- ytPct={liqDraftPct}
+ title="SLP liquidity yield curve"
+ y0Pct={liqDraft.y0}
+ y100Pct={liqDraft.y100}
+ ytPct={liqDraft.yt}
/>
) : null}
diff --git a/components/day-v3/DayV3Summary.tsx b/components/day-v3/DayV3Summary.tsx
index 505cb9c..7fc80c4 100644
--- a/components/day-v3/DayV3Summary.tsx
+++ b/components/day-v3/DayV3Summary.tsx
@@ -61,6 +61,7 @@ import {
buildDayV3Query,
boundDayV3YieldShareAtTarget,
DAY_V3_STARTER_DEFAULTS,
+ dayV3MarketDefaults,
dayV3MinimumLiquidityForPoolFunding,
deriveDayV3StartingYieldCurvePolicy,
normalizeDayV3Defaults,
@@ -169,8 +170,9 @@ export default function DayV3Summary({
});
};
const clearStarterFields = () => setStarterFields(new Set());
- // Only operating-target yield shares remain active. Legacy hidden overrides
- // still parse, but cannot change a displayed result.
+ // Only the six contract YDM anchors remain active from the legacy override
+ // surface. Pool/deployment-only overrides stay parseable without changing a
+ // displayed result.
const activeManualOverrides = useMemo(
() => dayV3ActiveOverrides(manualOverrides),
[manualOverrides],
@@ -271,8 +273,9 @@ export default function DayV3Summary({
const [maintainCoverage, setMaintainCoverage] = useState(
initialMarket.defaults.maintainCoverage,
);
- // The merged simulator exposes only target yield shares. Legacy curve-shape
- // anchors stay inactive even when an old link contains them.
+ // The shared yield editor exposes Y0 and Y100 while retaining the configured
+ // YT kink used by each Day contract YDM. All three values flow into the
+ // accountant snapshot below; the UI never evaluates either curve itself.
const riskShareOverride = activeManualOverrides.jrYieldShareAtTargetPct;
const liqShareOverride = activeManualOverrides.slpYieldShareAtTargetPct;
const y0Override = activeManualOverrides.jrYieldShareAtZeroPct;
@@ -314,22 +317,42 @@ export default function DayV3Summary({
// Switching market adopts that market's own terms, so the sliders describe the
// market on screen rather than carrying the previous one's numbers over.
const adoptTerms = (next: DayMarket) => {
+ const marketDefaults = dayV3MarketDefaults(next.id);
setSourceApyPct(next.defaults.sourceApy * 100);
- setProtectedDrawdownPct(null);
- setRecoveryDaysInput(null);
- setRecoveryMode(null);
- setImmediateExitSharePct(null);
- setMinimumProceedsPer100(null);
+ setProtectedDrawdownPct(marketDefaults?.protectedDrawdownPct ?? null);
+ setRecoveryDaysInput(marketDefaults?.recoveryDays ?? null);
+ setRecoveryMode(
+ marketDefaults
+ ? marketDefaults.recoveryDays === 0
+ ? "none"
+ : "window"
+ : null,
+ );
+ setImmediateExitSharePct(marketDefaults?.immediateExitSharePct ?? null);
+ setMinimumProceedsPer100(marketDefaults?.minimumProceedsPer100 ?? null);
// The quote asset belongs to the exit design, not to the source, so it is
// cleared with the rest of the exit rather than carried across markets.
- setQuoteAssetLabel(DAY_V3_DEFAULT_QUOTE_ASSET);
- setQuoteAssetYieldPct(DAY_V3_DEFAULT_QUOTE_ASSET_YIELD_PCT);
- setPoolTurnoverPerYear(DAY_V3_DEFAULT_POOL_TURNOVER);
+ setQuoteAssetLabel(
+ marketDefaults?.quoteAssetLabel ?? DAY_V3_DEFAULT_QUOTE_ASSET,
+ );
+ setQuoteAssetYieldPct(
+ marketDefaults?.quoteAssetYieldPct ?? DAY_V3_DEFAULT_QUOTE_ASSET_YIELD_PCT,
+ );
+ setPoolTurnoverPerYear(
+ marketDefaults?.poolTurnoverPerYear ?? DAY_V3_DEFAULT_POOL_TURNOVER,
+ );
// A fee is a property of the pool being designed, so it is released with
// the rest of the exit rather than carried onto the next market.
- setSwapFeeBps(null);
+ setSwapFeeBps(marketDefaults?.swapFeeBps ?? null);
+ setMarketMakerCostOfCapitalPct(
+ marketDefaults?.marketMakerCostOfCapitalPct ?? 12,
+ );
+ setRedemptionDays(marketDefaults?.redemptionDays ?? 7);
setImportedMarket(null);
- setManualOverrides(EMPTY_DAY_V3_OVERRIDES);
+ setManualOverrides({
+ ...EMPTY_DAY_V3_OVERRIDES,
+ ...(marketDefaults?.overrides ?? {}),
+ });
// Adopted with the rest of the market's terms, for the same reason: the
// toggle must describe the market on screen, not the previous one.
setMaintainCoverage(next.defaults.maintainCoverage);
@@ -360,14 +383,21 @@ export default function DayV3Summary({
};
const resetYieldCurveOverrides = () => {
+ const marketDefaults = dayV3MarketDefaults(market.id);
setManualOverrides((current) => ({
...current,
- jrYieldShareAtZeroPct: null,
- jrYieldShareAtFullPct: null,
- slpYieldShareAtZeroPct: null,
- slpYieldShareAtFullPct: null,
- jrYieldShareAtTargetPct: null,
- slpYieldShareAtTargetPct: null,
+ jrYieldShareAtZeroPct:
+ marketDefaults?.overrides.jrYieldShareAtZeroPct ?? null,
+ jrYieldShareAtFullPct:
+ marketDefaults?.overrides.jrYieldShareAtFullPct ?? null,
+ slpYieldShareAtZeroPct:
+ marketDefaults?.overrides.slpYieldShareAtZeroPct ?? null,
+ slpYieldShareAtFullPct:
+ marketDefaults?.overrides.slpYieldShareAtFullPct ?? null,
+ jrYieldShareAtTargetPct:
+ marketDefaults?.overrides.jrYieldShareAtTargetPct ?? null,
+ slpYieldShareAtTargetPct:
+ marketDefaults?.overrides.slpYieldShareAtTargetPct ?? null,
}));
};
@@ -1275,6 +1305,23 @@ export default function DayV3Summary({
) => {
setManualOverrides((current) => ({
...current,
+ // Endpoint edits must travel as one complete six-anchor policy. Preserve
+ // any anchor already edited; otherwise materialize the accountant's
+ // currently resolved curve. This keeps URL reloads and the live model on
+ // the same valid contract configuration without deriving curve math here.
+ jrYieldShareAtZeroPct:
+ current.jrYieldShareAtZeroPct ?? resolved.y0 * 100,
+ jrYieldShareAtTargetPct:
+ current.jrYieldShareAtTargetPct ?? resolved.riskYieldShare * 100,
+ jrYieldShareAtFullPct:
+ current.jrYieldShareAtFullPct ?? resolved.y100 * 100,
+ slpYieldShareAtZeroPct:
+ current.slpYieldShareAtZeroPct ?? resolved.liqY0 * 100,
+ slpYieldShareAtTargetPct:
+ current.slpYieldShareAtTargetPct ??
+ resolved.liquidityYieldShare * 100,
+ slpYieldShareAtFullPct:
+ current.slpYieldShareAtFullPct ?? resolved.liqY100 * 100,
[field]: value,
}));
};
@@ -1575,12 +1622,18 @@ export default function DayV3Summary({
y0Pct: resolved.liqY0 * 100,
y100Pct: resolved.liqY100 * 100,
})}
- onLiqYtPct={(value) =>
- updateYieldCurveOverride("slpYieldShareAtTargetPct", value)
+ onLiqY0Pct={(value) =>
+ updateYieldCurveOverride("slpYieldShareAtZeroPct", value)
+ }
+ onLiqY100Pct={(value) =>
+ updateYieldCurveOverride("slpYieldShareAtFullPct", value)
}
onResetCurve={resetYieldCurveOverrides}
- onRiskYtPct={(value) =>
- updateYieldCurveOverride("jrYieldShareAtTargetPct", value)
+ onRiskY0Pct={(value) =>
+ updateYieldCurveOverride("jrYieldShareAtZeroPct", value)
+ }
+ onRiskY100Pct={(value) =>
+ updateYieldCurveOverride("jrYieldShareAtFullPct", value)
}
riskCapPct={resolved.riskCeiling * 100}
riskY0Pct={resolved.y0 * 100}
@@ -2387,6 +2440,9 @@ export default function DayV3Summary({
bandPct={inputs.bandPct}
coveragePct={inputs.coveragePct}
customSource={customSource}
+ windowOption={
+ dayV3MarketDefaults(market.id)?.backtestWindowOption
+ }
liqSharePct={resolved.liquidityYieldShare * 100}
liqY0Pct={resolved.liqY0 * 100}
liqY100Pct={resolved.liqY100 * 100}
diff --git a/components/day-v3/url-state.test.ts b/components/day-v3/url-state.test.ts
index 827f19c..9684b82 100644
--- a/components/day-v3/url-state.test.ts
+++ b/components/day-v3/url-state.test.ts
@@ -105,20 +105,33 @@ assert.equal(listedSource.applied, true);
assert.equal(listedSource.state.sourceApyPct, null);
assert.equal(
listedSource.state.protectedDrawdownPct,
- DAY_V3_STARTER_DEFAULTS.protectedDrawdownPct,
-);
-assert.equal(
- listedSource.state.recoveryDays,
- DAY_V3_STARTER_DEFAULTS.recoveryDays,
-);
-assert.equal(
- listedSource.state.immediateExitSharePct,
- DAY_V3_STARTER_DEFAULTS.immediateExitSharePct,
-);
-assert.equal(
- listedSource.state.minimumProceedsPer100,
- DAY_V3_STARTER_DEFAULTS.minimumProceedsPer100,
+ 15,
);
+assert.equal(listedSource.state.recoveryDays, 90);
+assert.equal(listedSource.state.immediateExitSharePct, 10);
+assert.equal(listedSource.state.minimumProceedsPer100, 95);
+assert.equal(listedSource.state.quoteAssetLabel, "sr-srRoyUSDC");
+assert.equal(listedSource.state.quoteAssetYieldPct, 4);
+assert.equal(listedSource.state.poolTurnoverPerYear, 2);
+assert.equal(listedSource.state.swapFeeBps, 5);
+assert.equal(listedSource.state.marketMakerCostOfCapitalPct, 12);
+assert.equal(listedSource.state.redemptionDays, 7);
+assert.deepEqual(listedSource.state.overrides, {
+ jrYieldShareAtZeroPct: 7.5,
+ jrYieldShareAtTargetPct: 19,
+ jrYieldShareAtFullPct: 45,
+ slpYieldShareAtZeroPct: 2,
+ slpYieldShareAtTargetPct: 2.9937,
+ slpYieldShareAtFullPct: 29.7937,
+ coveragePct: null,
+ minimumLiquidityPct: null,
+ maximumDiscountPct: null,
+ depthAtNav: null,
+ maximumPremiumPct: null,
+ protectedExitThresholdPct: null,
+ protectedExitBonusPct: null,
+ poolCapitalPer100: null,
+});
assert.equal(listedSource.state.entryPointSettlementDays, null);
assert.deepEqual(listedSource.state.target, DAY_V3_STARTER_DEFAULTS.target);
assert.deepEqual(listedSource.appliedFields, [
@@ -128,6 +141,41 @@ assert.deepEqual(listedSource.appliedFields, [
"payout",
"target",
]);
+const listedSourceQuery = buildDayV3Query({
+ ...listedSource.state,
+ starterFields: listedSource.appliedFields,
+});
+for (const expected of [
+ "m=jbbb",
+ "protect=15",
+ "recover=90",
+ "exit=10",
+ "receive=95",
+ "quote=sr-srRoyUSDC",
+ "quoteApy=4",
+ "turnover=2",
+ "fee=5",
+ "mmCost=12",
+ "mmDays=7",
+ "jr0=7.5",
+ "jr90=19",
+ "jr100=45",
+ "slp0=2",
+ "slp90=2.9937",
+ "slp100=29.7937",
+]) {
+ assert.equal(listedSourceQuery.includes(expected), true, expected);
+}
+
+const explicitJbbbTerms = applyDayV3StarterDefaults(
+ readDayV3UrlState("m=jbbb&recover=30&fee=7&jr90=18"),
+ "m=jbbb&recover=30&fee=7&jr90=18",
+);
+assert.equal(explicitJbbbTerms.state.recoveryDays, 30);
+assert.equal(explicitJbbbTerms.state.swapFeeBps, 7);
+assert.equal(explicitJbbbTerms.state.overrides.jrYieldShareAtTargetPct, 18);
+assert.equal(explicitJbbbTerms.state.overrides.jrYieldShareAtZeroPct, null);
+assert.equal(explicitJbbbTerms.state.overrides.slpYieldShareAtFullPct, null);
const query = buildDayV3Query({
market: "custom",
@@ -194,6 +242,8 @@ assert.deepEqual(
"convertCost",
"exit",
"fee",
+ "jr0",
+ "jr100",
"jr90",
"m",
"mmCost",
@@ -204,10 +254,12 @@ assert.deepEqual(
"receive",
"recover",
"settle",
+ "slp0",
+ "slp100",
"slp90",
"turnover",
],
- "the canonical writer strips hidden state while retaining visible target shares",
+ "the canonical writer strips hidden state while retaining all visible curve anchors",
);
for (const hidden of [
"mode",
@@ -228,10 +280,6 @@ for (const hidden of [
"pexit",
"bonus",
"pool",
- "jr0",
- "jr100",
- "slp0",
- "slp100",
"starter",
]) {
assert.equal(new URLSearchParams(query).has(hidden), false, hidden);
@@ -323,12 +371,16 @@ assert.deepEqual(overridden.overrides, {
slpYieldShareAtFullPct: 14,
});
const curveRoundTrip = buildDayV3Query(overridden);
-for (const field of ["jr90=12", "slp90=5"]) {
+for (const field of [
+ "jr0=2",
+ "jr90=12",
+ "jr100=18",
+ "slp0=1",
+ "slp90=5",
+ "slp100=14",
+]) {
assert.equal(curveRoundTrip.includes(field), true);
}
-for (const field of ["jr0=", "jr100=", "slp0=", "slp100="]) {
- assert.equal(curveRoundTrip.includes(field), false);
-}
const simpleYieldSplit = readDayV3UrlState("m=custom&apy=8&jr90=20&slp90=10");
assert.deepEqual(
{
diff --git a/lib/day-sample-sources/jbbb/v3-defaults.ts b/lib/day-sample-sources/jbbb/v3-defaults.ts
new file mode 100644
index 0000000..6396e05
--- /dev/null
+++ b/lib/day-sample-sources/jbbb/v3-defaults.ts
@@ -0,0 +1,43 @@
+import type { DayV3Overrides } from "@/lib/day-v3/types";
+
+/**
+ * Issuer-design defaults explicitly agreed for the JBBB simulation.
+ *
+ * These are inputs to the shared Day runtime, not independently calculated
+ * tranche outputs. JBBB's source APY continues to come from its total-return
+ * series rather than being duplicated here.
+ */
+export const JBBB_V3_DEFAULTS = {
+ protectedDrawdownPct: 15,
+ recoveryDays: 90,
+ immediateExitSharePct: 10,
+ minimumProceedsPer100: 95,
+ quoteAssetLabel: "sr-srRoyUSDC",
+ quoteAssetYieldPct: 4,
+ poolTurnoverPerYear: 2,
+ swapFeeBps: 5,
+ marketMakerCostOfCapitalPct: 12,
+ redemptionDays: 7,
+ backtestWindowOption: {
+ id: "2023-2024",
+ label: "2023–2024",
+ from: "2023-01-01",
+ to: "2024-12-31",
+ },
+ overrides: {
+ jrYieldShareAtZeroPct: 7.5,
+ jrYieldShareAtTargetPct: 19,
+ jrYieldShareAtFullPct: 45,
+ slpYieldShareAtZeroPct: 2,
+ slpYieldShareAtTargetPct: 2.9937,
+ slpYieldShareAtFullPct: 29.7937,
+ } satisfies Pick<
+ DayV3Overrides,
+ | "jrYieldShareAtZeroPct"
+ | "jrYieldShareAtTargetPct"
+ | "jrYieldShareAtFullPct"
+ | "slpYieldShareAtZeroPct"
+ | "slpYieldShareAtTargetPct"
+ | "slpYieldShareAtFullPct"
+ >,
+} as const;
diff --git a/lib/day-v3/index.ts b/lib/day-v3/index.ts
index 73a6d03..a78a37f 100644
--- a/lib/day-v3/index.ts
+++ b/lib/day-v3/index.ts
@@ -1,5 +1,6 @@
export * from "@/lib/day-v3/types";
export * from "@/lib/day-v3/url-state";
+export * from "@/lib/day-v3/market-defaults";
export * from "@/lib/day-v3/yield-curves";
export * from "@/lib/day-v3/normalization";
export * from "@/lib/day-v3/protection";
diff --git a/lib/day-v3/market-defaults.ts b/lib/day-v3/market-defaults.ts
new file mode 100644
index 0000000..8a4a1e8
--- /dev/null
+++ b/lib/day-v3/market-defaults.ts
@@ -0,0 +1,39 @@
+import { JBBB_V3_DEFAULTS } from "@/lib/day-sample-sources/jbbb/v3-defaults";
+import type { DayV3Overrides } from "@/lib/day-v3/types";
+
+type YieldCurveOverrides = Pick<
+ DayV3Overrides,
+ | "jrYieldShareAtZeroPct"
+ | "jrYieldShareAtTargetPct"
+ | "jrYieldShareAtFullPct"
+ | "slpYieldShareAtZeroPct"
+ | "slpYieldShareAtTargetPct"
+ | "slpYieldShareAtFullPct"
+>;
+
+export type DayV3MarketDefaults = {
+ protectedDrawdownPct: number;
+ recoveryDays: number;
+ immediateExitSharePct: number;
+ minimumProceedsPer100: number;
+ quoteAssetLabel: string;
+ quoteAssetYieldPct: number;
+ poolTurnoverPerYear: number;
+ swapFeeBps: number;
+ marketMakerCostOfCapitalPct: number;
+ redemptionDays: number;
+ backtestWindowOption: {
+ id: string;
+ label: string;
+ from: string;
+ to: string;
+ };
+ overrides: YieldCurveOverrides;
+};
+
+/** Market-specific issuer inputs. Unlisted markets retain shared starters. */
+export function dayV3MarketDefaults(
+ marketId: string | null | undefined,
+): DayV3MarketDefaults | null {
+ return marketId === "jbbb" ? JBBB_V3_DEFAULTS : null;
+}
diff --git a/lib/day-v3/mode-model.ts b/lib/day-v3/mode-model.ts
index 3caa13d..f33e9f1 100644
--- a/lib/day-v3/mode-model.ts
+++ b/lib/day-v3/mode-model.ts
@@ -18,17 +18,20 @@ export const EMPTY_DAY_V3_OVERRIDES: Readonly
= Object.freeze({
});
/**
- * The simulator exposes only the two yield shares paid at the operating
- * target. Legacy curve-shape and deployment overrides stay parseable so old
- * links do not break, but invisible fields must never change a displayed
- * result.
+ * The simulator exposes the contract's Y0, YT, and Y100 anchors for both Day
+ * YDMs. Deployment and pool overrides stay parseable so old links do not
+ * break, but invisible fields must never change a displayed result.
*/
export function dayV3ActiveOverrides(
overrides: DayV3Overrides,
): Readonly {
return {
...EMPTY_DAY_V3_OVERRIDES,
+ jrYieldShareAtZeroPct: overrides.jrYieldShareAtZeroPct,
jrYieldShareAtTargetPct: overrides.jrYieldShareAtTargetPct,
+ jrYieldShareAtFullPct: overrides.jrYieldShareAtFullPct,
+ slpYieldShareAtZeroPct: overrides.slpYieldShareAtZeroPct,
slpYieldShareAtTargetPct: overrides.slpYieldShareAtTargetPct,
+ slpYieldShareAtFullPct: overrides.slpYieldShareAtFullPct,
};
}
diff --git a/lib/day-v3/mode-state.test.ts b/lib/day-v3/mode-state.test.ts
index 6393e81..8acafb4 100644
--- a/lib/day-v3/mode-state.test.ts
+++ b/lib/day-v3/mode-state.test.ts
@@ -119,6 +119,8 @@ const expectedCanonicalKeys = [
"convertCost",
"exit",
"fee",
+ "jr0",
+ "jr100",
"jr90",
"m",
"mmCost",
@@ -129,6 +131,8 @@ const expectedCanonicalKeys = [
"receive",
"recover",
"settle",
+ "slp0",
+ "slp100",
"slp90",
"turnover",
];
@@ -170,10 +174,6 @@ for (const removedKey of [
"pexit",
"bonus",
"pool",
- "jr0",
- "jr100",
- "slp0",
- "slp100",
"starter",
]) {
assert.equal(
@@ -223,12 +223,16 @@ for (const field of [
);
}
-// The unified simulator exposes only the two operating-target yield shares.
-// Legacy endpoint and pool overrides may parse, but cannot affect any result.
+// The unified simulator exposes the six contract curve anchors. Pool and
+// deployment overrides may parse, but cannot affect any result.
const expectedActiveOverrides = {
...EMPTY_DAY_V3_OVERRIDES,
+ jrYieldShareAtZeroPct: 2,
jrYieldShareAtTargetPct: 12,
+ jrYieldShareAtFullPct: 18,
+ slpYieldShareAtZeroPct: 1,
slpYieldShareAtTargetPct: 5,
+ slpYieldShareAtFullPct: 14,
};
assert.deepEqual(
dayV3ActiveOverrides(canonicalState.overrides),
@@ -237,7 +241,7 @@ assert.deepEqual(
assert.deepEqual(
dayV3ActiveOverrides(legacyState.overrides),
expectedActiveOverrides,
- "legacy hidden overrides must never reactivate in the unified simulator",
+ "all six visible contract anchors must remain active after canonicalization",
);
// Every visible market-design input feeds one exact deployment-service request.
@@ -326,7 +330,7 @@ const editedState = readDayV3UrlState(
sourceApyPct: 7,
overrides: {
...canonicalState.overrides,
- jrYieldShareAtTargetPct: 20,
+ jrYieldShareAtTargetPct: 15,
slpYieldShareAtTargetPct: 10,
},
}),
@@ -339,7 +343,7 @@ assert.equal(editedState.minimumProceedsPer100, 95);
assert.equal(editedState.entryPointSettlementDays, 90);
assert.equal(editedState.collateralToExitDays, 0);
assert.equal(editedState.collateralToExitCostBps, 50);
-assert.equal(editedState.overrides.jrYieldShareAtTargetPct, 20);
+assert.equal(editedState.overrides.jrYieldShareAtTargetPct, 15);
assert.equal(editedState.overrides.slpYieldShareAtTargetPct, 10);
assert.equal(editedState.mode, null);
diff --git a/lib/day-v3/url-state.ts b/lib/day-v3/url-state.ts
index cd03c8f..f9caba7 100644
--- a/lib/day-v3/url-state.ts
+++ b/lib/day-v3/url-state.ts
@@ -4,6 +4,7 @@ import type {
DayV3GoalDraft,
DayV3Overrides,
} from "@/lib/day-v3/types";
+import { dayV3MarketDefaults } from "@/lib/day-v3/market-defaults";
import { validateDayV3YieldCurveDesign } from "@/lib/day-v3/yield-curves";
export type DayV3Mode = "simulate" | "deploy";
@@ -123,6 +124,7 @@ export function applyDayV3StarterDefaults(
} {
const params = new URLSearchParams(search);
const customSource = !params.has("m") || state.market === "custom";
+ const marketDefaults = dayV3MarketDefaults(state.market);
// Legacy links may carry a `starter` marker. Continue honoring it when links
// are read, even though the canonical writer no longer serializes UI-only
@@ -139,6 +141,19 @@ export function applyDayV3StarterDefaults(
if (!appliedFields.includes(field)) appliedFields.push(field);
return fallback;
};
+ const marketValueWhenAbsent = (
+ keys: string[],
+ current: T | null,
+ fallback: T | undefined,
+ ): T | null => {
+ if (keys.some((key) => params.has(key)) || fallback === undefined) {
+ return current;
+ }
+ return current ?? fallback;
+ };
+ const hasCurveParameter = ["jr0", "jr90", "jr100", "slp0", "slp90", "slp100"].some(
+ (key) => params.has(key),
+ );
const nextState: DayV3UrlState = {
...state,
@@ -153,29 +168,62 @@ export function applyDayV3StarterDefaults(
DAY_V3_STARTER_DEFAULTS.sourceApyPct,
)
: state.sourceApyPct,
+ quoteAssetLabel: marketValueWhenAbsent(
+ ["quote"],
+ state.quoteAssetLabel,
+ marketDefaults?.quoteAssetLabel,
+ ),
+ quoteAssetYieldPct: marketValueWhenAbsent(
+ ["quoteApy"],
+ state.quoteAssetYieldPct,
+ marketDefaults?.quoteAssetYieldPct,
+ ),
+ poolTurnoverPerYear: marketValueWhenAbsent(
+ ["turnover"],
+ state.poolTurnoverPerYear,
+ marketDefaults?.poolTurnoverPerYear,
+ ),
+ swapFeeBps: marketValueWhenAbsent(
+ ["fee"],
+ state.swapFeeBps,
+ marketDefaults?.swapFeeBps,
+ ),
+ marketMakerCostOfCapitalPct: marketValueWhenAbsent(
+ ["mmCost"],
+ state.marketMakerCostOfCapitalPct,
+ marketDefaults?.marketMakerCostOfCapitalPct,
+ ),
+ redemptionDays: marketValueWhenAbsent(
+ ["mmDays"],
+ state.redemptionDays,
+ marketDefaults?.redemptionDays,
+ ),
protectedDrawdownPct: whenAbsent(
"drawdown",
["protect"],
state.protectedDrawdownPct,
- DAY_V3_STARTER_DEFAULTS.protectedDrawdownPct,
+ marketDefaults?.protectedDrawdownPct ??
+ DAY_V3_STARTER_DEFAULTS.protectedDrawdownPct,
),
recoveryDays: whenAbsent(
"recovery",
["recover"],
state.recoveryDays,
- DAY_V3_STARTER_DEFAULTS.recoveryDays,
+ marketDefaults?.recoveryDays ?? DAY_V3_STARTER_DEFAULTS.recoveryDays,
),
immediateExitSharePct: whenAbsent(
"exit-amount",
["exit"],
state.immediateExitSharePct,
- DAY_V3_STARTER_DEFAULTS.immediateExitSharePct,
+ marketDefaults?.immediateExitSharePct ??
+ DAY_V3_STARTER_DEFAULTS.immediateExitSharePct,
),
minimumProceedsPer100: whenAbsent(
"payout",
["receive"],
state.minimumProceedsPer100,
- DAY_V3_STARTER_DEFAULTS.minimumProceedsPer100,
+ marketDefaults?.minimumProceedsPer100 ??
+ DAY_V3_STARTER_DEFAULTS.minimumProceedsPer100,
),
entryPointSettlementDays: customSource
? whenAbsent(
@@ -249,6 +297,10 @@ export function applyDayV3StarterDefaults(
state.target,
DAY_V3_STARTER_DEFAULTS.target,
),
+ overrides:
+ marketDefaults && !hasCurveParameter
+ ? { ...state.overrides, ...marketDefaults.overrides }
+ : state.overrides,
};
return {
applied: appliedFields.length > 0,
@@ -360,10 +412,10 @@ export function readDayV3UrlState(search: string): DayV3UrlState {
y100Pct: curveOverrides.slpYieldShareAtFullPct as number,
},
}).valid;
- // The unified editor may carry the two visible target shares alone; its
- // hidden endpoints are re-derived from the disclosed fixed basis. A legacy
- // six-anchor curve is accepted only when the full shape is valid. Every
- // other partial, inverted, or over-budget curve is rejected as a unit.
+ // Older links may carry only the two target shares. The six-anchor editor
+ // writes a complete curve, which is accepted only when its ordering and
+ // shared Senior-yield budget are valid. Every other partial, inverted, or
+ // over-budget curve is rejected as a unit.
const acceptedCurveOverrides =
!hasAnyCurveOverride ||
(!validCurveOverride && !hasTargetOnlyCurveOverride)
@@ -520,11 +572,32 @@ export function buildDayV3Query(state: DayV3UrlWriteState): string {
params.set("recover", "0");
}
- if (state.protectedDrawdownPct !== 0) {
+ const hasCurveShapeOverride = [
+ state.overrides.jrYieldShareAtZeroPct,
+ state.overrides.jrYieldShareAtFullPct,
+ state.overrides.slpYieldShareAtZeroPct,
+ state.overrides.slpYieldShareAtFullPct,
+ ].some((value) => value !== null);
+ const hasActiveYieldCurve =
+ state.protectedDrawdownPct !== 0 || state.immediateExitSharePct !== 0;
+ if (hasCurveShapeOverride && hasActiveYieldCurve) {
+ // A shaped curve is one atomic contract policy. Serialize all six anchors,
+ // including zeros for a disabled tranche, so the strict reader can reject
+ // malformed partial curves instead of silently modeling a different one.
+ setNumber("jr0", state.overrides.jrYieldShareAtZeroPct);
setNumber("jr90", state.overrides.jrYieldShareAtTargetPct);
- }
- if (state.immediateExitSharePct !== 0) {
+ setNumber("jr100", state.overrides.jrYieldShareAtFullPct);
+ setNumber("slp0", state.overrides.slpYieldShareAtZeroPct);
setNumber("slp90", state.overrides.slpYieldShareAtTargetPct);
+ setNumber("slp100", state.overrides.slpYieldShareAtFullPct);
+ } else {
+ // Preserve compact target-only links produced by older versions.
+ if (state.protectedDrawdownPct !== 0) {
+ setNumber("jr90", state.overrides.jrYieldShareAtTargetPct);
+ }
+ if (state.immediateExitSharePct !== 0) {
+ setNumber("slp90", state.overrides.slpYieldShareAtTargetPct);
+ }
}
return params.toString();
}
diff --git a/lib/day-v3/yield-curves.ts b/lib/day-v3/yield-curves.ts
index 25b9615..6ee4a95 100644
--- a/lib/day-v3/yield-curves.ts
+++ b/lib/day-v3/yield-curves.ts
@@ -53,13 +53,13 @@ const zeroCurve = (): DayV3YieldCurveAnchors => ({
const formatPct = (value: number) => `${value.toFixed(2)}%`;
/**
- * Bound the one issuer-editable curve point to the derived curve endpoints.
+ * Bound a target-only override from an older link to the derived endpoints.
*
- * V3 intentionally hides Y0 and Y100. Older links can still contain a YT that
- * predates those derived bounds, so the visible slider and the accountant must
- * agree on the same valid value instead of showing one number and modeling
- * another. This only constrains an input; curve evaluation remains in the
- * shared Day engine.
+ * The current editor writes all six anchors as one validated policy. Older
+ * links can still contain only YT, so the displayed slider and the accountant
+ * must agree on the same valid value instead of showing one number and
+ * modeling another. This only constrains an input; curve evaluation remains
+ * in the shared Day engine.
*/
export function boundDayV3YieldShareAtTarget({
targetPct,
diff --git a/scripts/day-v3/model-output-parity.test.mjs b/scripts/day-v3/model-output-parity.test.mjs
index ca188b9..8ce2618 100644
--- a/scripts/day-v3/model-output-parity.test.mjs
+++ b/scripts/day-v3/model-output-parity.test.mjs
@@ -125,18 +125,18 @@ assert.match(
);
assert.doesNotMatch(
`${summary}\n${editor}`,
- /presentation=|showCurveShapeAnchors|deployOnly|\bsimple\b|\bAdvanced\b|six YDM anchors|deployment handoff|suggestedCurve/,
- "The sole yield-split editor must not retain mode-specific or full-curve controls",
+ /presentation=|showCurveShapeAnchors|deployOnly|\bsimple\b|\bAdvanced\b|deployment handoff|suggestedCurve/,
+ "The sole yield-split editor must not retain mode-specific controls",
);
-assert.doesNotMatch(
+assert.match(
editor,
- /onRiskY0Pct|onRiskY100Pct|onLiqY0Pct|onLiqY100Pct|No coverage used \(Y0\)|Full coverage used \(Y100\)/,
- "The unified editor must expose only operating-target yield shares",
+ /onRiskY0Pct[\s\S]*onRiskY100Pct[\s\S]*onLiqY0Pct[\s\S]*onLiqY100Pct/,
+ "The unified editor must expose both contract curves' Y0 and Y100 anchors",
);
assert.match(
modeModel,
- /jrYieldShareAtTargetPct:\s*overrides\.jrYieldShareAtTargetPct[\s\S]*slpYieldShareAtTargetPct:\s*overrides\.slpYieldShareAtTargetPct/,
- "Only the two visible target yield shares may remain active",
+ /jrYieldShareAtZeroPct:\s*overrides\.jrYieldShareAtZeroPct[\s\S]*jrYieldShareAtTargetPct:\s*overrides\.jrYieldShareAtTargetPct[\s\S]*jrYieldShareAtFullPct:\s*overrides\.jrYieldShareAtFullPct[\s\S]*slpYieldShareAtZeroPct:\s*overrides\.slpYieldShareAtZeroPct[\s\S]*slpYieldShareAtTargetPct:\s*overrides\.slpYieldShareAtTargetPct[\s\S]*slpYieldShareAtFullPct:\s*overrides\.slpYieldShareAtFullPct/,
+ "All six visible contract yield anchors must remain active",
);
const protectionGroupStart = goals.indexOf(
@@ -326,16 +326,17 @@ for (const marker of [
assert.ok(backtest.includes(marker), `Historical model lost: ${marker}`);
}
-// Hidden legacy curve anchors remain derived and cannot affect the unified UI.
+// One reusable curve card renders the two configurable endpoints for each YDM;
+// the fixed YT contract kink remains routed through the parent accountant state.
assert.equal(
editor.match(/