@kasufinance/kasu-sdk 2.11.0 → 2.13.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 +37 -2
- package/dist/bundle.cjs.js +1516 -71
- package/dist/bundle.esm.js +1511 -73
- package/dist/domain/index.d.ts +6 -2
- package/dist/domain/index.js +2 -0
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/pool-tvl.d.ts +62 -0
- package/dist/domain/pool-tvl.js +22 -0
- package/dist/domain/pool-tvl.js.map +1 -0
- package/dist/domain/yield-history.d.ts +122 -0
- package/dist/domain/yield-history.js +95 -0
- package/dist/domain/yield-history.js.map +1 -0
- package/dist/facade/chain-configs.js +24 -0
- package/dist/facade/chain-configs.js.map +1 -1
- package/dist/facade/kasu.d.ts +2 -0
- package/dist/facade/kasu.js +13 -5
- package/dist/facade/kasu.js.map +1 -1
- package/dist/facade/strategies.d.ts +20 -0
- package/dist/facade/strategies.js +22 -0
- package/dist/facade/strategies.js.map +1 -1
- package/dist/facade/types.d.ts +20 -0
- package/dist/facade/user-portfolio.d.ts +32 -0
- package/dist/facade/user-portfolio.js +34 -0
- package/dist/facade/user-portfolio.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/kasu-sdk.d.ts +9 -1
- package/dist/kasu-sdk.js +2 -2
- package/dist/kasu-sdk.js.map +1 -1
- package/dist/sdk-config.d.ts +20 -0
- package/dist/sdk-config.js +3 -1
- package/dist/sdk-config.js.map +1 -1
- package/dist/services/DataService/data-service.d.ts +81 -1
- package/dist/services/DataService/data-service.js +211 -6
- package/dist/services/DataService/data-service.js.map +1 -1
- package/dist/services/DataService/tvl-history.d.ts +296 -0
- package/dist/services/DataService/tvl-history.js +558 -0
- package/dist/services/DataService/tvl-history.js.map +1 -0
- package/dist/services/Portfolio/portfolio.d.ts +37 -0
- package/dist/services/Portfolio/portfolio.js +136 -56
- package/dist/services/Portfolio/portfolio.js.map +1 -1
- package/dist/services/Portfolio/queries.js +15 -3
- package/dist/services/Portfolio/queries.js.map +1 -1
- package/dist/services/Portfolio/types.d.ts +8 -0
- package/dist/services/Portfolio/yield-history.d.ts +162 -0
- package/dist/services/Portfolio/yield-history.js +378 -0
- package/dist/services/Portfolio/yield-history.js.map +1 -0
- package/dist/services/shared.d.ts +16 -0
- package/dist/services/shared.js +30 -0
- package/dist/services/shared.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/index.ts +15 -10
- package/src/domain/pool-tvl.ts +66 -0
- package/src/domain/yield-history.ts +194 -0
- package/src/facade/chain-configs.ts +26 -0
- package/src/facade/kasu.ts +20 -2
- package/src/facade/strategies.ts +26 -0
- package/src/facade/types.ts +20 -0
- package/src/facade/user-portfolio.ts +40 -3
- package/src/index.ts +11 -0
- package/src/kasu-sdk.ts +19 -2
- package/src/sdk-config.ts +22 -0
- package/src/services/DataService/data-service.ts +296 -6
- package/src/services/DataService/tvl-history.ts +853 -0
- package/src/services/Portfolio/portfolio.ts +263 -153
- package/src/services/Portfolio/queries.ts +15 -3
- package/src/services/Portfolio/types.ts +10 -0
- package/src/services/Portfolio/yield-history.ts +541 -0
- package/src/services/shared.ts +38 -1
package/README.md
CHANGED
|
@@ -116,9 +116,9 @@ 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
|
-
| `kasu.portfolio` | `getPositions()`, `getTransactionHistory()`, `getRequestStates()`
|
|
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,41 @@ 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
|
+
|
|
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
|
+
|
|
135
170
|
## Domain helpers
|
|
136
171
|
|
|
137
172
|
Pure functions shared by every Kasu frontend. They return **numbers and codes,
|