@kasufinance/kasu-sdk 2.10.3 → 2.12.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 (41) hide show
  1. package/README.md +28 -1
  2. package/dist/bundle.cjs.js +752 -59
  3. package/dist/bundle.esm.js +750 -60
  4. package/dist/domain/index.d.ts +10 -2
  5. package/dist/domain/index.js +6 -0
  6. package/dist/domain/index.js.map +1 -1
  7. package/dist/domain/strategy-summary.d.ts +47 -0
  8. package/dist/domain/strategy-summary.js +76 -0
  9. package/dist/domain/strategy-summary.js.map +1 -0
  10. package/dist/domain/yield-history.d.ts +122 -0
  11. package/dist/domain/yield-history.js +95 -0
  12. package/dist/domain/yield-history.js.map +1 -0
  13. package/dist/facade/strategies.js +2 -0
  14. package/dist/facade/strategies.js.map +1 -1
  15. package/dist/facade/types.d.ts +13 -0
  16. package/dist/facade/user-portfolio.d.ts +32 -0
  17. package/dist/facade/user-portfolio.js +34 -0
  18. package/dist/facade/user-portfolio.js.map +1 -1
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/services/Portfolio/portfolio.d.ts +37 -0
  22. package/dist/services/Portfolio/portfolio.js +136 -56
  23. package/dist/services/Portfolio/portfolio.js.map +1 -1
  24. package/dist/services/Portfolio/queries.js +15 -3
  25. package/dist/services/Portfolio/queries.js.map +1 -1
  26. package/dist/services/Portfolio/types.d.ts +8 -0
  27. package/dist/services/Portfolio/yield-history.d.ts +177 -0
  28. package/dist/services/Portfolio/yield-history.js +405 -0
  29. package/dist/services/Portfolio/yield-history.js.map +1 -0
  30. package/package.json +2 -1
  31. package/src/domain/index.ts +19 -10
  32. package/src/domain/strategy-summary.ts +88 -0
  33. package/src/domain/yield-history.ts +194 -0
  34. package/src/facade/strategies.ts +2 -0
  35. package/src/facade/types.ts +13 -0
  36. package/src/facade/user-portfolio.ts +40 -3
  37. package/src/index.ts +2 -0
  38. package/src/services/Portfolio/portfolio.ts +263 -153
  39. package/src/services/Portfolio/queries.ts +15 -3
  40. package/src/services/Portfolio/types.ts +10 -0
  41. package/src/services/Portfolio/yield-history.ts +574 -0
package/README.md CHANGED
@@ -118,7 +118,7 @@ You can also pass a whole `ChainConfigEntry` instead of a chain key.
118
118
  | ----------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
119
119
  | `kasu.strategies` | `getAll()`, `getVisible()`, `getById()`, `getPlatformStats()`, `getPerformanceFeePercent()`, `calculateDepositLimits()`, `getRiskPerformance(poolId)`, `getOriginator(poolId)` | Browse pools, APY, capacity, risk, originator |
120
120
  | `kasu.deposits` | `deposit()`, `withdraw()`, `withdrawMax()`, `buildKycParams()`, `isClearingPending()` | Submit transactions |
121
- | `kasu.portfolio` | `getPositions()`, `getTransactionHistory()`, `getRequestStates()` | Lender balances, yield, history |
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 |
123
123
  | `kasu.calls` | `requestWithdrawal(params)`, `cancelDepositRequest(poolId, dNftId)`, `cancelWithdrawalRequest(poolId, wNftId)`, `withdrawAtExpiry(poolId, lockId)` | Encoded calls for a sponsored relay (read, then encode — never sends) |
124
124
 
@@ -132,6 +132,16 @@ return an empty list; pass it straight through. `SdkConfig` normalises an empty
132
132
  exclusion list to `['']`, because the subgraph reads `id_not_in: []` as "match
133
133
  nothing" and would otherwise hide every pool.
134
134
 
135
+ `kasu.portfolio.getYieldHistory(user, { fromEpoch?, count? })` returns one
136
+ `{ epochId, epochEnd, poolId, trancheId, netYield }` per settled cycle the
137
+ lender held shares in; `aggregateYieldHistory(entries, { poolId? })` turns it
138
+ into chart bars. `netYield` is NET of the performance fee and in the
139
+ deployment's own stable token (AUDD on XDC AUDD — convert before showing USD);
140
+ `epochEnd` is unix seconds. For a fixed-term lock holder the bars can sum to
141
+ slightly more than lifetime interest (up to about 0.2 %, top-ups are valued at
142
+ today's share price), so show "earned to date" from the lifetime figure, not
143
+ from the sum of the bars.
144
+
135
145
  ## Domain helpers
136
146
 
137
147
  Pure functions shared by every Kasu frontend. They return **numbers and codes,
@@ -149,6 +159,7 @@ application formats them in its own design system and language.
149
159
  | Yields | `weeklyInterest`, `dailyInterest`, `accruedInterest`, `projectedAnnualEarnings`, `weightedAverageApy`, `SECONDS_PER_WEEK` — NET of the performance fee |
150
160
  | Batch proof | `validateDepositBatchCalls`, `proveDepositInReceipt`, `DepositBatchMismatchError`, `ENTRY_POINT_V07` |
151
161
  | Tranche display name | `getTrancheDisplayName`, `UPPER_MEZZANINE` |
162
+ | Strategy summary | `pickShortDescription` — the CMS short blurb as one line of plain text, or `undefined` (also on every `Strategy` as `summary`) |
152
163
  | Requests | `deriveRequestState`, `submissionEvents`, `countSubmissions`, `firstSubmissionTimestamp`, `isCycleClosed` |
153
164
  | Settlement | `computeSettlementWindow`, `nextCycleBoundary`, `deriveCycleDates`, `CLEARING_WINDOW_SECONDS` |
154
165
  | Loan contract | `encodeDepositData`, `buildContractVersionType`, `buildLoanAgreementSignMessage`, `buildLegacyContractRequestMessage`, `buildFullNameRequestMessage`, `formatSignTimestampUtc`, `parseFormattedMessage`, `asContractType` |
@@ -169,6 +180,14 @@ Three rules worth knowing:
169
180
  wrong number when an input is out of domain. Render that as "no rate", never
170
181
  as zero, and never substitute a fee of `0` for one you have not loaded — a
171
182
  fee-less rate overstates what a lender earns.
183
+ - **`Strategy.summary` is CMS editorial, cleaned, never authored.** It is
184
+ `liteDescription` when usable, else the first paragraph of `description`,
185
+ with inline markdown markers stripped and whitespace collapsed to one line.
186
+ The `"Not Available"` placeholder and a blank value count as missing, and an
187
+ absent blurb is `undefined`: what to show instead is the app's decision.
188
+ `liteDescription` and `description` stay the raw CMS values. It is NOT
189
+ sanitised: HTML tags and link syntax pass through unchanged, so render it
190
+ as text, never as HTML or markdown.
172
191
  - **The tranche rename is display-only.** `getTrancheDisplayName` maps the
173
192
  `Senior` tranche to "Upper Mezzanine" on Apxium strategies, because the true
174
193
  senior position is held by an institutional lender. Call it at the view
@@ -558,6 +577,14 @@ network problem cannot fail a pull request that did not touch the network.
558
577
  CI runs `build-tc`, `build`, `test:unit` and `rollup-build` on every pull
559
578
  request.
560
579
 
580
+ `npm ci` also installs a **pre-push hook** (`.githooks/pre-push`) that runs the
581
+ same steps locally before every `git push`: first a lockfile check
582
+ (`npm ci --dry-run`, which fails when `package.json` and `package-lock.json`
583
+ disagree), then `build-tc`, `build`, `test:unit` and `rollup-build`. It stops at
584
+ the first failing step and names it. It checks the working tree, not the pushed
585
+ commits, so commit first. `SKIP_PREPUSH=1 git push` skips it with a warning; CI
586
+ is still the gate.
587
+
561
588
  ## Versioning & publishing
562
589
 
563
590
  The package follows semantic versioning. The published runtime entry is the