@kasufinance/kasu-sdk 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -5
- package/dist/bundle.cjs.js +561 -11
- package/dist/bundle.esm.js +553 -12
- package/dist/domain/index.d.ts +6 -1
- package/dist/domain/index.js +6 -2
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/loan-contract.d.ts +16 -5
- package/dist/domain/loan-contract.js +16 -5
- package/dist/domain/loan-contract.js.map +1 -1
- package/dist/domain/pool-tvl.js +179 -0
- package/dist/domain/pool-tvl.js.map +1 -1
- package/dist/domain/requests.js +29 -19
- package/dist/domain/requests.js.map +1 -1
- package/dist/domain/strategy-details.d.ts +262 -0
- package/dist/domain/strategy-details.js +375 -0
- package/dist/domain/strategy-details.js.map +1 -0
- package/dist/facade/index.d.ts +1 -1
- package/dist/facade/index.js +2 -0
- package/dist/facade/index.js.map +1 -1
- package/dist/facade/strategies.d.ts +85 -3
- package/dist/facade/strategies.js +182 -6
- package/dist/facade/strategies.js.map +1 -1
- package/dist/facade/strategy-deployments.js +97 -0
- package/dist/facade/strategy-deployments.js.map +1 -0
- package/dist/facade/types.d.ts +82 -0
- package/dist/flows/deposit-flow.d.ts +19 -5
- package/dist/flows/deposit-flow.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/DataService/data-service.js +80 -9
- package/dist/services/DataService/data-service.js.map +1 -1
- package/dist/services/DataService/tvl-history.js +89 -0
- package/dist/services/DataService/tvl-history.js.map +1 -1
- package/dist/services/UserLending/queries.js +2 -7
- package/dist/services/UserLending/queries.js.map +1 -1
- package/dist/services/UserLending/subgraph-types.js.map +1 -1
- package/dist/services/UserLending/types.js.map +1 -1
- package/dist/services/UserLending/user-lending.js +72 -16
- package/dist/services/UserLending/user-lending.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/index.ts +27 -1
- package/src/domain/loan-contract.ts +16 -5
- package/src/domain/strategy-details.ts +528 -0
- package/src/facade/index.ts +3 -0
- package/src/facade/strategies.ts +205 -10
- package/src/facade/types.ts +85 -0
- package/src/flows/deposit-flow.ts +19 -5
package/dist/bundle.esm.js
CHANGED
|
@@ -27876,19 +27876,30 @@ function buildLoanAgreementSignMessage(p) {
|
|
|
27876
27876
|
].join('\n');
|
|
27877
27877
|
}
|
|
27878
27878
|
/**
|
|
27879
|
-
* The legacy `/contract/generate`
|
|
27879
|
+
* The legacy `/contract/generate` message.
|
|
27880
27880
|
*
|
|
27881
27881
|
* ⚠️ BYTE-EXACT PROTOCOL STRING. kasu-backend rebuilds it as
|
|
27882
27882
|
* `` `I request contract content for ${address} at ${timestamp}.` `` from the
|
|
27883
27883
|
* `address` and `timestamp` fields of the request body — so the string signed
|
|
27884
27884
|
* and the body sent must agree exactly, INCLUDING the address casing. This
|
|
27885
27885
|
* builder lowercases, and the request body must carry the same lowercased
|
|
27886
|
-
* address
|
|
27886
|
+
* address.
|
|
27887
27887
|
*
|
|
27888
27888
|
* The backend takes this path whenever the four human-readable display fields
|
|
27889
|
-
* are absent
|
|
27890
|
-
*
|
|
27891
|
-
* signs
|
|
27889
|
+
* are absent. Only the retired kasu-fe-next app (retired 2026-11-05) and
|
|
27890
|
+
* kasu-mobile builds from before 2026-09-06 signed it; every current consumer
|
|
27891
|
+
* signs `buildLoanAgreementSignMessage`. The backend keeps accepting it until
|
|
27892
|
+
* no such mobile build is left in use.
|
|
27893
|
+
*
|
|
27894
|
+
* It is NOT the `/contract/resolve` message. Resolve has a message of its own
|
|
27895
|
+
* (`Requesting contract content for {address}/{id} at {timestamp}.`), which
|
|
27896
|
+
* kasu-backend rebuilds and verifies, so it does not depend on this format.
|
|
27897
|
+
*
|
|
27898
|
+
* @deprecated Sign the human-readable loan-agreement message
|
|
27899
|
+
* (`buildLoanAgreementSignMessage`, `contractMessage.format:
|
|
27900
|
+
* 'loan-agreement'`) instead. Only the retired kasu-fe-next app and
|
|
27901
|
+
* pre-2026-09-06 kasu-mobile builds used this format; it will be removed in
|
|
27902
|
+
* the next major version.
|
|
27892
27903
|
*
|
|
27893
27904
|
* @param timestampMs ms-epoch, and the same value sent as the body's
|
|
27894
27905
|
* `timestamp`.
|
|
@@ -29307,6 +29318,381 @@ function maxNetRateCeiling(pools, feePercent) {
|
|
|
29307
29318
|
return rate;
|
|
29308
29319
|
}
|
|
29309
29320
|
|
|
29321
|
+
/**
|
|
29322
|
+
* The CMS-authored figures and text a strategy's Details screen shows, read
|
|
29323
|
+
* the way kasu-ui's Details tab reads them, so every app shows the same
|
|
29324
|
+
* thing.
|
|
29325
|
+
*
|
|
29326
|
+
* Lifted from kasu-ui (`lib/details-fields.ts`, `lib/directus-text.ts` and
|
|
29327
|
+
* the parsers inside `deposit-dialog/details-tab.tsx`). The rules are facts
|
|
29328
|
+
* about how the CMS is authored, not presentation:
|
|
29329
|
+
*
|
|
29330
|
+
* - EMPTY IS UNAUTHORED. The CMS stores an emptied field as `''`, and its
|
|
29331
|
+
* "numeric" fields arrive as a number, a numeric string, `''` or `null`.
|
|
29332
|
+
* Anything that is not real data reads as `undefined` — never a `0`, a
|
|
29333
|
+
* placeholder or a sentence of the SDK's own. A field the caller cannot
|
|
29334
|
+
* read is a row the caller omits.
|
|
29335
|
+
* - A START DATE MUST DATE. A value that is not an ISO date, or a real
|
|
29336
|
+
* calendar date, or is before 2000 or in the future, is refused: rendered
|
|
29337
|
+
* as elapsed time it would claim a history nobody authored.
|
|
29338
|
+
* - SOME FIELDS CARRY TWO LINES IN ONE STRING. Business Types and Facility
|
|
29339
|
+
* Type are a primary value and a qualifying clause; risk-item
|
|
29340
|
+
* descriptions can be numbered enumerations. Splitting them is the same
|
|
29341
|
+
* everywhere, so it lives here.
|
|
29342
|
+
*
|
|
29343
|
+
* Like `pickShortDescription`, this authors no string of its own: it selects,
|
|
29344
|
+
* splits and trims text the CMS already holds. None of it is sanitised —
|
|
29345
|
+
* render every string as text, never as HTML or markdown.
|
|
29346
|
+
*
|
|
29347
|
+
* Pure. No clock: the date reader takes `now` from its caller.
|
|
29348
|
+
*/
|
|
29349
|
+
// ---------------------------------------------------------------------------
|
|
29350
|
+
// Start dates
|
|
29351
|
+
// ---------------------------------------------------------------------------
|
|
29352
|
+
/**
|
|
29353
|
+
* `YYYY-MM-DD`, optionally followed by a time part — the two shapes a CMS
|
|
29354
|
+
* date column serialises to. Checked BEFORE any parse: `new Date('Jun 2024')`
|
|
29355
|
+
* is a valid date in V8, so an editorial string would otherwise become a
|
|
29356
|
+
* confident duration.
|
|
29357
|
+
*/
|
|
29358
|
+
const ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})(?:[T ].*)?$/;
|
|
29359
|
+
/** Nothing on Kasu has a lending history from before this year. */
|
|
29360
|
+
const EARLIEST_YEAR = 2000;
|
|
29361
|
+
/**
|
|
29362
|
+
* A CMS start date as its `YYYY-MM-DD` date head, or `undefined`.
|
|
29363
|
+
*
|
|
29364
|
+
* Accepts an ISO date, optionally with a time part (only the date head is
|
|
29365
|
+
* kept — a time changes nothing at year/month granularity, and converting it
|
|
29366
|
+
* through a timezone could move it a day). Refused, as `undefined`:
|
|
29367
|
+
*
|
|
29368
|
+
* - anything that is not a string (or, with `unixSeconds`, a number);
|
|
29369
|
+
* - an empty or blank string (unauthored);
|
|
29370
|
+
* - a string that is not ISO-shaped (`'Jun 2024'`);
|
|
29371
|
+
* - a date that does not exist (`'2024-02-30'`, `'2024-13-01'`) — never
|
|
29372
|
+
* rolled over into the next month;
|
|
29373
|
+
* - a year before 2000;
|
|
29374
|
+
* - a date after `now` (a typo such as 2062 for 2026 — no history has
|
|
29375
|
+
* begun in the future).
|
|
29376
|
+
*
|
|
29377
|
+
* `now` is the caller's clock; the facade passes the current time.
|
|
29378
|
+
*/
|
|
29379
|
+
function readCmsStartDate(value, now, options = {}) {
|
|
29380
|
+
let head;
|
|
29381
|
+
if (typeof value === 'number' && options.unixSeconds) {
|
|
29382
|
+
// `0` is formatDuration's "unset" sentinel; negatives are pre-1970.
|
|
29383
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
29384
|
+
return undefined;
|
|
29385
|
+
const date = new Date(value * 1000);
|
|
29386
|
+
if (Number.isNaN(date.getTime()))
|
|
29387
|
+
return undefined;
|
|
29388
|
+
head = date.toISOString().slice(0, 10);
|
|
29389
|
+
}
|
|
29390
|
+
else if (typeof value === 'string') {
|
|
29391
|
+
const trimmed = value.trim();
|
|
29392
|
+
if (!ISO_DATE.test(trimmed))
|
|
29393
|
+
return undefined;
|
|
29394
|
+
head = trimmed.slice(0, 10);
|
|
29395
|
+
}
|
|
29396
|
+
else {
|
|
29397
|
+
return undefined;
|
|
29398
|
+
}
|
|
29399
|
+
const match = ISO_DATE.exec(head);
|
|
29400
|
+
if (!match)
|
|
29401
|
+
return undefined;
|
|
29402
|
+
const year = Number(match[1]);
|
|
29403
|
+
const month = Number(match[2]);
|
|
29404
|
+
const day = Number(match[3]);
|
|
29405
|
+
// Round-trip through UTC: a day or month out of range comes back as a
|
|
29406
|
+
// different date, which is how a non-existent date is caught.
|
|
29407
|
+
const utc = new Date(Date.UTC(year, month - 1, day));
|
|
29408
|
+
if (utc.getUTCFullYear() !== year ||
|
|
29409
|
+
utc.getUTCMonth() !== month - 1 ||
|
|
29410
|
+
utc.getUTCDate() !== day) {
|
|
29411
|
+
return undefined;
|
|
29412
|
+
}
|
|
29413
|
+
if (year < EARLIEST_YEAR)
|
|
29414
|
+
return undefined;
|
|
29415
|
+
if (utc.getTime() > now.getTime())
|
|
29416
|
+
return undefined;
|
|
29417
|
+
return head;
|
|
29418
|
+
}
|
|
29419
|
+
/**
|
|
29420
|
+
* Business Types (the CMS `industryExposure`), split into the value and its
|
|
29421
|
+
* supporting clause on the FIRST newline, else the FIRST parenthesised
|
|
29422
|
+
* segment (a trailing `)` dropped):
|
|
29423
|
+
*
|
|
29424
|
+
* `'SMEs & Large Businesses (diversified industries – exclusions apply)'`
|
|
29425
|
+
* → `{ primary: 'SMEs & Large Businesses', detail: 'diversified industries – exclusions apply' }`
|
|
29426
|
+
*
|
|
29427
|
+
* A value with neither delimiter is `{ primary }` alone. `undefined` for a
|
|
29428
|
+
* missing, non-string, empty or blank value.
|
|
29429
|
+
*
|
|
29430
|
+
* REFINED over kasu-ui: a value that OPENS with `(` would split to an empty
|
|
29431
|
+
* primary there; here the whole value is the primary instead, so `primary`
|
|
29432
|
+
* is never empty. No live record has that shape.
|
|
29433
|
+
*/
|
|
29434
|
+
function splitBusinessTypes(raw) {
|
|
29435
|
+
const value = typeof raw === 'string' ? raw.trim() : '';
|
|
29436
|
+
if (!value)
|
|
29437
|
+
return undefined;
|
|
29438
|
+
let primary = value;
|
|
29439
|
+
let detail = '';
|
|
29440
|
+
const newlineAt = value.indexOf('\n');
|
|
29441
|
+
if (newlineAt !== -1) {
|
|
29442
|
+
primary = value.slice(0, newlineAt).trim();
|
|
29443
|
+
detail = value.slice(newlineAt + 1).trim();
|
|
29444
|
+
}
|
|
29445
|
+
else {
|
|
29446
|
+
const parenAt = value.indexOf('(');
|
|
29447
|
+
if (parenAt !== -1) {
|
|
29448
|
+
primary = value.slice(0, parenAt).trim();
|
|
29449
|
+
detail = value.slice(parenAt + 1).trim();
|
|
29450
|
+
if (detail.endsWith(')'))
|
|
29451
|
+
detail = detail.slice(0, -1).trim();
|
|
29452
|
+
}
|
|
29453
|
+
}
|
|
29454
|
+
if (!primary)
|
|
29455
|
+
return { primary: value };
|
|
29456
|
+
return detail ? { primary, detail } : { primary };
|
|
29457
|
+
}
|
|
29458
|
+
/**
|
|
29459
|
+
* The start of the label, or a character that is neither a word character
|
|
29460
|
+
* nor a hyphen, before `revolv` — not `\b`, which treats a hyphen as a
|
|
29461
|
+
* boundary, so "Non-Revolving" would match. kasu-ui writes the same rule as
|
|
29462
|
+
* the lookbehind `(?<![\w-])`; this form needs no lookbehind support from the
|
|
29463
|
+
* JavaScript engine.
|
|
29464
|
+
*/
|
|
29465
|
+
const REVOLVING_FACILITY = /(?:^|[^\w-])revolv\w*\b/i;
|
|
29466
|
+
/**
|
|
29467
|
+
* Facility Type (the CMS `loanStructure`): the label on the FIRST line, and
|
|
29468
|
+
* everything after the first newline as its clause, so a clause with line
|
|
29469
|
+
* breaks of its own stays whole.
|
|
29470
|
+
*
|
|
29471
|
+
* `'Revolving Instalment Facility\n12-24 months instalment loan, subject to annual review'`
|
|
29472
|
+
* → `{ label: 'Revolving Instalment Facility', detail: '12-24 months …', revolving: true }`
|
|
29473
|
+
*
|
|
29474
|
+
* `undefined` for a missing, non-string, empty or blank value. The value is
|
|
29475
|
+
* trimmed first, so a leading blank line still yields a label.
|
|
29476
|
+
*/
|
|
29477
|
+
function parseFacility(raw) {
|
|
29478
|
+
const value = typeof raw === 'string' ? raw.trim() : '';
|
|
29479
|
+
if (!value)
|
|
29480
|
+
return undefined;
|
|
29481
|
+
const breakAt = value.indexOf('\n');
|
|
29482
|
+
const label = (breakAt === -1 ? value : value.slice(0, breakAt)).trim();
|
|
29483
|
+
const detail = breakAt === -1 ? '' : value.slice(breakAt + 1).trim();
|
|
29484
|
+
const revolving = REVOLVING_FACILITY.test(label);
|
|
29485
|
+
return detail ? { label, detail, revolving } : { label, revolving };
|
|
29486
|
+
}
|
|
29487
|
+
// ---------------------------------------------------------------------------
|
|
29488
|
+
// Risk Management
|
|
29489
|
+
// ---------------------------------------------------------------------------
|
|
29490
|
+
/**
|
|
29491
|
+
* The order the Risk Management groups read in, by group name (compared
|
|
29492
|
+
* trimmed, case-insensitively). The CMS returns items in authoring order,
|
|
29493
|
+
* which is not this. A group not listed still appears — after these, in CMS
|
|
29494
|
+
* order.
|
|
29495
|
+
*/
|
|
29496
|
+
const RISK_GROUP_ORDER = Object.freeze([
|
|
29497
|
+
'Security & Recourse',
|
|
29498
|
+
'Structural Controls',
|
|
29499
|
+
'Financial Covenants',
|
|
29500
|
+
'Reporting Covenants',
|
|
29501
|
+
'Key Eligibility Criteria',
|
|
29502
|
+
]);
|
|
29503
|
+
/** Zero-width paste artifacts, which `\s` does not match. */
|
|
29504
|
+
const ZERO_WIDTH = /[-]/g;
|
|
29505
|
+
/** An `N)` marker at the start, or after a `;` / `; and,` separator. */
|
|
29506
|
+
const HAS_ENUMERATION = /(?:^\d+\)|;\s*(?:and,?\s*)?\d+\))/;
|
|
29507
|
+
const ENUMERATION_SPLIT = /(?:^|\s*;\s*(?:and,?\s*)?)\d+\)\s*/;
|
|
29508
|
+
/** kasu-ui's stub for an unauthored description; never a clause. */
|
|
29509
|
+
const EMPTY_DESCRIPTION = '—';
|
|
29510
|
+
/**
|
|
29511
|
+
* A risk-item description as the lines beneath the item's name.
|
|
29512
|
+
*
|
|
29513
|
+
* A numbered enumeration (`'1) Foo; and, 2) Bar'`, or one that omits its
|
|
29514
|
+
* leading `1)`: `'Foo; 2) Bar'`) is one line per clause; anything else is
|
|
29515
|
+
* one line. Zero-width characters are stripped first. An unauthored
|
|
29516
|
+
* description is NO lines (`[]`), never a dash.
|
|
29517
|
+
*/
|
|
29518
|
+
function splitNumberedClauses(description) {
|
|
29519
|
+
const raw = cleanDescription(description);
|
|
29520
|
+
if (!raw)
|
|
29521
|
+
return [];
|
|
29522
|
+
const clauses = HAS_ENUMERATION.test(raw)
|
|
29523
|
+
? raw
|
|
29524
|
+
.split(ENUMERATION_SPLIT)
|
|
29525
|
+
.map((part) => part.trim())
|
|
29526
|
+
.filter((part) => part.length > 0)
|
|
29527
|
+
: [raw];
|
|
29528
|
+
const lines = clauses.length > 0 ? clauses : [raw];
|
|
29529
|
+
return lines.filter((line) => line !== EMPTY_DESCRIPTION);
|
|
29530
|
+
}
|
|
29531
|
+
/** A description with zero-width characters stripped, trimmed; `''` when not a string. */
|
|
29532
|
+
function cleanDescription(description) {
|
|
29533
|
+
return typeof description === 'string'
|
|
29534
|
+
? description.replace(ZERO_WIDTH, '').trim()
|
|
29535
|
+
: '';
|
|
29536
|
+
}
|
|
29537
|
+
/**
|
|
29538
|
+
* Risk-management items grouped by their group, the groups in
|
|
29539
|
+
* `RISK_GROUP_ORDER` and, within a group, the items in CMS order.
|
|
29540
|
+
*
|
|
29541
|
+
* An item with no name, or no group, is left out: there is nothing to head
|
|
29542
|
+
* its lines with, or no group to place it in. (The CMS joins items to groups
|
|
29543
|
+
* by name, so neither occurs in live data.) No group is ever empty, so an
|
|
29544
|
+
* item list with nothing usable gives `[]`.
|
|
29545
|
+
*/
|
|
29546
|
+
function groupRiskManagementItems(items) {
|
|
29547
|
+
const groups = new Map();
|
|
29548
|
+
for (const source of items) {
|
|
29549
|
+
const name = trimmedOrUndefined(source.name);
|
|
29550
|
+
const group = trimmedOrUndefined(source.group);
|
|
29551
|
+
if (!name || !group)
|
|
29552
|
+
continue;
|
|
29553
|
+
const clauses = splitNumberedClauses(source.description);
|
|
29554
|
+
// The same cleaned text the clauses come from, and only when they
|
|
29555
|
+
// say something: a description of "—" or of zero-width characters
|
|
29556
|
+
// alone is unauthored, so it is absent here too, never a stray dash.
|
|
29557
|
+
const description = clauses.length > 0 ? cleanDescription(source.description) : '';
|
|
29558
|
+
const tooltip = trimmedOrUndefined(source.tooltip);
|
|
29559
|
+
const item = Object.assign(Object.assign(Object.assign({ name }, (description ? { description } : {})), { clauses }), (tooltip ? { tooltip } : {}));
|
|
29560
|
+
const existing = groups.get(group);
|
|
29561
|
+
if (existing)
|
|
29562
|
+
existing.items.push(item);
|
|
29563
|
+
else
|
|
29564
|
+
groups.set(group, { group, items: [item] });
|
|
29565
|
+
}
|
|
29566
|
+
// Array.prototype.sort is stable, so unlisted groups keep CMS order.
|
|
29567
|
+
return [...groups.values()].sort((a, b) => riskGroupRank(a.group) - riskGroupRank(b.group));
|
|
29568
|
+
}
|
|
29569
|
+
const RISK_GROUP_RANK = new Map(RISK_GROUP_ORDER.map((group, index) => [group.toLowerCase(), index]));
|
|
29570
|
+
function riskGroupRank(group) {
|
|
29571
|
+
var _a;
|
|
29572
|
+
return ((_a = RISK_GROUP_RANK.get(group.trim().toLowerCase())) !== null && _a !== void 0 ? _a : RISK_GROUP_ORDER.length);
|
|
29573
|
+
}
|
|
29574
|
+
/**
|
|
29575
|
+
* The pool's security tags (the CMS `security` list), trimmed, blanks
|
|
29576
|
+
* dropped. `undefined` when none remain.
|
|
29577
|
+
*
|
|
29578
|
+
* kasu-ui shows these under "Security Structure over End Borrowers" ONLY
|
|
29579
|
+
* when the pool has no risk-management items.
|
|
29580
|
+
*/
|
|
29581
|
+
function securityStructureOf(raw) {
|
|
29582
|
+
if (!Array.isArray(raw))
|
|
29583
|
+
return undefined;
|
|
29584
|
+
const tags = raw
|
|
29585
|
+
.map((tag) => trimmedOrUndefined(tag))
|
|
29586
|
+
.filter((tag) => tag !== undefined);
|
|
29587
|
+
return tags.length > 0 ? tags : undefined;
|
|
29588
|
+
}
|
|
29589
|
+
// ---------------------------------------------------------------------------
|
|
29590
|
+
// Numbers
|
|
29591
|
+
// ---------------------------------------------------------------------------
|
|
29592
|
+
/**
|
|
29593
|
+
* A CMS or subgraph "numeric" value as a finite number, or `undefined`. An
|
|
29594
|
+
* empty or blank string is UNAUTHORED, not zero; a genuine `0` survives.
|
|
29595
|
+
*/
|
|
29596
|
+
function finiteOrUndefined(value) {
|
|
29597
|
+
if (typeof value === 'number') {
|
|
29598
|
+
return Number.isFinite(value) ? value : undefined;
|
|
29599
|
+
}
|
|
29600
|
+
if (typeof value === 'string') {
|
|
29601
|
+
if (value.trim() === '')
|
|
29602
|
+
return undefined;
|
|
29603
|
+
const numeric = Number(value);
|
|
29604
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
29605
|
+
}
|
|
29606
|
+
return undefined;
|
|
29607
|
+
}
|
|
29608
|
+
/**
|
|
29609
|
+
* A leg `strategyTotalsUsd` cannot place: two legs for one deployment
|
|
29610
|
+
* (`duplicate-leg`, which would double-count it), or a leg for a deployment
|
|
29611
|
+
* not in `expectedDeployments` (`unexpected-leg`, a pool of some other
|
|
29612
|
+
* strategy). Thrown, because both are caller bugs, not data states.
|
|
29613
|
+
*/
|
|
29614
|
+
class StrategyTotalsInputError extends Error {
|
|
29615
|
+
constructor(code, deployment) {
|
|
29616
|
+
super(code === 'duplicate-leg'
|
|
29617
|
+
? `strategyTotalsUsd: two legs for deployment "${deployment}"`
|
|
29618
|
+
: `strategyTotalsUsd: leg for deployment "${deployment}" is not in expectedDeployments`);
|
|
29619
|
+
this.code = code;
|
|
29620
|
+
this.deployment = deployment;
|
|
29621
|
+
this.name = 'StrategyTotalsInputError';
|
|
29622
|
+
}
|
|
29623
|
+
}
|
|
29624
|
+
/**
|
|
29625
|
+
* Total Active Lending and Lender Interest Earned for a strategy across the
|
|
29626
|
+
* deployments it lends on, in USD: each leg's native amount times that leg's
|
|
29627
|
+
* own `usdRate`, summed. Tax Pay lends on Base (USDC) and XDC (AUDD);
|
|
29628
|
+
* 2,567,901 AUDD is not US$2,567,901.
|
|
29629
|
+
*
|
|
29630
|
+
* `expectedDeployments` is every deployment the strategy has a pool on —
|
|
29631
|
+
* `strategyDeployments(poolId, chain).map((d) => d.chain)` — and `legs` the
|
|
29632
|
+
* ones whose pool the caller actually loaded. What is guaranteed:
|
|
29633
|
+
*
|
|
29634
|
+
* - **`null` — WITHHELD** when there are no legs, or ANY leg's rate is
|
|
29635
|
+
* missing or unusable (not a finite number above 0). The total is never
|
|
29636
|
+
* built on a guessed rate, and never silently drops a loaded leg; the
|
|
29637
|
+
* caller shows the held pool's own figure, or nothing.
|
|
29638
|
+
* - **Otherwise the sum over `legs`**, with `isPartial` /
|
|
29639
|
+
* `missingDeployments` stating exactly which expected deployments it
|
|
29640
|
+
* does NOT cover. `isPartial: false` is the only case in which the
|
|
29641
|
+
* figures are the whole strategy.
|
|
29642
|
+
* - An amount that is absent or malformed contributes nothing (a real `0`
|
|
29643
|
+
* is still `0`).
|
|
29644
|
+
* - Throws `StrategyTotalsInputError` for a duplicated leg or one not in
|
|
29645
|
+
* `expectedDeployments`, before summing anything.
|
|
29646
|
+
*
|
|
29647
|
+
* Only these two figures are summed. The CMS-authored ones — every
|
|
29648
|
+
* originator figure, `operatingSince`, the loss rates — are shared by a
|
|
29649
|
+
* strategy's pools and already strategy-wide: summing them double-counts.
|
|
29650
|
+
*
|
|
29651
|
+
* Mirrors the money half of kasu-ui's `aggregateStrategyPools` and its
|
|
29652
|
+
* withhold gate.
|
|
29653
|
+
*/
|
|
29654
|
+
function strategyTotalsUsd(legs, expectedDeployments) {
|
|
29655
|
+
var _a, _b;
|
|
29656
|
+
const expected = new Set(expectedDeployments);
|
|
29657
|
+
const seen = new Set();
|
|
29658
|
+
for (const leg of legs) {
|
|
29659
|
+
if (seen.has(leg.deployment)) {
|
|
29660
|
+
throw new StrategyTotalsInputError('duplicate-leg', leg.deployment);
|
|
29661
|
+
}
|
|
29662
|
+
if (!expected.has(leg.deployment)) {
|
|
29663
|
+
throw new StrategyTotalsInputError('unexpected-leg', leg.deployment);
|
|
29664
|
+
}
|
|
29665
|
+
seen.add(leg.deployment);
|
|
29666
|
+
}
|
|
29667
|
+
if (legs.length === 0)
|
|
29668
|
+
return null;
|
|
29669
|
+
let totalActiveLendingUsd = 0;
|
|
29670
|
+
let lenderInterestEarnedUsd = 0;
|
|
29671
|
+
for (const leg of legs) {
|
|
29672
|
+
const rate = leg.usdRate;
|
|
29673
|
+
if (typeof rate !== 'number' || !Number.isFinite(rate) || rate <= 0) {
|
|
29674
|
+
return null;
|
|
29675
|
+
}
|
|
29676
|
+
totalActiveLendingUsd +=
|
|
29677
|
+
((_a = finiteOrUndefined(leg.totalActiveLending)) !== null && _a !== void 0 ? _a : 0) * rate;
|
|
29678
|
+
lenderInterestEarnedUsd +=
|
|
29679
|
+
((_b = finiteOrUndefined(leg.lenderInterestEarned)) !== null && _b !== void 0 ? _b : 0) * rate;
|
|
29680
|
+
}
|
|
29681
|
+
const missingDeployments = [...expected].filter((d) => !seen.has(d));
|
|
29682
|
+
return {
|
|
29683
|
+
totalActiveLendingUsd,
|
|
29684
|
+
lenderInterestEarnedUsd,
|
|
29685
|
+
isPartial: missingDeployments.length > 0,
|
|
29686
|
+
missingDeployments,
|
|
29687
|
+
};
|
|
29688
|
+
}
|
|
29689
|
+
function trimmedOrUndefined(value) {
|
|
29690
|
+
if (typeof value !== 'string')
|
|
29691
|
+
return undefined;
|
|
29692
|
+
const trimmed = value.trim();
|
|
29693
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
29694
|
+
}
|
|
29695
|
+
|
|
29310
29696
|
/**
|
|
29311
29697
|
* A strategy's SHORT blurb, as plain text: the CMS `liteDescription` first,
|
|
29312
29698
|
* else the first paragraph of the long `description`, else nothing.
|
|
@@ -29394,10 +29780,55 @@ class StrategiesFacade {
|
|
|
29394
29780
|
* Chain pool id → the pool id its CMS record is keyed by (XDC pools
|
|
29395
29781
|
* share their Base counterpart's editorial record). Lowercase keys.
|
|
29396
29782
|
*/
|
|
29397
|
-
_poolMetadataMapping = {}
|
|
29783
|
+
_poolMetadataMapping = {},
|
|
29784
|
+
/**
|
|
29785
|
+
* The clock the CMS start dates are checked against (a date after it
|
|
29786
|
+
* is refused). Injected for tests; the current time otherwise.
|
|
29787
|
+
*/
|
|
29788
|
+
_now = () => new Date(),
|
|
29789
|
+
/**
|
|
29790
|
+
* Milliseconds on a clock that only moves forward, for the shared
|
|
29791
|
+
* CMS reads' 30-second lifetime — separate from `_now`, so a pinned
|
|
29792
|
+
* date clock cannot keep a read alive for ever. Injected for tests;
|
|
29793
|
+
* `Date.now` otherwise.
|
|
29794
|
+
*/
|
|
29795
|
+
_memoClockMs = () => Date.now()) {
|
|
29398
29796
|
this._dataService = _dataService;
|
|
29399
29797
|
this._userLending = _userLending;
|
|
29400
29798
|
this._poolMetadataMapping = _poolMetadataMapping;
|
|
29799
|
+
this._now = _now;
|
|
29800
|
+
this._memoClockMs = _memoClockMs;
|
|
29801
|
+
/**
|
|
29802
|
+
* Short-lived, per-instance memo of the two CMS-wide reads the pool
|
|
29803
|
+
* getters share, so a Details screen asking for the loss rate, the risk
|
|
29804
|
+
* groups and the originator together reads each collection once. Keyed
|
|
29805
|
+
* by read; holds the in-flight promise, so concurrent callers share it.
|
|
29806
|
+
* A REJECTED read is dropped at once, never served again — the next call
|
|
29807
|
+
* retries.
|
|
29808
|
+
*/
|
|
29809
|
+
this._cmsReads = new Map();
|
|
29810
|
+
}
|
|
29811
|
+
_memoCmsRead(key, read) {
|
|
29812
|
+
const nowMs = this._memoClockMs();
|
|
29813
|
+
const cached = this._cmsReads.get(key);
|
|
29814
|
+
if (cached && cached.expiresAt > nowMs) {
|
|
29815
|
+
return cached.promise;
|
|
29816
|
+
}
|
|
29817
|
+
const promise = read();
|
|
29818
|
+
const entry = { promise, expiresAt: nowMs + CMS_READ_TTL_MS };
|
|
29819
|
+
this._cmsReads.set(key, entry);
|
|
29820
|
+
promise.catch(() => {
|
|
29821
|
+
// Only our own entry: a newer read may have replaced it.
|
|
29822
|
+
if (this._cmsReads.get(key) === entry)
|
|
29823
|
+
this._cmsReads.delete(key);
|
|
29824
|
+
});
|
|
29825
|
+
return promise;
|
|
29826
|
+
}
|
|
29827
|
+
_riskManagementRecords() {
|
|
29828
|
+
return this._memoCmsRead('riskManagement', () => this._dataService.getRiskManagement());
|
|
29829
|
+
}
|
|
29830
|
+
_originatorProfiles() {
|
|
29831
|
+
return this._memoCmsRead('originatorProfiles', () => this._dataService.getPoolDelegateProfileAndHistory());
|
|
29401
29832
|
}
|
|
29402
29833
|
/**
|
|
29403
29834
|
* The pool's loss rate and first-loss capital, from its CMS
|
|
@@ -29410,12 +29841,14 @@ class StrategiesFacade {
|
|
|
29410
29841
|
* 0..1 fraction.
|
|
29411
29842
|
*
|
|
29412
29843
|
* Requires `directusUrl`; without it the call rejects with
|
|
29413
|
-
* `NO_DIRECTUS_URL_MESSAGE`, like every CMS-only read.
|
|
29844
|
+
* `NO_DIRECTUS_URL_MESSAGE`, like every CMS-only read. Shares its CMS
|
|
29845
|
+
* read with `getRiskManagementGroups` for 30 seconds per instance; a
|
|
29846
|
+
* failed read is never reused.
|
|
29414
29847
|
*/
|
|
29415
29848
|
getRiskPerformance(poolId) {
|
|
29416
29849
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29417
29850
|
const metadataId = this._metadataIdOf(poolId);
|
|
29418
|
-
const records = yield this.
|
|
29851
|
+
const records = yield this._riskManagementRecords();
|
|
29419
29852
|
const record = records.find((r) => String(r.poolIdFK).toLowerCase() === metadataId);
|
|
29420
29853
|
if (!record)
|
|
29421
29854
|
return null;
|
|
@@ -29439,16 +29872,95 @@ class StrategiesFacade {
|
|
|
29439
29872
|
* deployment every profile lists no pools and this resolves `null` —
|
|
29440
29873
|
* the same answer kasu-ui's own lookup gives there today. The metadata
|
|
29441
29874
|
* candidate becomes live once the service resolves the mapping.
|
|
29875
|
+
*
|
|
29876
|
+
* Shares its reads with `getOriginatorHistory` for 30 seconds per
|
|
29877
|
+
* instance; a failed read is never reused. Each call returns its own
|
|
29878
|
+
* copy of the profile, so mutating it changes nothing shared.
|
|
29442
29879
|
*/
|
|
29443
29880
|
getOriginator(poolId) {
|
|
29444
29881
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29445
|
-
var _a;
|
|
29446
29882
|
const candidates = new Set([
|
|
29447
29883
|
poolId.toLowerCase(),
|
|
29448
29884
|
this._metadataIdOf(poolId),
|
|
29449
29885
|
]);
|
|
29450
|
-
const profiles = yield this.
|
|
29451
|
-
|
|
29886
|
+
const profiles = yield this._originatorProfiles();
|
|
29887
|
+
const profile = profiles.find((candidate) => candidate.otherKASUPools.some((pool) => candidates.has(String(pool.id).toLowerCase())));
|
|
29888
|
+
// A copy: the profiles are shared between calls (see
|
|
29889
|
+
// `_memoCmsRead`), so a caller sorting or editing its result must
|
|
29890
|
+
// not change what the next call returns.
|
|
29891
|
+
return profile
|
|
29892
|
+
? Object.assign(Object.assign({}, profile), { otherKASUPools: profile.otherKASUPools.map((pool) => (Object.assign({}, pool))) }) : null;
|
|
29893
|
+
});
|
|
29894
|
+
}
|
|
29895
|
+
/**
|
|
29896
|
+
* The credit originator's ENTIRE lending history for a pool — since when,
|
|
29897
|
+
* total originated, loans outstanding, loss rate — read from the profile
|
|
29898
|
+
* `getOriginator` finds, each figure validated. `null` when no profile
|
|
29899
|
+
* lists the pool, or the profile authors none of the four.
|
|
29900
|
+
*
|
|
29901
|
+
* kasu-ui's Details tab shows these as its Credit Originator strip, and
|
|
29902
|
+
* hides the strip when there is no profile. The money figures are
|
|
29903
|
+
* editorial USD on every deployment: never FX-convert them. An XDC pool
|
|
29904
|
+
* resolves `null` today, as it does in kasu-ui (see `getOriginator`).
|
|
29905
|
+
*
|
|
29906
|
+
* Requires `directusUrl`, like every CMS-only read; rejects when the
|
|
29907
|
+
* read fails. Shares its reads with `getOriginator` for 30 seconds per
|
|
29908
|
+
* instance; a failed read is never reused.
|
|
29909
|
+
*/
|
|
29910
|
+
getOriginatorHistory(poolId) {
|
|
29911
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29912
|
+
const profile = yield this.getOriginator(poolId);
|
|
29913
|
+
if (!profile)
|
|
29914
|
+
return null;
|
|
29915
|
+
const history = {};
|
|
29916
|
+
const since = readCmsStartDate(profile.delegateLendingHistory, this._now(), { unixSeconds: true });
|
|
29917
|
+
if (since !== undefined)
|
|
29918
|
+
history.since = since;
|
|
29919
|
+
const totalOriginated = finiteOrUndefined(profile.totalLoanFundsOriginated);
|
|
29920
|
+
if (totalOriginated !== undefined) {
|
|
29921
|
+
history.totalOriginated = totalOriginated;
|
|
29922
|
+
}
|
|
29923
|
+
const loansOutstanding = finiteOrUndefined(profile.loansUnderManagement);
|
|
29924
|
+
if (loansOutstanding !== undefined) {
|
|
29925
|
+
history.loansOutstanding = loansOutstanding;
|
|
29926
|
+
}
|
|
29927
|
+
const lossRate = finiteOrUndefined(profile.historicLossRate);
|
|
29928
|
+
if (lossRate !== undefined)
|
|
29929
|
+
history.lossRate = lossRate;
|
|
29930
|
+
return Object.keys(history).length > 0 ? history : null;
|
|
29931
|
+
});
|
|
29932
|
+
}
|
|
29933
|
+
/**
|
|
29934
|
+
* The pool's Risk Management groups, from its CMS risk-management record:
|
|
29935
|
+
* each group with its items (name, the pool's description of it split
|
|
29936
|
+
* into lines, the shared tooltip), the groups in `RISK_GROUP_ORDER`
|
|
29937
|
+
* (Security & Recourse, Structural Controls, Financial Covenants,
|
|
29938
|
+
* Reporting Covenants, Key Eligibility Criteria, then any other in CMS
|
|
29939
|
+
* order). See `groupRiskManagementItems`.
|
|
29940
|
+
*
|
|
29941
|
+
* `null` when the pool has no record, or the record has no usable item —
|
|
29942
|
+
* then kasu-ui falls back to `Strategy.securityStructure`. XDC pools
|
|
29943
|
+
* resolve through the metadata mapping to their Base record, like
|
|
29944
|
+
* `getRiskPerformance`.
|
|
29945
|
+
*
|
|
29946
|
+
* REJECTS when the CMS read fails (an outage, or no `directusUrl` —
|
|
29947
|
+
* `NO_DIRECTUS_URL_MESSAGE`), so a failure stays visible rather than
|
|
29948
|
+
* reading as "no items". For what to SHOW, treat a rejection like `null`:
|
|
29949
|
+
* fall back to `Strategy.securityStructure`, which arrives with the
|
|
29950
|
+
* strategy and needs no second read.
|
|
29951
|
+
*
|
|
29952
|
+
* Shares its CMS read with `getRiskPerformance` for 30 seconds per
|
|
29953
|
+
* instance; a failed read is never reused.
|
|
29954
|
+
*/
|
|
29955
|
+
getRiskManagementGroups(poolId) {
|
|
29956
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29957
|
+
const metadataId = this._metadataIdOf(poolId);
|
|
29958
|
+
const records = yield this._riskManagementRecords();
|
|
29959
|
+
const record = records.find((r) => String(r.poolIdFK).toLowerCase() === metadataId);
|
|
29960
|
+
if (!record || !Array.isArray(record.items))
|
|
29961
|
+
return null;
|
|
29962
|
+
const groups = groupRiskManagementItems(record.items);
|
|
29963
|
+
return groups.length > 0 ? groups : null;
|
|
29452
29964
|
});
|
|
29453
29965
|
}
|
|
29454
29966
|
_metadataIdOf(poolId) {
|
|
@@ -29622,10 +30134,39 @@ class StrategiesFacade {
|
|
|
29622
30134
|
apyStructure: pool.poolApyStructure,
|
|
29623
30135
|
thumbnailUrl: pool.thumbnailImageUrl,
|
|
29624
30136
|
bannerUrl: pool.bannerImageUrl,
|
|
30137
|
+
strategyHistory: strategyHistoryOf(pool, this._now()),
|
|
30138
|
+
endBorrowers: endBorrowersOf(pool),
|
|
30139
|
+
securityStructure: securityStructureOf(pool.security),
|
|
29625
30140
|
_raw: pool,
|
|
29626
30141
|
};
|
|
29627
30142
|
}
|
|
29628
30143
|
}
|
|
30144
|
+
/**
|
|
30145
|
+
* How long a CMS-wide read is shared between the pool getters. Long enough
|
|
30146
|
+
* for one screen's worth of calls, short enough that a CMS edit shows on the
|
|
30147
|
+
* next visit; apps cache further on their own terms.
|
|
30148
|
+
*/
|
|
30149
|
+
const CMS_READ_TTL_MS = 30000;
|
|
30150
|
+
/** `Strategy.strategyHistory`: an absent figure is an absent key. */
|
|
30151
|
+
function strategyHistoryOf(pool, now) {
|
|
30152
|
+
const history = {};
|
|
30153
|
+
const since = readCmsStartDate(pool.operatingSince, now);
|
|
30154
|
+
if (since !== undefined)
|
|
30155
|
+
history.since = since;
|
|
30156
|
+
const lenderInterestEarned = finiteOrUndefined(pool.yieldEarned);
|
|
30157
|
+
if (lenderInterestEarned !== undefined) {
|
|
30158
|
+
history.lenderInterestEarned = lenderInterestEarned;
|
|
30159
|
+
}
|
|
30160
|
+
return history;
|
|
30161
|
+
}
|
|
30162
|
+
/** Business Types and Facility Type, or `undefined` when neither is authored. */
|
|
30163
|
+
function endBorrowersOf(pool) {
|
|
30164
|
+
const businessTypes = splitBusinessTypes(pool.industryExposure);
|
|
30165
|
+
const facility = parseFacility(pool.loanStructure);
|
|
30166
|
+
if (!businessTypes && !facility)
|
|
30167
|
+
return undefined;
|
|
30168
|
+
return Object.assign(Object.assign({}, (businessTypes ? { businessTypes } : {})), (facility ? { facility } : {}));
|
|
30169
|
+
}
|
|
29629
30170
|
/**
|
|
29630
30171
|
* A CMS text field as a string, or `undefined` when it is absent, not a
|
|
29631
30172
|
* string, or empty (blank included) — the CMS stores an emptied field as `''`, and an empty
|
|
@@ -31124,4 +31665,4 @@ function weightedAverageApy(slices) {
|
|
|
31124
31665
|
return weighted / totalBalance;
|
|
31125
31666
|
}
|
|
31126
31667
|
|
|
31127
|
-
export { APXIUM, AU_ALPHA3, AU_MIN_CUMULATIVE_BY_STABLE, BatchPendingError, BatchRevertedError, BatchSubmissionError, CHAIN_CONFIGS, CLEARING_WINDOW_SECONDS, CONTRACT_TTL_MS, CallsFacade, DAYS_PER_EPOCH, DAYS_PER_MONTH, DEFAULT_BATCH_POLLING_POLICY, DepositBatchMismatchError, DepositFlow, DepositsFacade, ENTRY_POINT_V07, EPOCHS_IN_YEAR, Flow, FlowStore, FlowsFacade, INVALID_ACCEPTANCE_SIGNATURE_MESSAGE, INVALID_AUTH_SIGNATURE_MESSAGE, INVOICEMATE, Kasu, KasuSdk, MAX_LENDING_AMOUNT_FALLBACK, MIN_DAYS_FOR_MONTHS, MIN_LENDING_AMOUNT_FALLBACK, MIN_TRANCHE_CAPACITY, NOT_A_WITHDRAWAL_CALL_MESSAGE, NO_DIRECTUS_URL_MESSAGE, NO_HISTORY_PROVIDER_MESSAGE, NO_KYC_PARAMS_MESSAGE, NO_SPENDER_MESSAGE, NO_WITHDRAWAL_ENCODER_MESSAGE, PastStateUnavailableError, PoolTvlHistoryAbortedError, PoolTvlHistoryTimeoutError, PortfolioFacade, READ_ONLY_MESSAGE, RIXON_CAPITAL, SECONDS_PER_WEEK, SPONSORED_CALL_KINDS, SPONSORED_CALL_SELECTORS, SdkConfig, SponsoredCallInputError, StrategiesFacade, StrategyDeploymentInputError, TvlHistoryInputError, UPPER_MEZZANINE, WithdrawFlow, accruedInterest, aggregateYieldHistory, apyToEpochRate, asContractType, auMinimumRemaining, auThresholdFor, availableFixedTermConfigs, batchOutcomeOf, buildContractVersionType, buildFullNameRequestMessage, buildLegacyContractRequestMessage, buildLoanAgreementSignMessage, cancelDeadline, ceilToCents, checkBatchOutcome, checkSponsoredCallOutcome, classifyWalletFailure, combineTvlHistories, compareTrancheSeniority, computeSettlementWindow, countSubmissions, dailyInterest, decodeRevert, deriveCycleDates, derivePoolStatus, deriveRequestState, encodeCancelDepositCall, encodeCancelWithdrawalCall, encodeDepositData, encodeRequestWithdrawalCall, encodeStableTransfer, encodeWithdrawAtExpiryCall, epochRateToApy, epochTrancheYield, explorerAddressUrl, explorerTxUrl, extractRevertData, fetchUnusedPoolIds, firstSubmissionTimestamp, floorToCents, formatSignTimestampUtc, getCreditOriginator, getInstitutionalLender, getStrategyRegion, getTrancheDisplayName, isAuMinimumExempt, isAustralianKyc, isBelowMinimumCapacity, isCycleClosed, isDefinitivelyNotSubmitted, isFixedTermConfigId, isUnpredictableGas, isUserRejected, lastEventTimestamp, lockDurationDays, lockDurationMonths, maxNetRateCeiling, netEffectiveApy, netTrancheApyBounds, nextCycleBoundary, parseFormattedMessage, parseMinorUnits, parseTrancheBound, pickDefaultTrancheId, pickHighestYieldTranche, pickShortDescription, poolAllTranchesFull, poolMaxApy, poolTvl, projectedAnnualEarnings, proveDepositInReceipt, proveUserOperationInReceipt, resolveBoundShortcuts, resolveDepositBounds, selectVisiblePools, strategyDeployments, submissionEvents, submitBatch, submitSponsoredCall, trancheApyBounds, trancheHasCapacity, trancheRiskRank, validateDepositBatchCalls, weeklyInterest, weightedAverageApy };
|
|
31668
|
+
export { APXIUM, AU_ALPHA3, AU_MIN_CUMULATIVE_BY_STABLE, BatchPendingError, BatchRevertedError, BatchSubmissionError, CHAIN_CONFIGS, CLEARING_WINDOW_SECONDS, CONTRACT_TTL_MS, CallsFacade, DAYS_PER_EPOCH, DAYS_PER_MONTH, DEFAULT_BATCH_POLLING_POLICY, DepositBatchMismatchError, DepositFlow, DepositsFacade, ENTRY_POINT_V07, EPOCHS_IN_YEAR, Flow, FlowStore, FlowsFacade, INVALID_ACCEPTANCE_SIGNATURE_MESSAGE, INVALID_AUTH_SIGNATURE_MESSAGE, INVOICEMATE, Kasu, KasuSdk, MAX_LENDING_AMOUNT_FALLBACK, MIN_DAYS_FOR_MONTHS, MIN_LENDING_AMOUNT_FALLBACK, MIN_TRANCHE_CAPACITY, NOT_A_WITHDRAWAL_CALL_MESSAGE, NO_DIRECTUS_URL_MESSAGE, NO_HISTORY_PROVIDER_MESSAGE, NO_KYC_PARAMS_MESSAGE, NO_SPENDER_MESSAGE, NO_WITHDRAWAL_ENCODER_MESSAGE, PastStateUnavailableError, PoolTvlHistoryAbortedError, PoolTvlHistoryTimeoutError, PortfolioFacade, READ_ONLY_MESSAGE, RISK_GROUP_ORDER, RIXON_CAPITAL, SECONDS_PER_WEEK, SPONSORED_CALL_KINDS, SPONSORED_CALL_SELECTORS, SdkConfig, SponsoredCallInputError, StrategiesFacade, StrategyDeploymentInputError, StrategyTotalsInputError, TvlHistoryInputError, UPPER_MEZZANINE, WithdrawFlow, accruedInterest, aggregateYieldHistory, apyToEpochRate, asContractType, auMinimumRemaining, auThresholdFor, availableFixedTermConfigs, batchOutcomeOf, buildContractVersionType, buildFullNameRequestMessage, buildLegacyContractRequestMessage, buildLoanAgreementSignMessage, cancelDeadline, ceilToCents, checkBatchOutcome, checkSponsoredCallOutcome, classifyWalletFailure, combineTvlHistories, compareTrancheSeniority, computeSettlementWindow, countSubmissions, dailyInterest, decodeRevert, deriveCycleDates, derivePoolStatus, deriveRequestState, encodeCancelDepositCall, encodeCancelWithdrawalCall, encodeDepositData, encodeRequestWithdrawalCall, encodeStableTransfer, encodeWithdrawAtExpiryCall, epochRateToApy, epochTrancheYield, explorerAddressUrl, explorerTxUrl, extractRevertData, fetchUnusedPoolIds, firstSubmissionTimestamp, floorToCents, formatSignTimestampUtc, getCreditOriginator, getInstitutionalLender, getStrategyRegion, getTrancheDisplayName, groupRiskManagementItems, isAuMinimumExempt, isAustralianKyc, isBelowMinimumCapacity, isCycleClosed, isDefinitivelyNotSubmitted, isFixedTermConfigId, isUnpredictableGas, isUserRejected, lastEventTimestamp, lockDurationDays, lockDurationMonths, maxNetRateCeiling, netEffectiveApy, netTrancheApyBounds, nextCycleBoundary, parseFacility, parseFormattedMessage, parseMinorUnits, parseTrancheBound, pickDefaultTrancheId, pickHighestYieldTranche, pickShortDescription, poolAllTranchesFull, poolMaxApy, poolTvl, projectedAnnualEarnings, proveDepositInReceipt, proveUserOperationInReceipt, readCmsStartDate, resolveBoundShortcuts, resolveDepositBounds, securityStructureOf, selectVisiblePools, splitBusinessTypes, splitNumberedClauses, strategyDeployments, strategyTotalsUsd, submissionEvents, submitBatch, submitSponsoredCall, trancheApyBounds, trancheHasCapacity, trancheRiskRank, validateDepositBatchCalls, weeklyInterest, weightedAverageApy };
|
package/dist/domain/index.d.ts
CHANGED
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
*
|
|
20
20
|
* `pickShortDescription` returns a string but AUTHORS none: it selects and
|
|
21
21
|
* cleans editorial the CMS already holds, and an absent blurb is
|
|
22
|
-
* `undefined`, never a sentence of its own.
|
|
22
|
+
* `undefined`, never a sentence of its own. The Details-screen parsers in
|
|
23
|
+
* `strategy-details.ts` (`splitBusinessTypes`, `parseFacility`,
|
|
24
|
+
* `groupRiskManagementItems`, …) are the same kind: they split and trim
|
|
25
|
+
* CMS text, and an unauthored field is `undefined`.
|
|
23
26
|
* 2. **Pure.** No network, no clock, no environment. Anything with I/O belongs
|
|
24
27
|
* in `facade/` (see `fetchUnusedPoolIds`).
|
|
25
28
|
*/
|
|
@@ -50,6 +53,8 @@ export { encodeCancelDepositCall, encodeCancelWithdrawalCall, encodeRequestWithd
|
|
|
50
53
|
export type { SponsoredCall, SponsoredCallKind } from './sponsored-calls';
|
|
51
54
|
export { pickShortDescription } from './strategy-summary';
|
|
52
55
|
export type { ShortDescriptionSource } from './strategy-summary';
|
|
56
|
+
export { groupRiskManagementItems, parseFacility, readCmsStartDate, RISK_GROUP_ORDER, securityStructureOf, splitBusinessTypes, splitNumberedClauses, StrategyTotalsInputError, strategyTotalsUsd, } from './strategy-details';
|
|
57
|
+
export type { CmsStartDateOptions, CmsTwoLineValue, RiskManagementItemSource, StrategyFacility, StrategyRiskGroup, StrategyRiskItem, StrategyTotalsInputErrorCode, StrategyTotalsLeg, StrategyTotalsUsd, } from './strategy-details';
|
|
53
58
|
export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
|
|
54
59
|
export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
|
|
55
60
|
export type { ApyBounds, PoolStatus, TrancheCapacitySignal } from './tranches';
|