From 184e28cc57bf59069e7360aa4688aa117d23113d Mon Sep 17 00:00:00 2001 From: tavanam rama Date: Fri, 13 Nov 2026 12:12:19 +0530 Subject: [PATCH 1/6] Add in-browser previews that mirror the contract maths lib/sim.ts reproduces, in the same integer arithmetic, the settlement split, the credit contract's repayment accounting (principal and fee parts, the reserve's 10% of fees), draw terms, the period minimum, provisions, default losses and vault share pricing with the virtual offset. Offer estimates call the underwriter's own @runway/scoring, now a web dependency (the lockfile gains only the workspace link). lib/live.ts reads the gateway oracle's INR rate and the vault. test/sim.test.ts pins it to hand-worked values: 36.68 / 33.345454 / 3.334546 for a 400 USDC sale at 9.17%, a 10 USDC fee split 9.000002 to lenders and 0.999998 to the reserve, the live testnet deposit of 200 USDC minting 199.820179 shares at price 1.000899, and the offer decisions (grade C at 42.50 for three 400 windows, declines for too new, uneven and low revenue). --- apps/web/lib/live.ts | 30 +++++ apps/web/lib/sim.ts | 228 ++++++++++++++++++++++++++++++++++++++ apps/web/next.config.ts | 2 +- apps/web/package.json | 1 + apps/web/test/sim.test.ts | 131 ++++++++++++++++++++++ pnpm-lock.yaml | 3 + 6 files changed, 394 insertions(+), 1 deletion(-) create mode 100644 apps/web/lib/live.ts create mode 100644 apps/web/lib/sim.ts create mode 100644 apps/web/test/sim.test.ts diff --git a/apps/web/lib/live.ts b/apps/web/lib/live.ts new file mode 100644 index 0000000..39ad626 --- /dev/null +++ b/apps/web/lib/live.ts @@ -0,0 +1,30 @@ +"use client"; +// Live numbers for previews: the vault (chain), the INR rate (the gateway's oracle) and its limits. +import { useEffect, useState } from "react"; +import { credit, gateway } from "./chain"; +import { GATEWAY_URL } from "./env"; +import { useAsync } from "./useAsync"; + +/** Paise per USDC from the gateway's FX oracle; null while loading or if the backend is asleep. */ +export function useLiveRate(): { ratePpu: number | null; sources: string[] } { + const [r, setR] = useState<{ ratePpu: number | null; sources: string[] }>({ ratePpu: null, sources: [] }); + useEffect(() => { + let live = true; + fetch(`${GATEWAY_URL}/health`) + .then((res) => res.json() as Promise<{ oracle?: { rate_ppu?: number; sources?: string[] } }>) + .then((b) => { + if (live && b.oracle?.rate_ppu) setR({ ratePpu: b.oracle.rate_ppu, sources: b.oracle.sources ?? [] }); + }) + .catch(() => undefined); + return () => { + live = false; + }; + }, []); + return r; +} + +export const useVault = () => useAsync(() => credit.vault(), []); +export const useGatewayLimits = () => useAsync(() => gateway.limits(), []); + +/** A typical rate when the oracle can't be reached, clearly labelled as such where it is used. */ +export const FALLBACK_RATE_PPU = 10_000; diff --git a/apps/web/lib/sim.ts b/apps/web/lib/sim.ts new file mode 100644 index 0000000..275c10b --- /dev/null +++ b/apps/web/lib/sim.ts @@ -0,0 +1,228 @@ +// Previews of what the protocol will do, computed in the browser. Each function mirrors the +// contracts' integer maths exactly (settlement split, credit router/loans/vault, shared/fx) or calls +// the underwriter's own scoring package, so a preview matches the chain to the last micro-USDC. +// They only predict: the contracts and the underwriter agent decide. +import { + decide, + features, + scoringPolicy, + SCALE, + type Decision, + type Features, + type Grade, +} from "@runway/scoring"; +import { PROFILE } from "./env"; + +export const BPS = 10_000n; +/** contracts/shared consts.rs: protects the share price from donation and rounding attacks. */ +export const VIRTUAL_OFFSET = 1_000_000n; +const POLICY = PROFILE.policy; + +const min = (a: bigint, b: bigint) => (a < b ? a : b); +const ceilDiv = (a: bigint, b: bigint) => (a + b - 1n) / b; + +// ---------- payment split (contracts/settlement on_balance) ---------- + +/** repay = floor(inflow × repay_bps / 10,000); the merchant gets the rest. No loan → repay = 0. */ +export function splitPayment(inflow: bigint, repayBps: number | null | undefined) { + const repay = repayBps ? (inflow * BigInt(repayBps)) / BPS : 0n; + return { repay, merchant: inflow - repay }; +} + +// ---------- loans (contracts/credit loans.rs) ---------- + +/** accept_offer: drawing less than the limit scales the repay share down (never below the minimum). */ +export function drawTerms(offer: { limit: bigint; feeBps: number; repayBps: number }, amount: bigint) { + const scaled = Number(ceilDiv(BigInt(offer.repayBps) * amount, offer.limit)); + const repayBps = Math.max(scaled, POLICY.repayBpsMin); + const fee = (amount * BigInt(offer.feeBps)) / BPS; + return { repayBps, fee, owed: amount + fee }; +} + +/** The least that must be repaid in each loan period to avoid a missed period. */ +export const periodRequirement = (owed: bigint, remaining: bigint = owed) => + min((owed * BigInt(POLICY.minPeriodRepayBps)) / BPS, remaining); + +export interface LoanBook { + principal: bigint; + owed: bigint; + repaid: bigint; + principalRepaid: bigint; +} + +export interface RepayStep { + inflow: bigint; + /** the settlement account's repay part */ + repayPart: bigint; + /** what the loan actually took (never more than is still owed) */ + applied: bigint; + principalPart: bigint; + feePart: bigint; + toReserve: bigint; + toLenders: bigint; + toMerchant: bigint; + repaidAfter: bigint; + remainingAfter: bigint; + done: boolean; +} + +/** One settled payment against an open loan: settlement split, then credit apply_regular. */ +export function applyPayment( + loan: LoanBook, + inflow: bigint, + repayBps: number, +): { step: RepayStep; loan: LoanBook } { + const { repay } = splitPayment(inflow, repayBps); + const a = min(repay, loan.owed - loan.repaid); + const repaid = loan.repaid + a; + const principalRepaid = repaid === loan.owed ? loan.principal : (repaid * loan.principal) / loan.owed; + const principalPart = principalRepaid - loan.principalRepaid; + const feePart = a - principalPart; + const toReserve = (feePart * BigInt(POLICY.protocolFeeShareBps)) / BPS; + const next = { ...loan, repaid, principalRepaid }; + return { + loan: next, + step: { + inflow, + repayPart: repay, + applied: a, + principalPart, + feePart, + toReserve, + toLenders: a - toReserve, + toMerchant: inflow - a, + repaidAfter: repaid, + remainingAfter: loan.owed - repaid, + done: repaid === loan.owed, + }, + }; +} + +/** A whole loan: draw, then each payment in order until it is repaid. */ +export function simulateLoan(principal: bigint, feeBps: number, repayBps: number, payments: bigint[]) { + const fee = (principal * BigInt(feeBps)) / BPS; + let loan: LoanBook = { principal, owed: principal + fee, repaid: 0n, principalRepaid: 0n }; + const steps: RepayStep[] = []; + for (const p of payments) { + if (loan.repaid === loan.owed) { + steps.push({ + inflow: p, + repayPart: 0n, + applied: 0n, + principalPart: 0n, + feePart: 0n, + toReserve: 0n, + toLenders: 0n, + toMerchant: p, + repaidAfter: loan.repaid, + remainingAfter: 0n, + done: true, + }); + continue; + } + const r = applyPayment(loan, p, repayBps); + loan = r.loan; + steps.push(r.step); + } + return { fee, owed: principal + fee, steps, loan }; +} + +/** Unpaid principal × 50%: what a Delinquent loan sets aside (lowers the vault value meanwhile). */ +export const provisionFor = (principal: bigint, principalRepaid: bigint) => + ((principal - principalRepaid) * BigInt(POLICY.delinquencyProvisionBps)) / BPS; + +/** Default: the reserve covers the unpaid principal first; lenders lose only the rest. */ +export function defaultLoss(unpaidPrincipal: bigint, reserve: bigint) { + const fromReserve = min(reserve, unpaidPrincipal); + return { fromReserve, toLenders: unpaidPrincipal - fromReserve }; +} + +// ---------- vault (contracts/credit lib.rs, vault.rs) ---------- + +export const sharesForDeposit = (amount: bigint, totalShares: bigint, totalAssets: bigint) => + (amount * (totalShares + VIRTUAL_OFFSET)) / (totalAssets + VIRTUAL_OFFSET); + +export const assetsForShares = (shares: bigint, totalShares: bigint, totalAssets: bigint) => + (shares * (totalAssets + VIRTUAL_OFFSET)) / (totalShares + VIRTUAL_OFFSET); + +/** Share price × 1e6, as `get_vault.share_price_1e6` reports it. */ +export const sharePrice1e6 = (totalShares: bigint, totalAssets: bigint) => + assetsForShares(1_000_000n, totalShares, totalAssets); + +// ---------- underwriting (the agent's own @runway/scoring) ---------- + +const WEIGHTS = { stability: 35, history: 25, diversity: 15, trend: 15, corr: 10 }; +const clamp01 = (v: bigint) => (v < 0n ? 0n : v > SCALE ? SCALE : v); +const frac = (v: bigint) => Number(v) / Number(SCALE); + +export interface OfferEstimate { + features: Features; + /** points from each part of the score (they add up to the score) */ + parts: { stability: number; history: number; diversity: number; trend: number; corr: number }; + score: number; + decision: Decision; +} + +export const POLICY_FOR_SCORING = scoringPolicy({ + anchoredCaps: POLICY.anchoredCaps, + unanchoredCaps: POLICY.unanchoredCaps, + minLoan: POLICY.minLoan, + maxExposurePerMerchant: POLICY.maxExposurePerMerchant, + repayBpsMin: POLICY.repayBpsMin, + repayBpsMax: POLICY.repayBpsMax, +}); + +/** Completed revenue windows (oldest first, micro-USDC) → the offer the underwriter would compute. */ +export function estimateOffer( + windows: bigint[], + o: { repaid?: number; anchored?: boolean; statementMedian?: bigint; defaulted?: boolean } = {}, +): OfferEstimate { + const inputs = { + buckets: windows, + repaid: o.repaid ?? 0, + defaulted: o.defaulted ?? false, + frozen: false, + anchored: o.anchored ?? false, + statementMedian: o.statementMedian, + }; + const f = features(inputs); + const parts = { + stability: WEIGHTS.stability * frac(clamp01(SCALE - f.CV)), + history: (WEIGHTS.history * Math.min(inputs.repaid, 4)) / 4, + diversity: f.Ctop === null ? 0 : WEIGHTS.diversity * frac(clamp01(SCALE - f.Ctop)), + trend: WEIGHTS.trend * frac(clamp01(f.T - SCALE / 2n)), + corr: WEIGHTS.corr * frac(f.corr), + }; + return { + features: f, + parts, + score: parts.stability + parts.history + parts.diversity + parts.trend + parts.corr, + decision: decide(f, inputs, POLICY_FOR_SCORING), + }; +} + +export const GRADE_FEE_BPS: Record = { A: 400, B: 700, C: 1000 }; +export const MIN_ACTIVE_WINDOWS = POLICY_FOR_SCORING.minActiveBuckets; +export const MIN_MEDIAN_REVENUE = POLICY_FOR_SCORING.minRevenue; + +// ---------- revenue windows ---------- + +/** The 5-minute (testnet) window that `now` falls in, aligned to the clock like the contract's buckets. */ +export function windowClock(nowMs: number, bucketSec = PROFILE.bucketSec) { + const nowSec = Math.floor(nowMs / 1000); + const index = Math.floor(nowSec / bucketSec); + const endsAtSec = (index + 1) * bucketSec; + return { index, startsAtSec: index * bucketSec, endsAtSec, secondsLeft: endsAtSec - nowSec }; +} + +export const mmss = (sec: number) => { + const s = Math.max(0, Math.floor(sec)); + return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`; +}; + +/** "12.5" → micro-USDC, tolerant of commas; null when not a number. */ +export function microOf(text: string): bigint | null { + const m = /^(\d{1,12})(?:\.(\d{1,6}))?$/.exec(text.replace(/,/g, "").trim()); + if (!m) return null; + return BigInt(m[1]!) * 1_000_000n + BigInt((m[2] ?? "").padEnd(6, "0")); +} diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index de52714..4917e6c 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -3,7 +3,7 @@ import type { NextConfig } from "next"; const config: NextConfig = { reactStrictMode: true, // Workspace packages ship TypeScript sources with NodeNext-style ".js" import specifiers. - transpilePackages: ["@runway/sdk", "@runway/config", "@runway/fx"], + transpilePackages: ["@runway/sdk", "@runway/config", "@runway/fx", "@runway/scoring"], webpack: (cfg) => { cfg.resolve.extensionAlias = { ".js": [".ts", ".tsx", ".js"] }; return cfg; diff --git a/apps/web/package.json b/apps/web/package.json index e9ec93b..a5866ec 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -21,6 +21,7 @@ "@noble/hashes": "2.4.0", "@runway/config": "workspace:*", "@runway/fx": "workspace:*", + "@runway/scoring": "workspace:*", "@runway/sdk": "workspace:*", "@tanstack/react-query": "5.107.1", "near-api-js": "5.1.1", diff --git a/apps/web/test/sim.test.ts b/apps/web/test/sim.test.ts new file mode 100644 index 0000000..84f80c4 --- /dev/null +++ b/apps/web/test/sim.test.ts @@ -0,0 +1,131 @@ +// The previews must reproduce the contracts' integer maths and the underwriter's scoring exactly. +// Expected values are worked out by hand from contracts/credit (router.rs, loans.rs, lib.rs), +// contracts/settlement and @runway/scoring. +import { describe, expect, it } from "vitest"; +import { + applyPayment, + assetsForShares, + defaultLoss, + drawTerms, + estimateOffer, + microOf, + periodRequirement, + provisionFor, + sharePrice1e6, + sharesForDeposit, + simulateLoan, + splitPayment, + windowClock, +} from "../lib/sim"; + +const u = (n: number) => BigInt(Math.round(n * 1_000_000)); + +describe("payment split", () => { + it("takes floor(inflow × repay_bps / 10,000) while a loan is open", () => { + expect(splitPayment(u(400), 917)).toEqual({ repay: u(36.68), merchant: u(363.32) }); + expect(splitPayment(u(99.5), 917)).toEqual({ repay: 9_124_150n, merchant: 90_375_850n }); + }); + it("takes nothing without a loan", () => { + expect(splitPayment(u(400), null)).toEqual({ repay: 0n, merchant: u(400) }); + }); +}); + +describe("loan accounting (apply_regular)", () => { + it("splits each repayment into principal and fee, 10% of the fee to the reserve", () => { + const loan = { principal: u(100), owed: u(110), repaid: 0n, principalRepaid: 0n }; + const a = applyPayment(loan, u(400), 917); + expect(a.step).toMatchObject({ + applied: u(36.68), + principalPart: 33_345_454n, + feePart: 3_334_546n, + toReserve: 333_454n, + toMerchant: u(363.32), + remainingAfter: u(73.32), + done: false, + }); + const b = applyPayment(a.loan, u(99.5), 917); + expect(b.step).toMatchObject({ applied: 9_124_150n, principalPart: 8_294_682n, toReserve: 82_946n }); + const c = applyPayment(b.loan, u(1200), 917); + expect(c.step).toMatchObject({ + repayPart: u(110.04), + applied: 64_195_850n, + principalPart: 58_359_864n, + toReserve: 583_598n, + toMerchant: 1_135_804_150n, + done: true, + }); + // The whole fee of 10: 9.000002 to lenders, 0.999998 to the reserve. + const reserve = a.step.toReserve + b.step.toReserve + c.step.toReserve; + expect(reserve).toBe(999_998n); + const toCash = a.step.toLenders + b.step.toLenders + c.step.toLenders; + expect(toCash - u(100)).toBe(9_000_002n); + }); + + it("never takes more than is owed; later payments go to the merchant in full", () => { + const r = simulateLoan(u(100), 1000, 917, [u(1200), u(400)]); + expect(r.steps[0]).toMatchObject({ applied: u(110), toMerchant: u(1090), done: true }); + expect(r.steps[1]).toMatchObject({ applied: 0n, toMerchant: u(400) }); + }); + + it("scales the repay share when drawing less than the limit", () => { + expect(drawTerms({ limit: u(100), feeBps: 1000, repayBps: 917 }, u(100))).toEqual({ + repayBps: 917, + fee: u(10), + owed: u(110), + }); + expect(drawTerms({ limit: u(100), feeBps: 1000, repayBps: 917 }, u(60)).repayBps).toBe(551); + expect(drawTerms({ limit: u(100), feeBps: 1000, repayBps: 600 }, u(50)).repayBps).toBe(500); + }); + + it("requires 10% of the owed amount per period, provisions 50% when delinquent", () => { + expect(periodRequirement(u(110))).toBe(u(11)); + expect(periodRequirement(u(110), u(5))).toBe(u(5)); + expect(provisionFor(u(100), 0n)).toBe(u(50)); + expect(defaultLoss(u(100), u(30))).toEqual({ fromReserve: u(30), toLenders: u(70) }); + }); +}); + +describe("vault shares", () => { + it("mints and redeems at (assets + 1) / (shares + 1)", () => { + expect(sharesForDeposit(u(10_000), 0n, 0n)).toBe(u(10_000)); + expect(sharePrice1e6(u(10_000), 10_009_000_002n)).toBe(1_000_899n); + expect(assetsForShares(u(1_000), u(10_000), 10_009_000_002n)).toBe(1_000_899_910n); + // The live testnet deposit of 200 USDC at price 1.000899 minted 199.820179 shares. + expect(sharesForDeposit(u(200), u(10_000), 10_009_000_002n)).toBe(199_820_179n); + }); +}); + +describe("offer estimate (the underwriter's scoring)", () => { + it("three equal 400 USDC windows: grade C, limit 100, fee 10%, repay share 9.17%", () => { + const e = estimateOffer([u(400), u(400), u(400)]); + expect(e.score).toBeCloseTo(42.5, 5); + expect(e.decision).toMatchObject({ + kind: "offer", + grade: "C", + limit: u(100), + feeBps: 1000, + repayBps: 917, + }); + }); + it("declines a merchant with fewer than 3 windows", () => { + expect(estimateOffer([u(400), u(400)]).decision).toMatchObject({ kind: "decline", reason: "too_new" }); + }); + it("declines unsteady revenue (an empty window after the payments)", () => { + const e = estimateOffer([u(400), u(400), u(400), 0n]); + expect(e.decision).toMatchObject({ kind: "decline", reason: "low_score" }); + }); + it("declines a median below 300 USDC", () => { + expect(estimateOffer([u(100), u(100), u(100)]).decision).toMatchObject({ reason: "low_revenue" }); + }); +}); + +describe("helpers", () => { + it("aligns windows to the clock", () => { + const w = windowClock(Date.UTC(2026, 10, 13, 10, 7, 30), 300); + expect(w.secondsLeft).toBe(150); + }); + it("parses amounts", () => { + expect(microOf("1,200.5")).toBe(u(1200.5)); + expect(microOf("abc")).toBeNull(); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a145e60..87972e4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: '@runway/fx': specifier: workspace:* version: link:../../packages/fx + '@runway/scoring': + specifier: workspace:* + version: link:../../packages/scoring '@runway/sdk': specifier: workspace:* version: link:../../packages/sdk From 6b6bae29946878ba4d7d0ba5e358cd724cf022f0 Mon Sep 17 00:00:00 2001 From: tavanam rama Date: Fri, 13 Nov 2026 12:12:19 +0530 Subject: [PATCH 2/6] Restyle the web app in ink and sand A palette built on #274245 (ink) and #DFD6AE (sand): light sand surfaces with ink text, and ink bands with sand text for the header, hero and footer. Fraunces headings, Manrope body. The UI kit keeps its components and props and adds what explanations and previews need: page headers, card descriptions, info tips, "How this works" panels, callouts, step lists, preview boxes, progress bars, and error messages that translate contract codes into what to do next. A logo, an icon set, an animated money-flow diagram, scroll reveals and count-up numbers, all switched off under prefers-reduced-motion. The sticky header gets a mobile menu and highlights the current page; a footer links the guides and checks. Revenue windows are labelled by clock time, with the window in progress in sand. --- apps/web/app/globals.css | 273 ++++++++++++++++++----- apps/web/app/layout.tsx | 17 +- apps/web/components/Footer.tsx | 66 ++++++ apps/web/components/Nav.tsx | 84 +++++-- apps/web/components/RevenueChart.tsx | 50 +++-- apps/web/components/art.tsx | 199 +++++++++++++++++ apps/web/components/motion.tsx | 89 ++++++++ apps/web/components/ui.tsx | 319 ++++++++++++++++++++++++--- 8 files changed, 973 insertions(+), 124 deletions(-) create mode 100644 apps/web/components/Footer.tsx create mode 100644 apps/web/components/art.tsx create mode 100644 apps/web/components/motion.tsx diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css index dddf78b..c0fb6af 100644 --- a/apps/web/app/globals.css +++ b/apps/web/app/globals.css @@ -1,63 +1,29 @@ @import "tailwindcss"; +/* + * Runway palette: deep blue-green "ink" (#274245) and "sand" (yellow sapling, #DFD6AE). + * Light sand surfaces with ink text and ink/sand accents; ink bands (header, hero, footer) with sand text. + */ :root { color-scheme: light; - --c-bg: #f7f7f5; - --c-panel: #ffffff; - --c-fg: #161615; - --c-subtle: #5b5a56; - --c-line: #e2e1dc; - --c-muted: #efeeea; - --c-accent: #1f5fb0; - --c-accent-strong: #184c8d; - --c-good: #0f7a3d; - --c-bad: #b42318; - --c-warn: #a15c00; - /* chart roles (dataviz reference palette, validated) */ - --viz-surface: #fcfcfb; - --viz-series-1: #2a78d6; - --viz-grid: #e6e5e0; - --viz-axis: #52514e; -} - -@media (prefers-color-scheme: dark) { - :root:where(:not([data-theme="light"])) { - color-scheme: dark; - --c-bg: #121211; - --c-panel: #1a1a19; - --c-fg: #f0efec; - --c-subtle: #b3b2a8; - --c-line: #2e2e2b; - --c-muted: #242422; - --c-accent: #5b9cf0; - --c-accent-strong: #7cb1f4; - --c-good: #4cc27d; - --c-bad: #f07467; - --c-warn: #e7a33e; - --viz-surface: #1a1a19; - --viz-series-1: #3987e5; - --viz-grid: #2e2e2b; - --viz-axis: #c3c2b7; - } -} - -:root[data-theme="dark"] { - color-scheme: dark; - --c-bg: #121211; - --c-panel: #1a1a19; - --c-fg: #f0efec; - --c-subtle: #b3b2a8; - --c-line: #2e2e2b; - --c-muted: #242422; - --c-accent: #5b9cf0; - --c-accent-strong: #7cb1f4; - --c-good: #4cc27d; - --c-bad: #f07467; - --c-warn: #e7a33e; - --viz-surface: #1a1a19; - --viz-series-1: #3987e5; - --viz-grid: #2e2e2b; - --viz-axis: #c3c2b7; + --c-bg: #f8f5ea; + --c-panel: #fffdf7; + --c-fg: #172a2c; + --c-subtle: #55686a; + --c-line: #e4ddc1; + --c-muted: #f2edd9; + --c-accent: #274245; + --c-accent-strong: #1b3033; + --c-on-accent: #dfd6ae; + --c-good: #2d7a57; + --c-bad: #b3432f; + --c-warn: #a66a10; + /* chart roles */ + --viz-surface: #fffdf7; + --viz-series-1: #274245; + --viz-highlight: #b8a764; + --viz-grid: #ebe5cf; + --viz-axis: #55686a; } @theme inline { @@ -69,15 +35,208 @@ --color-muted: var(--c-muted); --color-accent: var(--c-accent); --color-accent-strong: var(--c-accent-strong); + --color-on-accent: var(--c-on-accent); --color-good: var(--c-good); --color-bad: var(--c-bad); --color-warn: var(--c-warn); - --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + --font-sans: var(--font-manrope), ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + --font-display: var(--font-fraunces), Georgia, "Times New Roman", serif; --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; } +@theme { + --color-ink-950: #0f1c1d; + --color-ink-900: #172a2c; + --color-ink-800: #1f3538; + --color-ink-700: #274245; + --color-ink-600: #34585c; + --color-ink-500: #4a777b; + --color-ink-400: #6f9a9d; + --color-ink-300: #9dbcbe; + --color-ink-200: #c9dbdc; + --color-ink-100: #e4eeee; + --color-ink-50: #f2f7f7; + --color-sand-50: #fbf9f0; + --color-sand-100: #f5f1de; + --color-sand-200: #ece5c6; + --color-sand-300: #dfd6ae; + --color-sand-400: #cdbf86; + --color-sand-500: #b8a764; + --color-sand-600: #978849; + --color-sand-700: #74683a; + --animate-fade-up: rw-fade-up 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; + --animate-float: rw-float 6s ease-in-out infinite; + --animate-pulse-soft: rw-pulse 2.4s ease-in-out infinite; +} + body { background: var(--c-bg); color: var(--c-fg); font-family: var(--font-sans); + -webkit-font-smoothing: antialiased; +} + +h1, +h2, +h3, +.font-display { + font-family: var(--font-display); + letter-spacing: -0.01em; +} + +::selection { + background: #dfd6ae; + color: #172a2c; +} + +:focus-visible { + outline: 2px solid #b8a764; + outline-offset: 2px; +} + +/* ---------- motion ---------- */ + +@keyframes rw-fade-up { + from { + opacity: 0; + transform: translateY(18px); + } + to { + opacity: 1; + transform: none; + } +} + +@keyframes rw-float { + 0%, + 100% { + transform: translateY(0); + } + 50% { + transform: translateY(-8px); + } +} + +@keyframes rw-pulse { + 0%, + 100% { + opacity: 1; + } + 50% { + opacity: 0.45; + } +} + +@keyframes rw-dash { + to { + stroke-dashoffset: -24; + } +} + +@keyframes rw-shimmer { + from { + background-position: 200% 0; + } + to { + background-position: -200% 0; + } +} + +@keyframes rw-grow { + from { + transform: scaleX(0); + } + to { + transform: scaleX(1); + } +} + +/* Revealed on scroll by (adds .is-visible). */ +.reveal { + opacity: 0; + transform: translateY(22px); + transition: + opacity 0.8s cubic-bezier(0.2, 0.7, 0.2, 1), + transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); + transition-delay: var(--reveal-delay, 0ms); +} +.reveal.is-visible { + opacity: 1; + transform: none; +} + +.flow-line { + stroke-dasharray: 6 6; + animation: rw-dash 1.1s linear infinite; +} + +.shimmer-text { + background: linear-gradient(90deg, #dfd6ae 0%, #fbf9f0 45%, #dfd6ae 60%, #b8a764 100%); + background-size: 200% 100%; + -webkit-background-clip: text; + background-clip: text; + color: transparent; + animation: rw-shimmer 8s linear infinite; +} + +.bar-grow { + transform-origin: left center; + animation: rw-grow 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; +} + +/* Subtle dotted texture for ink bands. */ +.ink-texture { + background-color: #274245; + background-image: + radial-gradient(circle at 20% 10%, rgba(223, 214, 174, 0.16), transparent 45%), + radial-gradient(circle at 85% 80%, rgba(111, 154, 157, 0.25), transparent 50%), + radial-gradient(rgba(223, 214, 174, 0.09) 1px, transparent 1px); + background-size: + auto, + auto, + 22px 22px; +} + +.card-lift { + transition: + transform 0.25s ease, + box-shadow 0.25s ease, + border-color 0.25s ease; +} +.card-lift:hover { + transform: translateY(-3px); + box-shadow: 0 14px 32px -18px rgba(23, 42, 44, 0.45); + border-color: #cdbf86; +} + +details > summary { + list-style: none; + cursor: pointer; +} +details > summary::-webkit-details-marker { + display: none; +} +details[open] .details-chevron { + transform: rotate(90deg); +} + +input[type="range"] { + accent-color: #274245; +} + +@media (prefers-reduced-motion: reduce) { + *, + ::before, + ::after { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } + .reveal { + opacity: 1; + transform: none; + } + .flow-dots { + display: none; + } } diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index 574042c..de3e28a 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -1,21 +1,28 @@ import type { Metadata } from "next"; +import { Fraunces, Manrope } from "next/font/google"; import type { ReactNode } from "react"; +import { Footer } from "../components/Footer"; import { Nav } from "../components/Nav"; import "./globals.css"; import { Providers } from "./providers"; +const sans = Manrope({ subsets: ["latin"], variable: "--font-manrope", display: "swap" }); +const display = Fraunces({ subsets: ["latin"], variable: "--font-fraunces", display: "swap" }); + export const metadata: Metadata = { - title: "Runway", - description: "Revenue-based credit for stablecoin and UPI merchants on NEAR (testnet).", + title: "Runway · credit that repays itself from sales", + description: + "Revenue-based working capital for merchants paid in stablecoins or UPI, funded by lenders, on NEAR (testnet).", }; export default function RootLayout({ children }: { children: ReactNode }) { return ( - - + +