@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.
- package/README.md +28 -1
- package/dist/bundle.cjs.js +752 -59
- package/dist/bundle.esm.js +750 -60
- package/dist/domain/index.d.ts +10 -2
- package/dist/domain/index.js +6 -0
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/strategy-summary.d.ts +47 -0
- package/dist/domain/strategy-summary.js +76 -0
- package/dist/domain/strategy-summary.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/strategies.js +2 -0
- package/dist/facade/strategies.js.map +1 -1
- package/dist/facade/types.d.ts +13 -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 +1 -0
- package/dist/index.js.map +1 -1
- 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 +177 -0
- package/dist/services/Portfolio/yield-history.js +405 -0
- package/dist/services/Portfolio/yield-history.js.map +1 -0
- package/package.json +2 -1
- package/src/domain/index.ts +19 -10
- package/src/domain/strategy-summary.ts +88 -0
- package/src/domain/yield-history.ts +194 -0
- package/src/facade/strategies.ts +2 -0
- package/src/facade/types.ts +13 -0
- package/src/facade/user-portfolio.ts +40 -3
- package/src/index.ts +2 -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 +574 -0
package/dist/domain/index.d.ts
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* reconstructs byte-for-byte to verify a lender's signature. Those are not
|
|
17
17
|
* copy: nobody may reword them, in any language, without a matching backend
|
|
18
18
|
* change, which is exactly why they belong in one place.
|
|
19
|
+
*
|
|
20
|
+
* `pickShortDescription` returns a string but AUTHORS none: it selects and
|
|
21
|
+
* cleans editorial the CMS already holds, and an absent blurb is
|
|
22
|
+
* `undefined`, never a sentence of its own.
|
|
19
23
|
* 2. **Pure.** No network, no clock, no environment. Anything with I/O belongs
|
|
20
24
|
* in `facade/` (see `fetchUnusedPoolIds`).
|
|
21
25
|
*/
|
|
@@ -37,17 +41,21 @@ export type { ContractListItem, ContractSection, ContractType, ExemptLoanContrac
|
|
|
37
41
|
export { maxNetRateCeiling, pickHighestYieldTranche, poolMaxApy, selectVisiblePools, } from './pools';
|
|
38
42
|
export type { BestTranche } from './pools';
|
|
39
43
|
export { cancelDeadline, countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, lastEventTimestamp, submissionEvents, } from './requests';
|
|
40
|
-
export type { RequestKind, RequestState, RequestStatusCode
|
|
44
|
+
export type { RequestKind, RequestState, RequestStatusCode } from './requests';
|
|
41
45
|
export { decodeRevert, extractRevertData } from './revert-errors';
|
|
42
46
|
export type { DecodedRevert, RevertFamily } from './revert-errors';
|
|
43
47
|
export { CLEARING_WINDOW_SECONDS, computeSettlementWindow, deriveCycleDates, nextCycleBoundary, } from './settlement';
|
|
44
48
|
export type { CycleDates, SettlementWindowInput, SettlementWindowState, } from './settlement';
|
|
45
49
|
export { encodeCancelDepositCall, encodeCancelWithdrawalCall, encodeRequestWithdrawalCall, encodeStableTransfer, encodeWithdrawAtExpiryCall, SPONSORED_CALL_KINDS, SPONSORED_CALL_SELECTORS, SponsoredCallInputError, } from './sponsored-calls';
|
|
46
50
|
export type { SponsoredCall, SponsoredCallKind } from './sponsored-calls';
|
|
51
|
+
export { pickShortDescription } from './strategy-summary';
|
|
52
|
+
export type { ShortDescriptionSource } from './strategy-summary';
|
|
47
53
|
export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
|
|
48
54
|
export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
|
|
49
|
-
export type { ApyBounds, PoolStatus, TrancheCapacitySignal
|
|
55
|
+
export type { ApyBounds, PoolStatus, TrancheCapacitySignal } from './tranches';
|
|
50
56
|
export { classifyWalletFailure, isUnpredictableGas, isUserRejected, } from './wallet-errors';
|
|
51
57
|
export type { WalletFailure } from './wallet-errors';
|
|
58
|
+
export { aggregateYieldHistory, epochTrancheYield } from './yield-history';
|
|
59
|
+
export type { EpochLockShares, EpochTrancheYield, EpochTrancheYieldInput, YieldHistoryEntry, YieldHistoryFilter, YieldHistoryPoint, } from './yield-history';
|
|
52
60
|
export { accruedInterest, dailyInterest, projectedAnnualEarnings, SECONDS_PER_WEEK, weeklyInterest, weightedAverageApy, } from './yields';
|
|
53
61
|
export type { InterestSlice, PoolAccrual } from './yields';
|
package/dist/domain/index.js
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* reconstructs byte-for-byte to verify a lender's signature. Those are not
|
|
17
17
|
* copy: nobody may reword them, in any language, without a matching backend
|
|
18
18
|
* change, which is exactly why they belong in one place.
|
|
19
|
+
*
|
|
20
|
+
* `pickShortDescription` returns a string but AUTHORS none: it selects and
|
|
21
|
+
* cleans editorial the CMS already holds, and an absent blurb is
|
|
22
|
+
* `undefined`, never a sentence of its own.
|
|
19
23
|
* 2. **Pure.** No network, no clock, no environment. Anything with I/O belongs
|
|
20
24
|
* in `facade/` (see `fetchUnusedPoolIds`).
|
|
21
25
|
*/
|
|
@@ -32,8 +36,10 @@ export { cancelDeadline, countSubmissions, deriveRequestState, firstSubmissionTi
|
|
|
32
36
|
export { decodeRevert, extractRevertData } from './revert-errors';
|
|
33
37
|
export { CLEARING_WINDOW_SECONDS, computeSettlementWindow, deriveCycleDates, nextCycleBoundary, } from './settlement';
|
|
34
38
|
export { encodeCancelDepositCall, encodeCancelWithdrawalCall, encodeRequestWithdrawalCall, encodeStableTransfer, encodeWithdrawAtExpiryCall, SPONSORED_CALL_KINDS, SPONSORED_CALL_SELECTORS, SponsoredCallInputError, } from './sponsored-calls';
|
|
39
|
+
export { pickShortDescription } from './strategy-summary';
|
|
35
40
|
export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
|
|
36
41
|
export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
|
|
37
42
|
export { classifyWalletFailure, isUnpredictableGas, isUserRejected, } from './wallet-errors';
|
|
43
|
+
export { aggregateYieldHistory, epochTrancheYield } from './yield-history';
|
|
38
44
|
export { accruedInterest, dailyInterest, projectedAnnualEarnings, SECONDS_PER_WEEK, weeklyInterest, weightedAverageApy, } from './yields';
|
|
39
45
|
//# 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
|
|
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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,CAAC;AAG1D,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EACH,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAU3E,OAAO,EACH,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACrB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A strategy's SHORT blurb, as plain text: the CMS `liteDescription` first,
|
|
3
|
+
* else the first paragraph of the long `description`, else nothing.
|
|
4
|
+
*
|
|
5
|
+
* Lifted from kasu-ui (`pickShortDescription`, its deposit dialog and landing
|
|
6
|
+
* strategy card) so every app shows the same line, and pinned to its output
|
|
7
|
+
* for every live CMS row. The rules are facts about how the CMS is authored,
|
|
8
|
+
* not formatting preferences:
|
|
9
|
+
*
|
|
10
|
+
* - `liteDescription` IS THE SHORT ONE. `description` is the credit
|
|
11
|
+
* originator's several-paragraph profile; on a card it is a wall.
|
|
12
|
+
* - `"Not Available"` IS A PLACEHOLDER, not editorial. Several rows carry it
|
|
13
|
+
* verbatim, and it must read as missing, not print. Matched on the whole
|
|
14
|
+
* trimmed value, case-insensitively. It applies to `liteDescription` only.
|
|
15
|
+
* - EMPTY OR BLANK IS MISSING. The service maps a pool with no CMS record to
|
|
16
|
+
* `''`.
|
|
17
|
+
* - THE FIELDS HOLD MARKDOWN. `liteDescription` can open with a `**bold**`
|
|
18
|
+
* lead, and the surfaces this feeds render plain text, so the markers are
|
|
19
|
+
* stripped (bold, then italic, then inline code).
|
|
20
|
+
* - AND HARD NEWLINES. Every run of whitespace becomes one space, so a
|
|
21
|
+
* paragraph break inside the value is not a gap in a one-line slot.
|
|
22
|
+
* - NOT SANITISED. "Plain text" means text to render AS text. HTML tags,
|
|
23
|
+
* entities and link syntax (`<script>`, `<`, `[a](javascript:…)`) pass
|
|
24
|
+
* through unchanged, and removing markers can join fragments into a tag
|
|
25
|
+
* (`<scr**i**pt>` becomes `<script>`). Render it as a text node, never as
|
|
26
|
+
* HTML or markdown.
|
|
27
|
+
*
|
|
28
|
+
* Two refinements over the kasu-ui original, neither reachable by any live
|
|
29
|
+
* row: the cleaned text is trimmed (a CRLF value no longer ends in a space),
|
|
30
|
+
* and a `liteDescription` that cleans to nothing (`** **`) counts as missing,
|
|
31
|
+
* so the result is never a blank string.
|
|
32
|
+
*
|
|
33
|
+
* This authors no string of its own. It selects and cleans editorial the CMS
|
|
34
|
+
* already holds, and an absent blurb is `undefined`, never a fallback sentence:
|
|
35
|
+
* what "no blurb" means is the render site's decision.
|
|
36
|
+
*
|
|
37
|
+
* Pure. A value that is not a string reads as missing.
|
|
38
|
+
*/
|
|
39
|
+
export declare function pickShortDescription(source: ShortDescriptionSource): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The two CMS fields `pickShortDescription` reads. A `PoolOverview` and a
|
|
42
|
+
* facade `Strategy` both satisfy it.
|
|
43
|
+
*/
|
|
44
|
+
export interface ShortDescriptionSource {
|
|
45
|
+
liteDescription?: string | null;
|
|
46
|
+
description?: string | null;
|
|
47
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A strategy's SHORT blurb, as plain text: the CMS `liteDescription` first,
|
|
3
|
+
* else the first paragraph of the long `description`, else nothing.
|
|
4
|
+
*
|
|
5
|
+
* Lifted from kasu-ui (`pickShortDescription`, its deposit dialog and landing
|
|
6
|
+
* strategy card) so every app shows the same line, and pinned to its output
|
|
7
|
+
* for every live CMS row. The rules are facts about how the CMS is authored,
|
|
8
|
+
* not formatting preferences:
|
|
9
|
+
*
|
|
10
|
+
* - `liteDescription` IS THE SHORT ONE. `description` is the credit
|
|
11
|
+
* originator's several-paragraph profile; on a card it is a wall.
|
|
12
|
+
* - `"Not Available"` IS A PLACEHOLDER, not editorial. Several rows carry it
|
|
13
|
+
* verbatim, and it must read as missing, not print. Matched on the whole
|
|
14
|
+
* trimmed value, case-insensitively. It applies to `liteDescription` only.
|
|
15
|
+
* - EMPTY OR BLANK IS MISSING. The service maps a pool with no CMS record to
|
|
16
|
+
* `''`.
|
|
17
|
+
* - THE FIELDS HOLD MARKDOWN. `liteDescription` can open with a `**bold**`
|
|
18
|
+
* lead, and the surfaces this feeds render plain text, so the markers are
|
|
19
|
+
* stripped (bold, then italic, then inline code).
|
|
20
|
+
* - AND HARD NEWLINES. Every run of whitespace becomes one space, so a
|
|
21
|
+
* paragraph break inside the value is not a gap in a one-line slot.
|
|
22
|
+
* - NOT SANITISED. "Plain text" means text to render AS text. HTML tags,
|
|
23
|
+
* entities and link syntax (`<script>`, `<`, `[a](javascript:…)`) pass
|
|
24
|
+
* through unchanged, and removing markers can join fragments into a tag
|
|
25
|
+
* (`<scr**i**pt>` becomes `<script>`). Render it as a text node, never as
|
|
26
|
+
* HTML or markdown.
|
|
27
|
+
*
|
|
28
|
+
* Two refinements over the kasu-ui original, neither reachable by any live
|
|
29
|
+
* row: the cleaned text is trimmed (a CRLF value no longer ends in a space),
|
|
30
|
+
* and a `liteDescription` that cleans to nothing (`** **`) counts as missing,
|
|
31
|
+
* so the result is never a blank string.
|
|
32
|
+
*
|
|
33
|
+
* This authors no string of its own. It selects and cleans editorial the CMS
|
|
34
|
+
* already holds, and an absent blurb is `undefined`, never a fallback sentence:
|
|
35
|
+
* what "no blurb" means is the render site's decision.
|
|
36
|
+
*
|
|
37
|
+
* Pure. A value that is not a string reads as missing.
|
|
38
|
+
*/
|
|
39
|
+
export function pickShortDescription(source) {
|
|
40
|
+
var _a;
|
|
41
|
+
const lite = asTrimmed(source.liteDescription);
|
|
42
|
+
if (lite && !NOT_AVAILABLE.test(lite)) {
|
|
43
|
+
const summary = toOneLine(lite);
|
|
44
|
+
if (summary)
|
|
45
|
+
return summary;
|
|
46
|
+
}
|
|
47
|
+
const long = asTrimmed(source.description);
|
|
48
|
+
if (long) {
|
|
49
|
+
const firstParagraph = (_a = long.split(PARAGRAPH_BREAK, 1)[0]) !== null && _a !== void 0 ? _a : long;
|
|
50
|
+
return toOneLine(firstParagraph) || undefined;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const NOT_AVAILABLE = /^not available$/i;
|
|
55
|
+
const PARAGRAPH_BREAK = /\n\s*\n/;
|
|
56
|
+
function asTrimmed(value) {
|
|
57
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
58
|
+
}
|
|
59
|
+
/** Markers off, whitespace runs to one space, ends trimmed. `''` when nothing is left. */
|
|
60
|
+
function toOneLine(text) {
|
|
61
|
+
return stripInlineMarkdown(text).replace(/\s+/gu, ' ').trim();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Inline markdown markers off, in the order bold → italic → code. The bold
|
|
65
|
+
* passes consume every `**` / `__` pair first, so the italic patterns can match
|
|
66
|
+
* a lone `*` / `_` without lookarounds.
|
|
67
|
+
*/
|
|
68
|
+
function stripInlineMarkdown(input) {
|
|
69
|
+
return input
|
|
70
|
+
.replace(/\*\*(.+?)\*\*/g, '$1')
|
|
71
|
+
.replace(/__(.+?)__/g, '$1')
|
|
72
|
+
.replace(/\*(.+?)\*/g, '$1')
|
|
73
|
+
.replace(/_(.+?)_/g, '$1')
|
|
74
|
+
.replace(/`([^`]+)`/g, '$1');
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=strategy-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-summary.js","sourceRoot":"","sources":["../../src/domain/strategy-summary.ts"],"names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,YAAY,EAAE,IAAI,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC;SACzB,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACrC,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,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ClD,MAAM,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;IAErD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;YAChE,SAAS;QACb,CAAC;QACD,IACI,SAAS,KAAK,SAAS;YACvB,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,SAAS,EAC7C,CAAC;YACC,SAAS;QACb,CAAC;QAED,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,KAAK,EAAE,CAAC;YACR,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC;YACjC,SAAS;QACb,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE;YACvB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,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"}
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { selectVisiblePools } from '../domain/pools';
|
|
11
|
+
import { pickShortDescription } from '../domain/strategy-summary';
|
|
11
12
|
/**
|
|
12
13
|
* High-level facade for browsing Kasu lending strategies (pools).
|
|
13
14
|
*
|
|
@@ -194,6 +195,7 @@ export class StrategiesFacade {
|
|
|
194
195
|
subheading: nonEmptyOrUndefined(pool.subheading),
|
|
195
196
|
description: pool.description,
|
|
196
197
|
liteDescription: nonEmptyOrUndefined(pool.liteDescription),
|
|
198
|
+
summary: pickShortDescription(pool),
|
|
197
199
|
isActive: pool.isActive,
|
|
198
200
|
apy: pool.apy,
|
|
199
201
|
tvl: pool.totalValueLocked,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategies.js","sourceRoot":"","sources":["../../src/facade/strategies.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"strategies.js","sourceRoot":"","sources":["../../src/facade/strategies.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAiBlE;;;;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,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,KAAK,UAAU,CACzD,CAAC;YACF,IAAI,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAC;YACzB,MAAM,WAAW,GAAG,MAAM,CAAC,eAGZ,CAAC;YAChB,OAAO;gBACH,YAAY,E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;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
package/dist/facade/types.d.ts
CHANGED
|
@@ -98,6 +98,19 @@ export interface Strategy {
|
|
|
98
98
|
* Absent when the record has none, or an empty one.
|
|
99
99
|
*/
|
|
100
100
|
liteDescription?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The strategy's short blurb as ONE line of plain text, for cards and
|
|
103
|
+
* compact surfaces: `liteDescription` when it is usable, else the first
|
|
104
|
+
* paragraph of `description`, with inline markdown markers stripped and
|
|
105
|
+
* every run of whitespace collapsed to one space. The `"Not Available"`
|
|
106
|
+
* placeholder, an empty or blank value, and a missing one all count as
|
|
107
|
+
* absent. `undefined` when neither field yields a blurb; the SDK never
|
|
108
|
+
* substitutes a sentence of its own. See `pickShortDescription`.
|
|
109
|
+
*
|
|
110
|
+
* Not sanitised: HTML tags and link syntax pass through unchanged. Render
|
|
111
|
+
* it as text, never as HTML or markdown.
|
|
112
|
+
*/
|
|
113
|
+
summary?: string;
|
|
101
114
|
isActive: boolean;
|
|
102
115
|
/** Weighted-average APY across tranches (decimal, e.g. 0.08 = 8 %). */
|
|
103
116
|
apy: number;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Provider } from '@ethersproject/providers';
|
|
2
2
|
import { RequestState } from '../domain/requests';
|
|
3
|
+
import { YieldHistoryEntry } from '../domain/yield-history';
|
|
3
4
|
import { DataService } from '../services/DataService/data-service';
|
|
4
5
|
import { Portfolio } from '../services/Portfolio/portfolio';
|
|
6
|
+
import { YieldHistoryOptions } from '../services/Portfolio/yield-history';
|
|
5
7
|
import { UserRequest } from '../services/UserLending/types';
|
|
6
8
|
import { UserLending } from '../services/UserLending/user-lending';
|
|
7
9
|
import { UserPositions } from './types';
|
|
@@ -29,6 +31,36 @@ export declare class PortfolioFacade {
|
|
|
29
31
|
* SDK was initialised with a Signer but you need a read-only provider).
|
|
30
32
|
*/
|
|
31
33
|
getPositions(userAddress: string, provider?: Provider): Promise<UserPositions>;
|
|
34
|
+
/**
|
|
35
|
+
* The lender's settled yield per cycle, per pool and tranche: what each
|
|
36
|
+
* close credited them, NET of the performance fee (the chain credits it
|
|
37
|
+
* net), in display units of the deployment's own stable token (AUDD on
|
|
38
|
+
* XDC AUDD). `epochEnd` is unix seconds. Net only — no gross is offered.
|
|
39
|
+
*
|
|
40
|
+
* Validates `options` before any read (`RangeError` on a malformed one).
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* const entries = await kasu.portfolio.getYieldHistory('0xUser...', { count: 52 });
|
|
44
|
+
* const allStrategies = aggregateYieldHistory(entries);
|
|
45
|
+
* const oneStrategy = aggregateYieldHistory(entries, { poolId });
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* `getPositions`' `totalYieldEarningsLastEpoch` for a pool equals that
|
|
49
|
+
* pool's bar for the epoch of its most recently APPLIED interest — which
|
|
50
|
+
* is older than the last cycle for a pool that has not cleared since (the
|
|
51
|
+
* bar carries that older `epochId`). A lender who held nothing at that
|
|
52
|
+
* epoch has no bar there and a figure of 0; their newest bar is from
|
|
53
|
+
* when they last held shares.
|
|
54
|
+
*
|
|
55
|
+
* For a fixed-term lock holder the bars can sum to slightly more than the
|
|
56
|
+
* lifetime interest (up to about 0.2 %), because each top-up is valued at
|
|
57
|
+
* today's share price — show "earned to date" from the lifetime figure,
|
|
58
|
+
* never from the sum of the bars.
|
|
59
|
+
*
|
|
60
|
+
* `[]` for a lender with no history, and on a LITE deployment whose
|
|
61
|
+
* subgraph lacks the entities; on a full deployment that error throws.
|
|
62
|
+
*/
|
|
63
|
+
getYieldHistory(userAddress: string, options?: YieldHistoryOptions): Promise<YieldHistoryEntry[]>;
|
|
32
64
|
/**
|
|
33
65
|
* Fetch a user's full transaction history (deposits, withdrawals, cancellations).
|
|
34
66
|
*/
|
|
@@ -41,6 +41,40 @@ export class PortfolioFacade {
|
|
|
41
41
|
return { pools, summary };
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* The lender's settled yield per cycle, per pool and tranche: what each
|
|
46
|
+
* close credited them, NET of the performance fee (the chain credits it
|
|
47
|
+
* net), in display units of the deployment's own stable token (AUDD on
|
|
48
|
+
* XDC AUDD). `epochEnd` is unix seconds. Net only — no gross is offered.
|
|
49
|
+
*
|
|
50
|
+
* Validates `options` before any read (`RangeError` on a malformed one).
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* const entries = await kasu.portfolio.getYieldHistory('0xUser...', { count: 52 });
|
|
54
|
+
* const allStrategies = aggregateYieldHistory(entries);
|
|
55
|
+
* const oneStrategy = aggregateYieldHistory(entries, { poolId });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* `getPositions`' `totalYieldEarningsLastEpoch` for a pool equals that
|
|
59
|
+
* pool's bar for the epoch of its most recently APPLIED interest — which
|
|
60
|
+
* is older than the last cycle for a pool that has not cleared since (the
|
|
61
|
+
* bar carries that older `epochId`). A lender who held nothing at that
|
|
62
|
+
* epoch has no bar there and a figure of 0; their newest bar is from
|
|
63
|
+
* when they last held shares.
|
|
64
|
+
*
|
|
65
|
+
* For a fixed-term lock holder the bars can sum to slightly more than the
|
|
66
|
+
* lifetime interest (up to about 0.2 %), because each top-up is valued at
|
|
67
|
+
* today's share price — show "earned to date" from the lifetime figure,
|
|
68
|
+
* never from the sum of the bars.
|
|
69
|
+
*
|
|
70
|
+
* `[]` for a lender with no history, and on a LITE deployment whose
|
|
71
|
+
* subgraph lacks the entities; on a full deployment that error throws.
|
|
72
|
+
*/
|
|
73
|
+
getYieldHistory(userAddress, options) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
return yield this._portfolio.getYieldHistory(userAddress, options);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
44
78
|
/**
|
|
45
79
|
* Fetch a user's full transaction history (deposits, withdrawals, cancellations).
|
|
46
80
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-portfolio.js","sourceRoot":"","sources":["../../src/facade/user-portfolio.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"user-portfolio.js","sourceRoot":"","sources":["../../src/facade/user-portfolio.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,oBAAoB,CAAC;AAUtE;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACxB,YACY,YAAyB,EACzB,YAAyB,EACzB,UAAqB;QAFrB,iBAAY,GAAZ,YAAY,CAAa;QACzB,iBAAY,GAAZ,YAAY,CAAa;QACzB,eAAU,GAAV,UAAU,CAAW;IAC9B,CAAC;IAEJ;;;;;;;;;;;OAWG;IACG,YAAY,CACd,WAAmB,EACnB,QAAmB;;YAEnB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;YAE/D,MAAM,aAAa,GACf,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE1D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,uBAAuB,CACvD,WAAW,EACX,aAAa,EACb,YAAY,EACZ,QAAQ,CACX,CAAC;YAEF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CACrD,WAAW,EACX,KAAK,EACL,YAAY,CACf,CAAC;YAEF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAC9B,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,eAAe,CACjB,WAAmB,EACnB,OAA6B;;YAE7B,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACvE,CAAC;KAAA;IAED;;OAEG;IACG,qBAAqB,CACvB,WAA0B;;YAE1B,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;YAC/D,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CAC1C,WAAW,EACX,YAAY,CACf,CAAC;QACN,CAAC;KAAA;IAED;;;;;;;;;;;;;;;OAeG;IACG,gBAAgB,CAClB,WAA0B;;YAE1B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;YAC/D,OAAO,QAAQ,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAC5C,CAAC;KAAA;CACJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { SdkConfig } from './sdk-config';
|
|
|
4
4
|
export type { PoolOverview, TrancheData, LendingTotals, PoolRepayment, RiskManagement, PoolDelegateProfileAndHistory, PoolTranche, PoolCreditMetrics, BadAndDoubtfulDebts, FinancialReportingDocuments, } from './services/DataService/types';
|
|
5
5
|
export type { UserRequest, UserRequestEvent, UserTrancheBalance, UserPoolBalance, UserApyBonus, PortfolioUserTrancheBalance, } from './services/UserLending/types';
|
|
6
6
|
export type { PortfolioSummary, PortfolioLendingPool, PortfolioTranche, PortfolioRewards, PortfolioTrancheDepositDetails, } from './services/Portfolio/types';
|
|
7
|
+
export type { YieldHistoryOptions } from './services/Portfolio/yield-history';
|
|
7
8
|
export type { UserLock, UserBonusData, LockPeriod, GQLGetLockingPeriods, SystemVariables, } from './services/Locking/types';
|
|
8
9
|
export type { PoolOverviewDirectus, PlatformOverviewDirectus, } from './services/DataService/directus-types';
|
|
9
10
|
export { NO_DIRECTUS_URL_MESSAGE } from './services/DataService/directus-client';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,4CAA4C;AAC5C,8EAA8E;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,4CAA4C;AAC5C,8EAA8E;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAkDzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,8EAA8E;AAC9E,+CAA+C;AAC/C,8EAA8E;AAC9E,cAAc,UAAU,CAAC;AAEzB,8EAA8E;AAC9E,6EAA6E;AAC7E,uDAAuD;AACvD,8EAA8E;AAC9E,cAAc,UAAU,CAAC;AAEzB,8EAA8E;AAC9E,6EAA6E;AAC7E,uEAAuE;AACvE,wDAAwD;AACxD,8EAA8E;AAC9E,cAAc,SAAS,CAAC"}
|