/** * The CMS-authored figures and text a strategy's Details screen shows, read * the way kasu-ui's Details tab reads them, so every app shows the same * thing. * * Lifted from kasu-ui (`lib/details-fields.ts`, `lib/directus-text.ts` and * the parsers inside `deposit-dialog/details-tab.tsx`). The rules are facts * about how the CMS is authored, not presentation: * * - EMPTY IS UNAUTHORED. The CMS stores an emptied field as `''`, and its * "numeric" fields arrive as a number, a numeric string, `''` or `null`. * Anything that is not real data reads as `undefined` — never a `0`, a * placeholder or a sentence of the SDK's own. A field the caller cannot * read is a row the caller omits. * - A START DATE MUST DATE. A value that is not an ISO date, or a real * calendar date, or is before 2000 or in the future, is refused: rendered * as elapsed time it would claim a history nobody authored. * - SOME FIELDS CARRY TWO LINES IN ONE STRING. Business Types and Facility * Type are a primary value and a qualifying clause; risk-item * descriptions can be numbered enumerations. Splitting them is the same * everywhere, so it lives here. * * Like `pickShortDescription`, this authors no string of its own: it selects, * splits and trims text the CMS already holds. None of it is sanitised — * render every string as text, never as HTML or markdown. * * Pure. No clock: the date reader takes `now` from its caller. */ export interface CmsStartDateOptions { /** * Also accept a finite number as unix SECONDS. kasu-ui's duration * formatter reads a numeric value that way, and the originator's * `delegateLendingHistory` is typed as a number although the live CMS * serves an ISO date. Off by default: a strategy's `operatingSince` is a * date column, and kasu-ui refuses a number there. */ unixSeconds?: boolean; } /** * A CMS start date as its `YYYY-MM-DD` date head, or `undefined`. * * Accepts an ISO date, optionally with a time part (only the date head is * kept — a time changes nothing at year/month granularity, and converting it * through a timezone could move it a day). Refused, as `undefined`: * * - anything that is not a string (or, with `unixSeconds`, a number); * - an empty or blank string (unauthored); * - a string that is not ISO-shaped (`'Jun 2024'`); * - a date that does not exist (`'2024-02-30'`, `'2024-13-01'`) — never * rolled over into the next month; * - a year before 2000; * - a date after `now` (a typo such as 2062 for 2026 — no history has * begun in the future). * * `now` is the caller's clock; the facade passes the current time. */ export declare function readCmsStartDate(value: unknown, now: Date, options?: CmsStartDateOptions): string | undefined; /** A CMS value split into its primary line and an optional qualifying clause. */ export interface CmsTwoLineValue { /** The value itself — never empty. */ primary: string; /** The qualifying clause beneath it. Absent when none is authored. */ detail?: string; } /** * Business Types (the CMS `industryExposure`), split into the value and its * supporting clause on the FIRST newline, else the FIRST parenthesised * segment (a trailing `)` dropped): * * `'SMEs & Large Businesses (diversified industries – exclusions apply)'` * → `{ primary: 'SMEs & Large Businesses', detail: 'diversified industries – exclusions apply' }` * * A value with neither delimiter is `{ primary }` alone. `undefined` for a * missing, non-string, empty or blank value. * * REFINED over kasu-ui: a value that OPENS with `(` would split to an empty * primary there; here the whole value is the primary instead, so `primary` * is never empty. No live record has that shape. */ export declare function splitBusinessTypes(raw: unknown): CmsTwoLineValue | undefined; /** Facility Type: the authored label, its clause, and whether it revolves. */ export interface StrategyFacility { /** The facility's label (`'Revolving Instalment Facility'`) — never empty. */ label: string; /** The qualifying clause beneath it. Absent when none is authored. */ detail?: string; /** * The LABEL names a revolving facility (`'Revolving'`, `'Revolving * Instalment Facility'`), matched case-insensitively on a word starting * `revolv`. Never true for a negated label: `'Non-Revolving Term * Facility'` is false, because a hyphen before the word does not count as * a word boundary here. The clause is not read, so a clause that merely * mentions redraw does not make a facility revolve. * * kasu-ui hangs an explanatory ⓘ off a revolving label; that copy is the * app's own. */ revolving: boolean; } /** * Facility Type (the CMS `loanStructure`): the label on the FIRST line, and * everything after the first newline as its clause, so a clause with line * breaks of its own stays whole. * * `'Revolving Instalment Facility\n12-24 months instalment loan, subject to annual review'` * → `{ label: 'Revolving Instalment Facility', detail: '12-24 months …', revolving: true }` * * `undefined` for a missing, non-string, empty or blank value. The value is * trimmed first, so a leading blank line still yields a label. */ export declare function parseFacility(raw: unknown): StrategyFacility | undefined; /** * The order the Risk Management groups read in, by group name (compared * trimmed, case-insensitively). The CMS returns items in authoring order, * which is not this. A group not listed still appears — after these, in CMS * order. */ export declare const RISK_GROUP_ORDER: readonly string[]; /** * A risk-item description as the lines beneath the item's name. * * A numbered enumeration (`'1) Foo; and, 2) Bar'`, or one that omits its * leading `1)`: `'Foo; 2) Bar'`) is one line per clause; anything else is * one line. Zero-width characters are stripped first. An unauthored * description is NO lines (`[]`), never a dash. */ export declare function splitNumberedClauses(description: unknown): string[]; /** One risk-management item as the CMS row carries it. */ export interface RiskManagementItemSource { name?: unknown; group?: unknown; description?: unknown; tooltip?: unknown; } /** One item in a Risk Management group. */ export interface StrategyRiskItem { /** The item's name (`'Guarantee & Indemnity'`) — never empty. */ name: string; /** * The pool's own description of it — zero-width characters stripped, * trimmed. Present exactly when `clauses` is non-empty: a description * that yields no line (`''`, `'—'`, zero-width characters alone) is * absent. */ description?: string; /** `description` as the lines beneath the name; `[]` when unauthored. */ clauses: string[]; /** The CMS explanation of the item (shared by every pool). Absent when unauthored. */ tooltip?: string; } /** One Risk Management group and its items, in CMS order. */ export interface StrategyRiskGroup { /** The group's name as the CMS authors it (`'Security & Recourse'`). */ group: string; /** Never empty. */ items: StrategyRiskItem[]; } /** * Risk-management items grouped by their group, the groups in * `RISK_GROUP_ORDER` and, within a group, the items in CMS order. * * An item with no name, or no group, is left out: there is nothing to head * its lines with, or no group to place it in. (The CMS joins items to groups * by name, so neither occurs in live data.) No group is ever empty, so an * item list with nothing usable gives `[]`. */ export declare function groupRiskManagementItems(items: readonly RiskManagementItemSource[]): StrategyRiskGroup[]; /** * The pool's security tags (the CMS `security` list), trimmed, blanks * dropped. `undefined` when none remain. * * kasu-ui shows these under "Security Structure over End Borrowers" ONLY * when the pool has no risk-management items. */ export declare function securityStructureOf(raw: unknown): string[] | undefined; /** * A CMS or subgraph "numeric" value as a finite number, or `undefined`. An * empty or blank string is UNAUTHORED, not zero; a genuine `0` survives. */ export declare function finiteOrUndefined(value: unknown): number | undefined; /** One deployment's pool of a strategy, for `strategyTotalsUsd`. */ export interface StrategyTotalsLeg { /** * Which deployment this leg is — the same key the caller lists in * `expectedDeployments` (e.g. `StrategyDeployment.chain`: `'base'`, * `'xdc'`). Compared exactly. */ deployment: string; /** The pool's TVL (`Strategy.tvl.total`), in its own stable token. */ totalActiveLending: string | number; /** * The pool's lender interest earned * (`Strategy.strategyHistory.lenderInterestEarned`), in its own stable * token. */ lenderInterestEarned?: string | number; /** * USD per 1 unit of this deployment's stable token (`1` for USDC). * `undefined` while the rate is not known. */ usdRate: number | undefined; } /** A strategy's two money figures, summed over the legs given, in USD. */ export interface StrategyTotalsUsd { totalActiveLendingUsd: number; lenderInterestEarnedUsd: number; /** * `true` when some expected deployment has no leg — it failed to load, * or has not loaded yet — so both figures cover only `legs`, NOT the * whole strategy. A caller stating them as the strategy-wide figure must * say so (kasu-ui adds a partial-regions note) or fall back. */ isPartial: boolean; /** * The expected deployments with no leg, in `expectedDeployments` order. * Empty exactly when `isPartial` is `false`. */ missingDeployments: string[]; } export type StrategyTotalsInputErrorCode = 'duplicate-leg' | 'unexpected-leg'; /** * A leg `strategyTotalsUsd` cannot place: two legs for one deployment * (`duplicate-leg`, which would double-count it), or a leg for a deployment * not in `expectedDeployments` (`unexpected-leg`, a pool of some other * strategy). Thrown, because both are caller bugs, not data states. */ export declare class StrategyTotalsInputError extends Error { readonly code: StrategyTotalsInputErrorCode; readonly deployment: string; constructor(code: StrategyTotalsInputErrorCode, deployment: string); } /** * Total Active Lending and Lender Interest Earned for a strategy across the * deployments it lends on, in USD: each leg's native amount times that leg's * own `usdRate`, summed. Tax Pay lends on Base (USDC) and XDC (AUDD); * 2,567,901 AUDD is not US$2,567,901. * * `expectedDeployments` is every deployment the strategy has a pool on — * `strategyDeployments(poolId, chain).map((d) => d.chain)` — and `legs` the * ones whose pool the caller actually loaded. What is guaranteed: * * - **`null` — WITHHELD** when there are no legs, or ANY leg's rate is * missing or unusable (not a finite number above 0). The total is never * built on a guessed rate, and never silently drops a loaded leg; the * caller shows the held pool's own figure, or nothing. * - **Otherwise the sum over `legs`**, with `isPartial` / * `missingDeployments` stating exactly which expected deployments it * does NOT cover. `isPartial: false` is the only case in which the * figures are the whole strategy. * - An amount that is absent or malformed contributes nothing (a real `0` * is still `0`). * - Throws `StrategyTotalsInputError` for a duplicated leg or one not in * `expectedDeployments`, before summing anything. * * Only these two figures are summed. The CMS-authored ones — every * originator figure, `operatingSince`, the loss rates — are shared by a * strategy's pools and already strategy-wide: summing them double-counts. * * Mirrors the money half of kasu-ui's `aggregateStrategyPools` and its * withhold gate. */ export declare function strategyTotalsUsd(legs: readonly StrategyTotalsLeg[], expectedDeployments: readonly string[]): StrategyTotalsUsd | null;