@kasufinance/kasu-sdk 2.12.0 → 2.13.1

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 (62) hide show
  1. package/README.md +26 -1
  2. package/dist/bundle.cjs.js +974 -83
  3. package/dist/bundle.esm.js +971 -85
  4. package/dist/domain/index.d.ts +2 -0
  5. package/dist/domain/index.js +1 -0
  6. package/dist/domain/index.js.map +1 -1
  7. package/dist/domain/pool-tvl.d.ts +62 -0
  8. package/dist/domain/pool-tvl.js +22 -0
  9. package/dist/domain/pool-tvl.js.map +1 -0
  10. package/dist/domain/requests.d.ts +11 -10
  11. package/dist/facade/chain-configs.js +24 -0
  12. package/dist/facade/chain-configs.js.map +1 -1
  13. package/dist/facade/kasu.d.ts +2 -0
  14. package/dist/facade/kasu.js +13 -5
  15. package/dist/facade/kasu.js.map +1 -1
  16. package/dist/facade/strategies.d.ts +20 -0
  17. package/dist/facade/strategies.js +22 -0
  18. package/dist/facade/strategies.js.map +1 -1
  19. package/dist/facade/types.d.ts +20 -0
  20. package/dist/index.d.ts +4 -0
  21. package/dist/index.js +2 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/kasu-sdk.d.ts +9 -1
  24. package/dist/kasu-sdk.js +2 -2
  25. package/dist/kasu-sdk.js.map +1 -1
  26. package/dist/sdk-config.d.ts +20 -0
  27. package/dist/sdk-config.js +3 -1
  28. package/dist/sdk-config.js.map +1 -1
  29. package/dist/services/DataService/data-service.d.ts +81 -1
  30. package/dist/services/DataService/data-service.js +211 -6
  31. package/dist/services/DataService/data-service.js.map +1 -1
  32. package/dist/services/DataService/tvl-history.d.ts +296 -0
  33. package/dist/services/DataService/tvl-history.js +558 -0
  34. package/dist/services/DataService/tvl-history.js.map +1 -0
  35. package/dist/services/Portfolio/yield-history.d.ts +1 -16
  36. package/dist/services/Portfolio/yield-history.js +2 -29
  37. package/dist/services/Portfolio/yield-history.js.map +1 -1
  38. package/dist/services/UserLending/subgraph-types.d.ts +2 -8
  39. package/dist/services/UserLending/types.d.ts +10 -0
  40. package/dist/services/UserLending/user-lending.d.ts +14 -0
  41. package/dist/services/shared.d.ts +16 -0
  42. package/dist/services/shared.js +30 -0
  43. package/dist/services/shared.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/domain/index.ts +3 -0
  46. package/src/domain/pool-tvl.ts +66 -0
  47. package/src/domain/requests.ts +37 -23
  48. package/src/facade/chain-configs.ts +26 -0
  49. package/src/facade/kasu.ts +20 -2
  50. package/src/facade/strategies.ts +26 -0
  51. package/src/facade/types.ts +20 -0
  52. package/src/index.ts +9 -0
  53. package/src/kasu-sdk.ts +19 -2
  54. package/src/sdk-config.ts +22 -0
  55. package/src/services/DataService/data-service.ts +296 -6
  56. package/src/services/DataService/tvl-history.ts +853 -0
  57. package/src/services/Portfolio/yield-history.ts +2 -35
  58. package/src/services/UserLending/queries.ts +2 -7
  59. package/src/services/UserLending/subgraph-types.ts +2 -8
  60. package/src/services/UserLending/types.ts +10 -0
  61. package/src/services/UserLending/user-lending.ts +98 -40
  62. package/src/services/shared.ts +38 -1
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)` | Browse pools, APY, capacity, risk, originator |
119
+ | `kasu.strategies` | `getAll()`, `getVisible()`, `getById()`, `getPlatformStats()`, `getPerformanceFeePercent()`, `calculateDepositLimits()`, `getRiskPerformance(poolId)`, `getOriginator(poolId)`, `getPoolTvlHistory(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 |
@@ -142,6 +142,31 @@ slightly more than lifetime interest (up to about 0.2 %, top-ups are valued at
142
142
  today's share price), so show "earned to date" from the lifetime figure, not
143
143
  from the sum of the bars.
144
144
 
145
+ `kasu.strategies.getPoolTvlHistory(poolId, { fromEpoch?, count?, timeoutMs?,
146
+ signal? })` returns the strategy's TVL (total lent by everyone) as
147
+ `{ epochId, timestamp, tvl, kind }[]`, ascending in time: one
148
+ `kind: 'clearing'` point per finished clearing, read at the block it finished
149
+ in, then one `kind: 'current'` point. `tvl` is in the deployment's own stable
150
+ token (AUDD on XDC AUDD — convert before showing USD) and is on-chain plus
151
+ off-chain TVL, the same `poolTvl` sum `tvl.total` uses; `timestamp` is unix
152
+ seconds. Plot by `timestamp`, not `epochId`: epoch numbers can jump, and
153
+ clearings run in one block share a point in time.
154
+
155
+ The `current` point is the subgraph's latest balance plus the off-chain TVL
156
+ read at `latest`, so it equals `strategy.tvl.total` when both calls' reads
157
+ succeed. `tvl.total` falls back to an off-chain 0 when its own read fails;
158
+ the history throws instead.
159
+
160
+ The off-chain part at old blocks needs RPCs that serve PAST state (archive
161
+ nodes). Built-in chains carry public ones (`historyRpcUrls`, tried in order,
162
+ 10 s per call), but they are RATE-LIMITED and shared: **partners should pass
163
+ their own archive provider** — `Kasu.create({ chain, historyProvider })` — or
164
+ their own `configOverrides.historyRpcUrls`. A failed past-state read throws
165
+ (after retries); it never becomes 0. Final blocks are cached per SDK
166
+ instance, so a second call reads only what is new. `timeoutMs` (default
167
+ 30 s) and `signal` bound the call and reject with
168
+ `PoolTvlHistoryTimeoutError` / `PoolTvlHistoryAbortedError`.
169
+
145
170
  ## Domain helpers
146
171
 
147
172
  Pure functions shared by every Kasu frontend. They return **numbers and codes,