@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.
Files changed (46) hide show
  1. package/README.md +29 -5
  2. package/dist/bundle.cjs.js +561 -11
  3. package/dist/bundle.esm.js +553 -12
  4. package/dist/domain/index.d.ts +6 -1
  5. package/dist/domain/index.js +6 -2
  6. package/dist/domain/index.js.map +1 -1
  7. package/dist/domain/loan-contract.d.ts +16 -5
  8. package/dist/domain/loan-contract.js +16 -5
  9. package/dist/domain/loan-contract.js.map +1 -1
  10. package/dist/domain/pool-tvl.js +179 -0
  11. package/dist/domain/pool-tvl.js.map +1 -1
  12. package/dist/domain/requests.js +29 -19
  13. package/dist/domain/requests.js.map +1 -1
  14. package/dist/domain/strategy-details.d.ts +262 -0
  15. package/dist/domain/strategy-details.js +375 -0
  16. package/dist/domain/strategy-details.js.map +1 -0
  17. package/dist/facade/index.d.ts +1 -1
  18. package/dist/facade/index.js +2 -0
  19. package/dist/facade/index.js.map +1 -1
  20. package/dist/facade/strategies.d.ts +85 -3
  21. package/dist/facade/strategies.js +182 -6
  22. package/dist/facade/strategies.js.map +1 -1
  23. package/dist/facade/strategy-deployments.js +97 -0
  24. package/dist/facade/strategy-deployments.js.map +1 -0
  25. package/dist/facade/types.d.ts +82 -0
  26. package/dist/flows/deposit-flow.d.ts +19 -5
  27. package/dist/flows/deposit-flow.js.map +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/services/DataService/data-service.js +80 -9
  30. package/dist/services/DataService/data-service.js.map +1 -1
  31. package/dist/services/DataService/tvl-history.js +89 -0
  32. package/dist/services/DataService/tvl-history.js.map +1 -1
  33. package/dist/services/UserLending/queries.js +2 -7
  34. package/dist/services/UserLending/queries.js.map +1 -1
  35. package/dist/services/UserLending/subgraph-types.js.map +1 -1
  36. package/dist/services/UserLending/types.js.map +1 -1
  37. package/dist/services/UserLending/user-lending.js +72 -16
  38. package/dist/services/UserLending/user-lending.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/domain/index.ts +27 -1
  41. package/src/domain/loan-contract.ts +16 -5
  42. package/src/domain/strategy-details.ts +528 -0
  43. package/src/facade/index.ts +3 -0
  44. package/src/facade/strategies.ts +205 -10
  45. package/src/facade/types.ts +85 -0
  46. package/src/flows/deposit-flow.ts +19 -5
package/README.md CHANGED
@@ -116,7 +116,7 @@ You can also pass a whole `ChainConfigEntry` instead of a chain key.
116
116
 
117
117
  | Facade | Methods | Purpose |
118
118
  | ----------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
119
- | `kasu.strategies` | `getAll()`, `getVisible()`, `getById()`, `getPlatformStats()`, `getPerformanceFeePercent()`, `calculateDepositLimits()`, `getRiskPerformance(poolId)`, `getOriginator(poolId)`, `getPoolTvlHistory(poolId)`, `getPoolTvlHistoryWindow(poolId)` | Browse pools, APY, capacity, risk, originator, TVL history |
119
+ | `kasu.strategies` | `getAll()`, `getVisible()`, `getById()`, `getPlatformStats()`, `getPerformanceFeePercent()`, `calculateDepositLimits()`, `getRiskPerformance(poolId)`, `getOriginator(poolId)`, `getOriginatorHistory(poolId)`, `getRiskManagementGroups(poolId)`, `getPoolTvlHistory(poolId)`, `getPoolTvlHistoryWindow(poolId)` | Browse pools, APY, capacity, risk, originator, TVL history |
120
120
  | `kasu.deposits` | `deposit()`, `withdraw()`, `withdrawMax()`, `buildKycParams()`, `isClearingPending()` | Submit transactions |
121
121
  | `kasu.portfolio` | `getPositions()`, `getYieldHistory()`, `getTransactionHistory()`, `getRequestStates()` | Lender balances, yield, per-cycle earnings (net, in the chain's own stable token), history |
122
122
  | `kasu.flows` | `deposit(ports)`, `withdraw(ports?)` | Headless transaction pipelines |
@@ -223,15 +223,16 @@ application formats them in its own design system and language.
223
223
  | Batch proof | `validateDepositBatchCalls`, `proveDepositInReceipt`, `DepositBatchMismatchError`, `ENTRY_POINT_V07` |
224
224
  | Tranche display name | `getTrancheDisplayName`, `UPPER_MEZZANINE` |
225
225
  | Strategy summary | `pickShortDescription` — the CMS short blurb as one line of plain text, or `undefined` (also on every `Strategy` as `summary`) |
226
+ | Strategy details | `readCmsStartDate`, `splitBusinessTypes`, `parseFacility`, `splitNumberedClauses`, `groupRiskManagementItems`, `RISK_GROUP_ORDER`, `securityStructureOf`, `strategyTotalsUsd`, `StrategyTotalsInputError` — the Details-screen fields as kasu-ui reads them (also on `Strategy` and the two strategy getters above) |
226
227
  | Requests | `deriveRequestState`, `submissionEvents`, `countSubmissions`, `firstSubmissionTimestamp`, `isCycleClosed` |
227
228
  | Settlement | `computeSettlementWindow`, `nextCycleBoundary`, `deriveCycleDates`, `CLEARING_WINDOW_SECONDS` |
228
- | Loan contract | `encodeDepositData`, `buildContractVersionType`, `buildLoanAgreementSignMessage`, `buildLegacyContractRequestMessage`, `buildFullNameRequestMessage`, `formatSignTimestampUtc`, `parseFormattedMessage`, `asContractType` |
229
+ | Loan contract | `encodeDepositData`, `buildContractVersionType`, `buildLoanAgreementSignMessage`, `buildLegacyContractRequestMessage` (deprecated), `buildFullNameRequestMessage`, `formatSignTimestampUtc`, `parseFormattedMessage`, `asContractType` |
229
230
  | Wallet errors | `isUserRejected`, `isUnpredictableGas`, `classifyWalletFailure` |
230
231
  | Pool TVL | `poolTvl`, `combineTvlHistories`, `TvlHistoryInputError` — one strategy's history summed across deployments, in USD at the caller's rates |
231
232
  | Revert errors | `decodeRevert`, `extractRevertData` — the bytes a reverted call came back with, read as the custom error the contract named |
232
233
  | AU minimum | `auMinimumRemaining`, `isAustralianKyc`, `auThresholdFor`, `isAuMinimumExempt`, `parseMinorUnits`, `AU_ALPHA3`, `AU_MIN_CUMULATIVE_BY_STABLE` |
233
234
 
234
- Three rules worth knowing:
235
+ Rules worth knowing:
235
236
 
236
237
  - **Protocol strings are the exception to "never copy".** The messages
237
238
  `loan-contract` builds are reconstructed byte-for-byte by the Kasu backend to
@@ -252,6 +253,29 @@ Three rules worth knowing:
252
253
  `liteDescription` and `description` stay the raw CMS values. It is NOT
253
254
  sanitised: HTML tags and link syntax pass through unchanged, so render it
254
255
  as text, never as HTML or markdown.
256
+ - **The Details-screen fields omit, never stub.** `Strategy.strategyHistory`,
257
+ `Strategy.endBorrowers`, `Strategy.securityStructure`,
258
+ `getOriginatorHistory` and `getRiskManagementGroups` carry only what the CMS
259
+ actually authors: an empty, blank or malformed value is an absent key (or
260
+ `null` for a whole section), never a `0`, a dash or a sentence of the
261
+ SDK's own. A start date is `YYYY-MM-DD` and must be a real date from 2000
262
+ up to today. The originator's money figures are editorial USD on every
263
+ deployment — never FX-convert them. A risk item's `description` is present
264
+ exactly when its `clauses` are non-empty.
265
+ - **A failed CMS read rejects; it is not "no data".** `getOriginatorHistory`
266
+ and `getRiskManagementGroups` reject on a CMS outage (or no
267
+ `directusUrl`). For what to SHOW, treat a rejected `getRiskManagementGroups`
268
+ like `null`: fall back to `Strategy.securityStructure`. The pool getters
269
+ share their CMS reads per instance for 30 seconds (`getRiskPerformance` with
270
+ `getRiskManagementGroups`, `getOriginator` with `getOriginatorHistory`), so
271
+ a Details screen reads each collection once; a failed read is never reused.
272
+ - **`strategyTotalsUsd(legs, expectedDeployments)` states its coverage.** It
273
+ sums a strategy's Total Active Lending and Lender Interest Earned in USD
274
+ over the legs the caller loaded, each at its own rate. It is `null`
275
+ (withheld) when there are no legs or any loaded leg lacks a usable rate;
276
+ otherwise `isPartial` / `missingDeployments` name every expected deployment
277
+ the sum does not cover. Only `isPartial: false` is the whole strategy. A
278
+ duplicated or unexpected leg throws `StrategyTotalsInputError`.
255
279
  - **The tranche rename is display-only.** `getTrancheDisplayName` maps the
256
280
  `Senior` tranche to "Upper Mezzanine" on Apxium strategies, because the true
257
281
  senior position is held by an institutional lender. Call it at the view
@@ -662,8 +686,8 @@ tag workflow only verifies that a pushed `vX.Y.Z` tag matches `package.json`.
662
686
  ## Support
663
687
 
664
688
  - Issues: <https://github.com/Kasu-Finance/kasu-sdk/issues>
665
- - Developer documentation: <https://devdocs.kasu.finance>
666
- - Product documentation: <https://docs.kasu.finance>
689
+ - Developer documentation: <https://kasu.finance/docs/developers>
690
+ - Product documentation: <https://kasu.finance/docs/user>
667
691
 
668
692
  ## License
669
693