@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/dist/domain/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export type { ContractListItem, ContractSection, ContractType, ExemptLoanContrac
|
|
|
41
41
|
export { maxNetRateCeiling, pickHighestYieldTranche, poolMaxApy, selectVisiblePools, } from './pools';
|
|
42
42
|
export type { BestTranche } from './pools';
|
|
43
43
|
export { cancelDeadline, countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, lastEventTimestamp, submissionEvents, } from './requests';
|
|
44
|
-
export type { RequestKind, RequestState, RequestStatusCode
|
|
44
|
+
export type { RequestKind, RequestState, RequestStatusCode } from './requests';
|
|
45
45
|
export { decodeRevert, extractRevertData } from './revert-errors';
|
|
46
46
|
export type { DecodedRevert, RevertFamily } from './revert-errors';
|
|
47
47
|
export { CLEARING_WINDOW_SECONDS, computeSettlementWindow, deriveCycleDates, nextCycleBoundary, } from './settlement';
|
|
@@ -52,8 +52,12 @@ export { pickShortDescription } from './strategy-summary';
|
|
|
52
52
|
export type { ShortDescriptionSource } from './strategy-summary';
|
|
53
53
|
export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
|
|
54
54
|
export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
|
|
55
|
-
export type { ApyBounds, PoolStatus, TrancheCapacitySignal
|
|
55
|
+
export type { ApyBounds, PoolStatus, TrancheCapacitySignal } from './tranches';
|
|
56
56
|
export { classifyWalletFailure, isUnpredictableGas, isUserRejected, } from './wallet-errors';
|
|
57
57
|
export type { WalletFailure } from './wallet-errors';
|
|
58
|
+
export { poolTvl } from './pool-tvl';
|
|
59
|
+
export type { PoolTvlHistoryEntry } from './pool-tvl';
|
|
60
|
+
export { aggregateYieldHistory, epochTrancheYield } from './yield-history';
|
|
61
|
+
export type { EpochLockShares, EpochTrancheYield, EpochTrancheYieldInput, YieldHistoryEntry, YieldHistoryFilter, YieldHistoryPoint, } from './yield-history';
|
|
58
62
|
export { accruedInterest, dailyInterest, projectedAnnualEarnings, SECONDS_PER_WEEK, weeklyInterest, weightedAverageApy, } from './yields';
|
|
59
63
|
export type { InterestSlice, PoolAccrual } from './yields';
|
package/dist/domain/index.js
CHANGED
|
@@ -40,5 +40,7 @@ export { pickShortDescription } from './strategy-summary';
|
|
|
40
40
|
export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
|
|
41
41
|
export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
|
|
42
42
|
export { classifyWalletFailure, isUnpredictableGas, isUserRejected, } from './wallet-errors';
|
|
43
|
+
export { poolTvl } from './pool-tvl';
|
|
44
|
+
export { aggregateYieldHistory, epochTrancheYield } from './yield-history';
|
|
43
45
|
export { accruedInterest, dailyInterest, projectedAnnualEarnings, SECONDS_PER_WEEK, weeklyInterest, weightedAverageApy, } from './yields';
|
|
44
46
|
//# sourceMappingURL=index.js.map
|
package/dist/domain/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACH,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACH,SAAS,EACT,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,eAAe,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACH,yBAAyB,EACzB,eAAe,EACf,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,GAC5B,MAAM,eAAe,CAAC;AAavB,OAAO,EACH,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,GACvB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EACH,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACH,MAAM,EACN,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,aAAa,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,cAAc,EACd,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,6BAA6B,EAC7B,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,GACxB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EACH,iBAAiB,EACjB,uBAAuB,EACvB,UAAU,EACV,kBAAkB,GACrB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACnB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACH,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACH,SAAS,EACT,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,eAAe,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACH,yBAAyB,EACzB,eAAe,EACf,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,GAC5B,MAAM,eAAe,CAAC;AAavB,OAAO,EACH,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,GACvB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EACH,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACH,MAAM,EACN,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,aAAa,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,cAAc,EACd,wBAAwB,EACxB,2BAA2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AC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pool's TVL — the total lent into it by everyone — and the shape of its
|
|
3
|
+
* history. Pure: the reads live in `services/DataService/tvl-history.ts`.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The ONE definition of a pool's TVL: what lenders have lent on chain
|
|
7
|
+
* (`lendingPool.balance` in the subgraph) plus the off-chain amount the
|
|
8
|
+
* pool's `ExternalTVL` contract records (`externalTVLOfPool`).
|
|
9
|
+
*
|
|
10
|
+
* Both inputs, and the result, are in DISPLAY units of the deployment's own
|
|
11
|
+
* stable token (USDC on Base and XDC USDC, AUDD on XDC AUDD) — `'1.5'` is
|
|
12
|
+
* one and a half tokens, not 1.5 minor units. Convert before formatting as
|
|
13
|
+
* USD.
|
|
14
|
+
*
|
|
15
|
+
* `getPoolOverview` (its `totalValueLocked.total`) and `getPoolTvlHistory`
|
|
16
|
+
* (every point) both call this, so the chart and the figure above it cannot
|
|
17
|
+
* be computed two ways.
|
|
18
|
+
*/
|
|
19
|
+
export declare function poolTvl(onChainBalance: string, offChainTvl: string): number;
|
|
20
|
+
/**
|
|
21
|
+
* One point of a pool's TVL history.
|
|
22
|
+
*
|
|
23
|
+
* - `kind: 'clearing'` — the TVL as it stood at the end of the block in which
|
|
24
|
+
* that epoch's clearing finished (`LendingPoolClearing.endBlockNumber`):
|
|
25
|
+
* accepted deposits and withdrawals and the applied interest included.
|
|
26
|
+
* - `kind: 'current'` — the closing "as of now" point, from two sources: the
|
|
27
|
+
* subgraph's latest balance (and its latest block time) and
|
|
28
|
+
* `externalTVLOfPool` at `latest` on the history provider. It equals
|
|
29
|
+
* today's `PoolOverview.totalValueLocked.total` when both that call's reads
|
|
30
|
+
* and these succeed; `getPoolOverview` falls back to an off-chain 0 when its
|
|
31
|
+
* own read fails, and the figure can move between the two calls.
|
|
32
|
+
*/
|
|
33
|
+
export interface PoolTvlHistoryEntry {
|
|
34
|
+
/**
|
|
35
|
+
* The epoch (cycle) number, in the chain's numbering
|
|
36
|
+
* (`SystemVariables.currentEpochNumber`).
|
|
37
|
+
*
|
|
38
|
+
* A clearing point carries the epoch that clearing closed. The `current`
|
|
39
|
+
* point carries the CURRENT epoch — which may equal the newest clearing's
|
|
40
|
+
* epoch, because a clearing runs before its epoch rolls over. Epoch
|
|
41
|
+
* numbers can jump (a pool that did not clear for a while, or a
|
|
42
|
+
* deployment whose first clearing is numbered far below the next one), so
|
|
43
|
+
* plot by `timestamp`, never by `epochId`.
|
|
44
|
+
*/
|
|
45
|
+
epochId: number;
|
|
46
|
+
/**
|
|
47
|
+
* Unix SECONDS. A clearing point: the time of the block its clearing
|
|
48
|
+
* finished in (`endTimestamp`). The `current` point: the time of the
|
|
49
|
+
* subgraph's latest indexed block. Clearings that finished in the same
|
|
50
|
+
* block (a pool catching up several epochs at once) share a timestamp and
|
|
51
|
+
* a `tvl`.
|
|
52
|
+
*/
|
|
53
|
+
timestamp: number;
|
|
54
|
+
/**
|
|
55
|
+
* TVL in DISPLAY units of the deployment's own stable token (USDC on Base
|
|
56
|
+
* and XDC USDC, AUDD on XDC AUDD): `poolTvl(onChain, offChain)` at that
|
|
57
|
+
* block. Convert before formatting as USD.
|
|
58
|
+
*/
|
|
59
|
+
tvl: number;
|
|
60
|
+
/** `'clearing'` for a cycle boundary; `'current'` for the closing point. */
|
|
61
|
+
kind: 'clearing' | 'current';
|
|
62
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pool's TVL — the total lent into it by everyone — and the shape of its
|
|
3
|
+
* history. Pure: the reads live in `services/DataService/tvl-history.ts`.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The ONE definition of a pool's TVL: what lenders have lent on chain
|
|
7
|
+
* (`lendingPool.balance` in the subgraph) plus the off-chain amount the
|
|
8
|
+
* pool's `ExternalTVL` contract records (`externalTVLOfPool`).
|
|
9
|
+
*
|
|
10
|
+
* Both inputs, and the result, are in DISPLAY units of the deployment's own
|
|
11
|
+
* stable token (USDC on Base and XDC USDC, AUDD on XDC AUDD) — `'1.5'` is
|
|
12
|
+
* one and a half tokens, not 1.5 minor units. Convert before formatting as
|
|
13
|
+
* USD.
|
|
14
|
+
*
|
|
15
|
+
* `getPoolOverview` (its `totalValueLocked.total`) and `getPoolTvlHistory`
|
|
16
|
+
* (every point) both call this, so the chart and the figure above it cannot
|
|
17
|
+
* be computed two ways.
|
|
18
|
+
*/
|
|
19
|
+
export function poolTvl(onChainBalance, offChainTvl) {
|
|
20
|
+
return parseFloat(onChainBalance) + parseFloat(offChainTvl);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=pool-tvl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-tvl.js","sourceRoot":"","sources":["../../src/domain/pool-tvl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CAAC,cAAsB,EAAE,WAAmB;IAC/D,OAAO,UAAU,CAAC,cAAc,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settled interest per cycle (epoch): what a lender was credited at each close,
|
|
3
|
+
* per pool and tranche, and the one formula that turns a tranche's credited
|
|
4
|
+
* interest into one lender's share of it.
|
|
5
|
+
*
|
|
6
|
+
* **The figures are NET, and only net.** `LendingPool._applyTrancheInterest`
|
|
7
|
+
* takes the performance fee off first and emits `InterestApplied` with the
|
|
8
|
+
* lender side only (`interest × (1 − performanceFee)`); a fixed-term top-up
|
|
9
|
+
* (`_applyFixedRateInterests`) is net of the fee the same way. So the figure
|
|
10
|
+
* this module computes from those records IS what the lender was credited —
|
|
11
|
+
* never take the fee off it again. No gross is offered: the subgraph keeps
|
|
12
|
+
* only TODAY's fee, so a historical gross would be a guess.
|
|
13
|
+
*
|
|
14
|
+
* Units: amounts are display units of the DEPLOYMENT'S OWN stable token (USDC
|
|
15
|
+
* on Base and XDC USDC, AUDD on XDC AUDD) — never converted to USD here;
|
|
16
|
+
* shares are display units of tranche shares, as the subgraph's BigDecimals.
|
|
17
|
+
*/
|
|
18
|
+
/** One fixed-term lock inside a tranche position, at one epoch. */
|
|
19
|
+
export interface EpochLockShares {
|
|
20
|
+
/**
|
|
21
|
+
* The lock earns in this epoch: it started BEFORE the epoch, ends at or
|
|
22
|
+
* after it, and the lender has a share snapshot for the tranche at it.
|
|
23
|
+
*/
|
|
24
|
+
active: boolean;
|
|
25
|
+
/** The lock's tranche shares as of the epoch (latest update at or before it). */
|
|
26
|
+
sharesAtEpoch: number;
|
|
27
|
+
/** The lock's tranche shares as of the epoch BEFORE it. */
|
|
28
|
+
sharesBeforeEpoch: number;
|
|
29
|
+
}
|
|
30
|
+
/** Everything one lender's share of one tranche's credited interest needs. */
|
|
31
|
+
export interface EpochTrancheYieldInput {
|
|
32
|
+
/** The tranche's interest credited at this epoch's close (net of the fee). */
|
|
33
|
+
epochInterest: number;
|
|
34
|
+
/** The lender's tranche shares as of the epoch (fixed-term locks included). */
|
|
35
|
+
userShares: number;
|
|
36
|
+
/** The tranche's total shares as of the epoch. */
|
|
37
|
+
trancheShares: number;
|
|
38
|
+
/**
|
|
39
|
+
* The tranche's CURRENT balance and shares: the price a fixed-term top-up
|
|
40
|
+
* (extra shares) is valued at. The subgraph keeps no per-epoch tranche
|
|
41
|
+
* balance, so an older top-up is valued at today's price — a second-order
|
|
42
|
+
* difference, because the top-up is only the fixed rate's excess over the
|
|
43
|
+
* variable one.
|
|
44
|
+
*/
|
|
45
|
+
trancheBalanceNow: number;
|
|
46
|
+
trancheSharesNow: number;
|
|
47
|
+
locks: readonly EpochLockShares[];
|
|
48
|
+
}
|
|
49
|
+
export interface EpochTrancheYield {
|
|
50
|
+
/** `variable + Σ locks` — the lender's whole yield in the tranche. */
|
|
51
|
+
total: number;
|
|
52
|
+
/** The variable residual: the share-weighted base yield minus the locks' part of it. */
|
|
53
|
+
variable: number;
|
|
54
|
+
/** Each lock's yield, in the order of `input.locks`: its base part plus its top-up. */
|
|
55
|
+
locks: number[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The ONE per-epoch formula. `Portfolio.getPortfolioLendingData` runs it for
|
|
59
|
+
* the last settled epoch and `getYieldHistory` for every epoch of a window, so
|
|
60
|
+
* the two figures cannot drift apart.
|
|
61
|
+
*
|
|
62
|
+
* ```
|
|
63
|
+
* base = epochInterest × userShares / trancheShares
|
|
64
|
+
* lockBase = base × lock.sharesBeforeEpoch / userShares (active locks)
|
|
65
|
+
* topUp = (lock.sharesAtEpoch − lock.sharesBeforeEpoch) × trancheBalanceNow / trancheSharesNow
|
|
66
|
+
* variable = base − Σ lockBase
|
|
67
|
+
* total = variable + Σ (lockBase + topUp)
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* A zero denominator contributes 0 (a tranche or a lender with no shares
|
|
71
|
+
* earned nothing at that close), never `NaN`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function epochTrancheYield(input: EpochTrancheYieldInput): EpochTrancheYield;
|
|
74
|
+
/** One lender's settled yield in one tranche at one epoch. */
|
|
75
|
+
export interface YieldHistoryEntry {
|
|
76
|
+
/** The epoch (cycle) number, in the chain's numbering. */
|
|
77
|
+
epochId: number;
|
|
78
|
+
/**
|
|
79
|
+
* When the epoch ended — the next epoch's start — in unix SECONDS (not
|
|
80
|
+
* milliseconds).
|
|
81
|
+
*/
|
|
82
|
+
epochEnd: number;
|
|
83
|
+
/** Lowercased lending pool address. */
|
|
84
|
+
poolId: string;
|
|
85
|
+
/** Lowercased tranche address. */
|
|
86
|
+
trancheId: string;
|
|
87
|
+
/**
|
|
88
|
+
* What the close credited the lender in this tranche, AFTER the
|
|
89
|
+
* performance fee, in display units of the deployment's own stable token
|
|
90
|
+
* (AUDD on XDC AUDD — convert before formatting it as USD).
|
|
91
|
+
*/
|
|
92
|
+
netYield: number;
|
|
93
|
+
}
|
|
94
|
+
/** One epoch's yield summed over the entries an aggregation kept. */
|
|
95
|
+
export interface YieldHistoryPoint {
|
|
96
|
+
/** The epoch (cycle) number. */
|
|
97
|
+
epochId: number;
|
|
98
|
+
/** The epoch's end, in unix SECONDS. */
|
|
99
|
+
epochEnd: number;
|
|
100
|
+
/** Net yield summed, in the deployment's own stable token. */
|
|
101
|
+
netYield: number;
|
|
102
|
+
}
|
|
103
|
+
export interface YieldHistoryFilter {
|
|
104
|
+
/** Keep only this pool (case-insensitive). */
|
|
105
|
+
poolId?: string;
|
|
106
|
+
/** Keep only this tranche (case-insensitive). */
|
|
107
|
+
trancheId?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Pool/tranche entries → one point per epoch, ascending by `epochId`. With no
|
|
111
|
+
* filter it sums every strategy (the Lend tab's bars); with `poolId` it is one
|
|
112
|
+
* strategy (a strategy page's bars).
|
|
113
|
+
*
|
|
114
|
+
* An epoch appears only if a kept entry has it — there is no zero padding, so
|
|
115
|
+
* an empty input (a new lender) is an empty output.
|
|
116
|
+
*
|
|
117
|
+
* For a fixed-term lock holder the bars can sum to slightly MORE than the
|
|
118
|
+
* lender's lifetime interest (up to about 0.2 %): each top-up is valued at the
|
|
119
|
+
* tranche's CURRENT share price, which has grown since. Show "earned to date"
|
|
120
|
+
* from the lifetime figure, never from this sum.
|
|
121
|
+
*/
|
|
122
|
+
export declare function aggregateYieldHistory(entries: readonly YieldHistoryEntry[], filter?: YieldHistoryFilter): YieldHistoryPoint[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settled interest per cycle (epoch): what a lender was credited at each close,
|
|
3
|
+
* per pool and tranche, and the one formula that turns a tranche's credited
|
|
4
|
+
* interest into one lender's share of it.
|
|
5
|
+
*
|
|
6
|
+
* **The figures are NET, and only net.** `LendingPool._applyTrancheInterest`
|
|
7
|
+
* takes the performance fee off first and emits `InterestApplied` with the
|
|
8
|
+
* lender side only (`interest × (1 − performanceFee)`); a fixed-term top-up
|
|
9
|
+
* (`_applyFixedRateInterests`) is net of the fee the same way. So the figure
|
|
10
|
+
* this module computes from those records IS what the lender was credited —
|
|
11
|
+
* never take the fee off it again. No gross is offered: the subgraph keeps
|
|
12
|
+
* only TODAY's fee, so a historical gross would be a guess.
|
|
13
|
+
*
|
|
14
|
+
* Units: amounts are display units of the DEPLOYMENT'S OWN stable token (USDC
|
|
15
|
+
* on Base and XDC USDC, AUDD on XDC AUDD) — never converted to USD here;
|
|
16
|
+
* shares are display units of tranche shares, as the subgraph's BigDecimals.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The ONE per-epoch formula. `Portfolio.getPortfolioLendingData` runs it for
|
|
20
|
+
* the last settled epoch and `getYieldHistory` for every epoch of a window, so
|
|
21
|
+
* the two figures cannot drift apart.
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* base = epochInterest × userShares / trancheShares
|
|
25
|
+
* lockBase = base × lock.sharesBeforeEpoch / userShares (active locks)
|
|
26
|
+
* topUp = (lock.sharesAtEpoch − lock.sharesBeforeEpoch) × trancheBalanceNow / trancheSharesNow
|
|
27
|
+
* variable = base − Σ lockBase
|
|
28
|
+
* total = variable + Σ (lockBase + topUp)
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* A zero denominator contributes 0 (a tranche or a lender with no shares
|
|
32
|
+
* earned nothing at that close), never `NaN`.
|
|
33
|
+
*/
|
|
34
|
+
export function epochTrancheYield(input) {
|
|
35
|
+
const base = input.trancheShares === 0
|
|
36
|
+
? 0
|
|
37
|
+
: (input.epochInterest * input.userShares) / input.trancheShares;
|
|
38
|
+
let variable = base;
|
|
39
|
+
const locks = input.locks.map((lock) => {
|
|
40
|
+
if (!lock.active)
|
|
41
|
+
return 0;
|
|
42
|
+
const topUp = input.trancheSharesNow === 0
|
|
43
|
+
? 0
|
|
44
|
+
: ((lock.sharesAtEpoch - lock.sharesBeforeEpoch) *
|
|
45
|
+
input.trancheBalanceNow) /
|
|
46
|
+
input.trancheSharesNow;
|
|
47
|
+
const lockBase = input.userShares === 0
|
|
48
|
+
? 0
|
|
49
|
+
: (base * lock.sharesBeforeEpoch) / input.userShares;
|
|
50
|
+
variable -= lockBase;
|
|
51
|
+
return lockBase + topUp;
|
|
52
|
+
});
|
|
53
|
+
const total = locks.reduce((sum, lockYield) => sum + lockYield, variable);
|
|
54
|
+
return { total, variable, locks };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Pool/tranche entries → one point per epoch, ascending by `epochId`. With no
|
|
58
|
+
* filter it sums every strategy (the Lend tab's bars); with `poolId` it is one
|
|
59
|
+
* strategy (a strategy page's bars).
|
|
60
|
+
*
|
|
61
|
+
* An epoch appears only if a kept entry has it — there is no zero padding, so
|
|
62
|
+
* an empty input (a new lender) is an empty output.
|
|
63
|
+
*
|
|
64
|
+
* For a fixed-term lock holder the bars can sum to slightly MORE than the
|
|
65
|
+
* lender's lifetime interest (up to about 0.2 %): each top-up is valued at the
|
|
66
|
+
* tranche's CURRENT share price, which has grown since. Show "earned to date"
|
|
67
|
+
* from the lifetime figure, never from this sum.
|
|
68
|
+
*/
|
|
69
|
+
export function aggregateYieldHistory(entries, filter = {}) {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
const poolId = (_a = filter.poolId) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
72
|
+
const trancheId = (_b = filter.trancheId) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
73
|
+
const byEpoch = new Map();
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
if (poolId !== undefined && entry.poolId.toLowerCase() !== poolId) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (trancheId !== undefined &&
|
|
79
|
+
entry.trancheId.toLowerCase() !== trancheId) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const point = byEpoch.get(entry.epochId);
|
|
83
|
+
if (point) {
|
|
84
|
+
point.netYield += entry.netYield;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
byEpoch.set(entry.epochId, {
|
|
88
|
+
epochId: entry.epochId,
|
|
89
|
+
epochEnd: entry.epochEnd,
|
|
90
|
+
netYield: entry.netYield,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return [...byEpoch.values()].sort((a, b) => a.epochId - b.epochId);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=yield-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yield-history.js","sourceRoot":"","sources":["../../src/domain/yield-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA4CH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,iBAAiB,CAC7B,KAA6B;IAE7B,MAAM,IAAI,GACN,KAAK,CAAC,aAAa,KAAK,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC;IAEzE,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACnC,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,CAAC;QAE3B,MAAM,KAAK,GACP,KAAK,CAAC,gBAAgB,KAAK,CAAC;YACxB,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,iBAAiB,CAAC;gBAC1C,KAAK,CAAC,iBAAiB,CAAC;gBAC5B,KAAK,CAAC,gBAAgB,CAAC;QAEjC,MAAM,QAAQ,GACV,KAAK,CAAC,UAAU,KAAK,CAAC;YAClB,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,CAAC,IAAI,GAAG,IAA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QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SAC3B,CAAC,CAAC;IACP,CAAC;IAED,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -12,6 +12,27 @@ const XDC_RPC_URLS = [
|
|
|
12
12
|
'https://rpc.xinfin.network',
|
|
13
13
|
'https://rpc.primenumbers.xyz/',
|
|
14
14
|
];
|
|
15
|
+
/**
|
|
16
|
+
* XDC RPCs that serve PAST state, for `getPoolTvlHistory` (each verified
|
|
17
|
+
* with `externalTVLOfPool` at old blocks, CORS `*`), in fallback order. Not
|
|
18
|
+
* `rpc.xdcrpc.com`, which refuses older blocks, and never `rpc.xdc.org` /
|
|
19
|
+
* `erpc.xdc.org`. Public and rate-limited.
|
|
20
|
+
*/
|
|
21
|
+
const XDC_HISTORY_RPC_URLS = [
|
|
22
|
+
'https://rpc.primenumbers.xyz/',
|
|
23
|
+
'https://rpc.ankr.com/xdc',
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Base RPCs that serve PAST state, in fallback order (each verified with
|
|
27
|
+
* `externalTVLOfPool` at old blocks; all answer CORS). Not
|
|
28
|
+
* `base-rpc.publicnode.com`, the default read RPC, which refuses old state.
|
|
29
|
+
* Public and rate-limited.
|
|
30
|
+
*/
|
|
31
|
+
const BASE_HISTORY_RPC_URLS = [
|
|
32
|
+
'https://mainnet.base.org',
|
|
33
|
+
'https://base.drpc.org',
|
|
34
|
+
'https://1rpc.io/base',
|
|
35
|
+
];
|
|
15
36
|
/**
|
|
16
37
|
* Built-in chain configurations for Kasu-supported networks.
|
|
17
38
|
*
|
|
@@ -55,6 +76,7 @@ export const CHAIN_CONFIGS = {
|
|
|
55
76
|
'https://base-rpc.publicnode.com',
|
|
56
77
|
'https://mainnet.base.org',
|
|
57
78
|
],
|
|
79
|
+
historyRpcUrls: BASE_HISTORY_RPC_URLS,
|
|
58
80
|
blockExplorerUrl: 'https://basescan.org',
|
|
59
81
|
},
|
|
60
82
|
xdc: {
|
|
@@ -91,6 +113,7 @@ export const CHAIN_CONFIGS = {
|
|
|
91
113
|
currencyCode: 'AUD',
|
|
92
114
|
},
|
|
93
115
|
rpcUrls: XDC_RPC_URLS,
|
|
116
|
+
historyRpcUrls: XDC_HISTORY_RPC_URLS,
|
|
94
117
|
blockExplorerUrl: 'https://xdcscan.com',
|
|
95
118
|
},
|
|
96
119
|
'xdc-usdc': {
|
|
@@ -123,6 +146,7 @@ export const CHAIN_CONFIGS = {
|
|
|
123
146
|
currencyCode: 'USD',
|
|
124
147
|
},
|
|
125
148
|
rpcUrls: XDC_RPC_URLS,
|
|
149
|
+
historyRpcUrls: XDC_HISTORY_RPC_URLS,
|
|
126
150
|
blockExplorerUrl: 'https://xdcscan.com',
|
|
127
151
|
},
|
|
128
152
|
plume: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-configs.js","sourceRoot":"","sources":["../../src/facade/chain-configs.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,YAAY,GAAa;IAC3B,0BAA0B;IAC1B,wBAAwB;IACxB,4BAA4B;IAC5B,+BAA+B;CAClC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAoE;IAC1F,IAAI,EAAE;QACF,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,cAAc;QACpB,gBAAgB,EAAE,KAAK;QACvB,SAAS,EAAE;YACP,QAAQ,EAAE,4CAA4C;YACtD,WAAW,EAAE,4CAA4C;YACzD,aAAa,EAAE,4CAA4C;YAC3D,kBAAkB,EAAE,4CAA4C;YAChE,WAAW,EAAE,4CAA4C;YACzD,aAAa,EAAE,4CAA4C;YAC3D,eAAe,EAAE,4CAA4C;YAC7D,QAAQ,EAAE,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;QACpE,iDAAiD;QACjD,WAAW,EACP,mGAAmG;QACvG,WAAW,EAAE,oCAAoC;QACjD,aAAa,EAAE,EAAE;QACjB,mBAAmB,EAAE,SAAS;QAC9B,WAAW,EAAE;YACT,OAAO,EAAE,4CAA4C;YACrD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,CAAC;YACX,YAAY,EAAE,KAAK;SACtB;QACD,mEAAmE;QACnE,+DAA+D;QAC/D,0DAA0D;QAC1D,iDAAiD;QACjD,OAAO,EAAE,EAAE;QACX,gDAAgD;QAChD,gBAAgB,EAAE,4BAA4B;QAC9C,OAAO,EAAE,IAAI;KAChB;CACJ,CAAC"}
|
package/dist/facade/kasu.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export declare class Kasu {
|
|
|
52
52
|
* of pools than the read-only one it came from.
|
|
53
53
|
*/
|
|
54
54
|
private readonly _configOverrides;
|
|
55
|
+
/** The caller's own history provider, kept so `connect` keeps it too. */
|
|
56
|
+
private readonly _historyProvider;
|
|
55
57
|
private constructor();
|
|
56
58
|
/**
|
|
57
59
|
* Create a Kasu instance with built-in chain config.
|
package/dist/facade/kasu.js
CHANGED
|
@@ -31,12 +31,13 @@ import { PortfolioFacade } from './user-portfolio';
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export class Kasu {
|
|
34
|
-
constructor(sdk, chainConfig, signerOrProvider, configOverrides) {
|
|
34
|
+
constructor(sdk, chainConfig, signerOrProvider, configOverrides, historyProvider) {
|
|
35
35
|
var _a, _b;
|
|
36
36
|
this._sdk = sdk;
|
|
37
37
|
this._chainConfig = chainConfig;
|
|
38
38
|
this._signerOrProvider = signerOrProvider;
|
|
39
39
|
this._configOverrides = configOverrides;
|
|
40
|
+
this._historyProvider = historyProvider;
|
|
40
41
|
this.strategies = new StrategiesFacade(sdk.DataService, sdk.UserLending, normaliseMapping((_a = configOverrides.poolMetadataMapping) !== null && _a !== void 0 ? _a : chainConfig.poolMetadataMapping));
|
|
41
42
|
// Derived ONCE and handed to every facade that needs it. Each of them
|
|
42
43
|
// re-deriving `Signer.isSigner` is how two facades come to disagree
|
|
@@ -74,7 +75,7 @@ export class Kasu {
|
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
77
|
static create(options) {
|
|
77
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
78
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
78
79
|
const chainConfig = resolveChainConfig(options.chain);
|
|
79
80
|
const overrides = (_a = options.configOverrides) !== null && _a !== void 0 ? _a : {};
|
|
80
81
|
const sdkConfig = new SdkConfig({
|
|
@@ -89,12 +90,18 @@ export class Kasu {
|
|
|
89
90
|
// of 6. Every live deployment happens to be 6dp today, so the
|
|
90
91
|
// default was right by luck; the next one need not be.
|
|
91
92
|
stableAssetDecimals: (_h = overrides.stableAssetDecimals) !== null && _h !== void 0 ? _h : (_j = stableAssetOf(chainConfig)) === null || _j === void 0 ? void 0 : _j.decimals,
|
|
93
|
+
historyRpcUrls: (_k = overrides.historyRpcUrls) !== null && _k !== void 0 ? _k : chainConfig.historyRpcUrls,
|
|
94
|
+
chainId: (_l = overrides.chainId) !== null && _l !== void 0 ? _l : chainConfig.chainId,
|
|
92
95
|
});
|
|
93
|
-
const signerOrProvider = (
|
|
96
|
+
const signerOrProvider = (_m = options.signerOrProvider) !== null && _m !== void 0 ? _m : defaultProvider(chainConfig, typeof options.chain === 'string'
|
|
94
97
|
? options.chain
|
|
95
98
|
: chainConfig.name);
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
// An explicit history provider wins; otherwise DataService builds
|
|
100
|
+
// them from `historyRpcUrls`, pinned to `chainId` (the one place).
|
|
101
|
+
const sdk = new KasuSdk(sdkConfig, signerOrProvider, {
|
|
102
|
+
historyProvider: options.historyProvider,
|
|
103
|
+
});
|
|
104
|
+
return new Kasu(sdk, chainConfig, signerOrProvider, overrides, options.historyProvider);
|
|
98
105
|
}
|
|
99
106
|
/**
|
|
100
107
|
* A NEW instance bound to `signer`, with the same chain config and the same
|
|
@@ -114,6 +121,7 @@ export class Kasu {
|
|
|
114
121
|
chain: this._chainConfig,
|
|
115
122
|
signerOrProvider: signer,
|
|
116
123
|
configOverrides: this._configOverrides,
|
|
124
|
+
historyProvider: this._historyProvider,
|
|
117
125
|
});
|
|
118
126
|
}
|
|
119
127
|
/**
|
package/dist/facade/kasu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kasu.js","sourceRoot":"","sources":["../../src/facade/kasu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,IAAI;
|
|
1
|
+
{"version":3,"file":"kasu.js","sourceRoot":"","sources":["../../src/facade/kasu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAo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C,CAAC,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CACX,uBAAuB,UAAU,uDAAuD,CAC3F,CAAC;IACN,CAAC;IACD,OAAO,IAAI,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,kBAAkB,CACvB,KAAwC;IAExC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,4EAA4E;AAC5E,SAAS,gBAAgB,CACrB,OAA2C;IAE3C,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { PoolTvlHistoryEntry } from '../domain/pool-tvl';
|
|
1
2
|
import { DataService } from '../services/DataService/data-service';
|
|
3
|
+
import { PoolTvlHistoryOptions } from '../services/DataService/tvl-history';
|
|
2
4
|
import { PoolDelegateProfileAndHistory } from '../services/DataService/types';
|
|
3
5
|
import { UserLending } from '../services/UserLending/user-lending';
|
|
4
6
|
import { DepositLimits, PlatformStats, Strategy, StrategyRiskPerformance, StrategyTranche } from './types';
|
|
@@ -84,6 +86,24 @@ export declare class StrategiesFacade {
|
|
|
84
86
|
* ```
|
|
85
87
|
*/
|
|
86
88
|
getPerformanceFeePercent(): Promise<number>;
|
|
89
|
+
/**
|
|
90
|
+
* The strategy's TVL (total lent by everyone) at every cycle boundary,
|
|
91
|
+
* then as of now — the data behind a TVL chart. Ascending in time; the
|
|
92
|
+
* last point (`kind: 'current'`) equals `strategy.tvl.total` when both
|
|
93
|
+
* calls' reads succeed (see `PoolTvlHistoryEntry`).
|
|
94
|
+
*
|
|
95
|
+
* `tvl` is in display units of the deployment's OWN stable token (USDC on
|
|
96
|
+
* Base and XDC USDC, AUDD on XDC AUDD); `timestamp` is unix SECONDS.
|
|
97
|
+
* `{ count }` = the newest `count` epochs, `{ fromEpoch }` = from that
|
|
98
|
+
* epoch on; `timeoutMs` (default 30 s) and `signal` bound the call. A
|
|
99
|
+
* malformed option throws before any network read. See
|
|
100
|
+
* `DataService.getPoolTvlHistory` for the reads, the cost and the errors.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* const points = await kasu.strategies.getPoolTvlHistory(poolId, { count: 52 });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
getPoolTvlHistory(poolId: string, options?: PoolTvlHistoryOptions): Promise<PoolTvlHistoryEntry[]>;
|
|
87
107
|
/**
|
|
88
108
|
* Fetch a single strategy by pool ID. Returns `null` if not found.
|
|
89
109
|
*/
|
|
@@ -131,6 +131,28 @@ export class StrategiesFacade {
|
|
|
131
131
|
return yield this._dataService.getPerformanceFee();
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* The strategy's TVL (total lent by everyone) at every cycle boundary,
|
|
136
|
+
* then as of now — the data behind a TVL chart. Ascending in time; the
|
|
137
|
+
* last point (`kind: 'current'`) equals `strategy.tvl.total` when both
|
|
138
|
+
* calls' reads succeed (see `PoolTvlHistoryEntry`).
|
|
139
|
+
*
|
|
140
|
+
* `tvl` is in display units of the deployment's OWN stable token (USDC on
|
|
141
|
+
* Base and XDC USDC, AUDD on XDC AUDD); `timestamp` is unix SECONDS.
|
|
142
|
+
* `{ count }` = the newest `count` epochs, `{ fromEpoch }` = from that
|
|
143
|
+
* epoch on; `timeoutMs` (default 30 s) and `signal` bound the call. A
|
|
144
|
+
* malformed option throws before any network read. See
|
|
145
|
+
* `DataService.getPoolTvlHistory` for the reads, the cost and the errors.
|
|
146
|
+
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* const points = await kasu.strategies.getPoolTvlHistory(poolId, { count: 52 });
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
getPoolTvlHistory(poolId_1) {
|
|
152
|
+
return __awaiter(this, arguments, void 0, function* (poolId, options = {}) {
|
|
153
|
+
return yield this._dataService.getPoolTvlHistory(poolId, options);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
134
156
|
/**
|
|
135
157
|
* Fetch a single strategy by pool ID. Returns `null` if not found.
|
|
136
158
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategies.js","sourceRoot":"","sources":["../../src/facade/strategies.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"strategies.js","sourceRoot":"","sources":["../../src/facade/strategies.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAkBlE;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IACzB,YACY,YAAyB,EACzB,YAAyB;IACjC;;;OAGG;IACK,uBAA+C,EAAE;QANjD,iBAAY,GAAZ,YAAY,CAAa;QACzB,iBAAY,GAAZ,YAAY,CAAa;QAKzB,yBAAoB,GAApB,oBAAoB,CAA6B;IAC1D,CAAC;IAEJ;;;;;;;;;;;;OAYG;IACG,kBAAkB,CACpB,MAAc;;YAEd,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC9C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC;YAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CACvB,CAAC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AK,QAAQ;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;QACrC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
package/dist/facade/types.d.ts
CHANGED
|
@@ -55,6 +55,16 @@ export interface ChainConfigEntry {
|
|
|
55
55
|
* Empty on a retired deployment, which has no read-only default.
|
|
56
56
|
*/
|
|
57
57
|
rpcUrls: string[];
|
|
58
|
+
/**
|
|
59
|
+
* RPCs that SERVE PAST STATE (archive nodes), tried IN ORDER on failure,
|
|
60
|
+
* used only by `getPoolTvlHistory` to read the off-chain TVL at old
|
|
61
|
+
* blocks. Pruned nodes refuse those reads — some answer as if the call
|
|
62
|
+
* reverted — so these are never `rpcUrls[0]` by assumption. Public and
|
|
63
|
+
* RATE-LIMITED: an integrator should pass its own archive
|
|
64
|
+
* `KasuOptions.historyProvider`, which wins over them. Absent on a
|
|
65
|
+
* retired deployment.
|
|
66
|
+
*/
|
|
67
|
+
historyRpcUrls?: string[];
|
|
58
68
|
/**
|
|
59
69
|
* Origin of the chain's block explorer, `https://…` with NO trailing
|
|
60
70
|
* slash (`https://basescan.org`). Never append a path to it by hand: build
|
|
@@ -83,6 +93,16 @@ export interface KasuOptions {
|
|
|
83
93
|
signerOrProvider?: import('ethers').Signer | import('@ethersproject/providers').Provider;
|
|
84
94
|
/** Override any default config value. */
|
|
85
95
|
configOverrides?: Partial<SdkConfigOptions>;
|
|
96
|
+
/**
|
|
97
|
+
* A provider that SERVES PAST STATE (an archive RPC), for
|
|
98
|
+
* `kasu.strategies.getPoolTvlHistory`. OPTIONAL: without one, the SDK
|
|
99
|
+
* builds one `StaticJsonRpcProvider` per
|
|
100
|
+
* `configOverrides.historyRpcUrls ?? chainConfig.historyRpcUrls` entry
|
|
101
|
+
* (tried in order, 10 s per call). The built-in URLs are public and
|
|
102
|
+
* rate-limited, so pass your own archive provider in production. Kept
|
|
103
|
+
* across `connect(signer)`.
|
|
104
|
+
*/
|
|
105
|
+
historyProvider?: import('@ethersproject/providers').Provider;
|
|
86
106
|
}
|
|
87
107
|
export interface Strategy {
|
|
88
108
|
id: string;
|