@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.
- package/README.md +26 -1
- package/dist/bundle.cjs.js +974 -83
- package/dist/bundle.esm.js +971 -85
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.js +1 -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/requests.d.ts +11 -10
- 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/index.d.ts +4 -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/yield-history.d.ts +1 -16
- package/dist/services/Portfolio/yield-history.js +2 -29
- package/dist/services/Portfolio/yield-history.js.map +1 -1
- package/dist/services/UserLending/subgraph-types.d.ts +2 -8
- package/dist/services/UserLending/types.d.ts +10 -0
- package/dist/services/UserLending/user-lending.d.ts +14 -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 +3 -0
- package/src/domain/pool-tvl.ts +66 -0
- package/src/domain/requests.ts +37 -23
- 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/index.ts +9 -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/yield-history.ts +2 -35
- package/src/services/UserLending/queries.ts +2 -7
- package/src/services/UserLending/subgraph-types.ts +2 -8
- package/src/services/UserLending/types.ts +10 -0
- package/src/services/UserLending/user-lending.ts +98 -40
- package/src/services/shared.ts +38 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yield-history.js","sourceRoot":"","sources":["../../../src/services/Portfolio/yield-history.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,OAAO,EAEH,iBAAiB,GAEpB,MAAM,4BAA4B,CAAC;AAyBpC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACvC,OAA4B;IAE5B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACrC,IACI,SAAS,KAAK,SAAS;QACvB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,EACrD,CAAC;QACC,MAAM,IAAI,UAAU,CAChB,kEAAkE,MAAM,CAAC,SAAS,CAAC,EAAE,CACxF,CAAC;IACN,CAAC;IACD,IAAI,KAAK,KAAK,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,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,0CAC5B,MAAM,mCAAI,IAAI,CAAC,oBAAoB,CAC5C;qBACJ,CAAC;gBACN,CAAC,CACJ,CAAC;gBAEN,MAAM,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC;oBAChC,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,mBAAmB,CAAC;oBACrD,UAAU;oBACV,aAAa,EAAE,UAAU,CACrB,MAAA,MAAA,UAAU,CAAC,cAAc,EAAE,KAAK,CAAC,0CAAE,MAAM,mCAAI,GAAG,CACnD;oBACD,iBAAiB;oBACjB,gBAAgB;oBAChB,KAAK;iBACR,CAAC,CAAC;gBAEH,uDAAuD;gBACvD,sDAAsD;gBACtD,IAAI,UAAU,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC;oBAAE,SAAS;gBAE7C,OAAO,CAAC,IAAI,CAAC;oBACT,OAAO,EAAE,KAAK;oBACd,QAAQ,EACJ,KAAK,CAAC,cAAc;wBACpB,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa;oBACrC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE;oBAC3B,SAAS;oBACT,QAAQ,EAAE,KAAK;iBAClB,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CACf,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;QACrB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;QAChC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAC7C,CAAC;AACN,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"yield-history.js","sourceRoot":"","sources":["../../../src/services/Portfolio/yield-history.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAi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MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE;oBAC3B,SAAS;oBACT,QAAQ,EAAE,KAAK;iBAClB,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CACf,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;QACrB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;QAChC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAC7C,CAAC;AACN,CAAC;AAED,4EAA4E;AAC5E,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -69,8 +69,6 @@ export interface CurrentEpochFtdAmountSubgraph {
|
|
|
69
69
|
amountRequested: string;
|
|
70
70
|
tranche: {
|
|
71
71
|
id: string;
|
|
72
|
-
balance: string;
|
|
73
|
-
shares: string;
|
|
74
72
|
};
|
|
75
73
|
}[];
|
|
76
74
|
}
|
|
@@ -135,13 +133,9 @@ export interface CurrentFtdBalanceSubgraph {
|
|
|
135
133
|
configId: string;
|
|
136
134
|
lendingPoolTranche: {
|
|
137
135
|
id: string;
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
lendingPool: {
|
|
141
|
-
balance: string;
|
|
142
|
-
tranches: {
|
|
136
|
+
balance: string;
|
|
143
137
|
shares: string;
|
|
144
|
-
}
|
|
138
|
+
};
|
|
145
139
|
};
|
|
146
140
|
}[];
|
|
147
141
|
}
|
|
@@ -36,8 +36,18 @@ export interface UserRequest {
|
|
|
36
36
|
requestType: 'Deposit' | 'Withdrawal';
|
|
37
37
|
trancheId: string;
|
|
38
38
|
trancheName: string;
|
|
39
|
+
/**
|
|
40
|
+
* The amount still OUTSTANDING on the request, in assets (the
|
|
41
|
+
* deployment's stable token, display units) — not the amount first asked
|
|
42
|
+
* for: the subgraph takes accepted and rejected amounts off it, and a
|
|
43
|
+
* cancellation zeroes it. A deposit's figure is the asset amount as the
|
|
44
|
+
* subgraph holds it (top-ups included); a withdrawal's is its remaining
|
|
45
|
+
* tranche shares at the tranche's current share price.
|
|
46
|
+
*/
|
|
39
47
|
requestedAmount: string;
|
|
48
|
+
/** Assets accepted so far — deposited, or paid out for a withdrawal. */
|
|
40
49
|
acceptedAmount: string;
|
|
50
|
+
/** Assets rejected and returned — deposits only; 0 for a withdrawal. */
|
|
41
51
|
rejectedAmount: string;
|
|
42
52
|
timestamp: EpochTimeStamp;
|
|
43
53
|
status: UserRequestStatus;
|
|
@@ -3,6 +3,8 @@ import { BigNumber, BigNumberish, BytesLike, ContractTransaction, Signer } from
|
|
|
3
3
|
import { IKasuAllowListAbi__factory } from '../../contracts';
|
|
4
4
|
import { SdkConfig } from '../../sdk-config';
|
|
5
5
|
import { PortfolioUserTrancheBalance, UserApyBonus, UserPoolBalance, UserRequest, UserTrancheBalance } from './types';
|
|
6
|
+
/** Thrown when the subgraph reports a request type with no known unit. */
|
|
7
|
+
export declare const UNKNOWN_REQUEST_TYPE_MESSAGE = "UserLending: unknown request type, its amount unit is unknown";
|
|
6
8
|
export declare class UserLending {
|
|
7
9
|
private _kasuConfig;
|
|
8
10
|
private readonly _graph;
|
|
@@ -60,6 +62,18 @@ export declare class UserLending {
|
|
|
60
62
|
getCurrentFtdBalance(poolId: string, userId: string): Promise<Map<string, number[]>>;
|
|
61
63
|
getCurrentEpochFtdAmount(poolIds: string[], userId: string, currentEpoch: string): Promise<Map<string, string[]>>;
|
|
62
64
|
getCurrentEpochDepositedAmount(lendingPoolIds: string[], userId: string): Promise<Map<string, string>>;
|
|
65
|
+
/**
|
|
66
|
+
* A request's outstanding amount in ASSETS (the deployment's stable token).
|
|
67
|
+
*
|
|
68
|
+
* The subgraph's `UserRequest.amountRequested` is denominated by request
|
|
69
|
+
* type. A DEPOSIT request holds assets: the deposit NFT's `assetAmount`,
|
|
70
|
+
* top-ups added, accepted and rejected amounts taken off. A WITHDRAWAL
|
|
71
|
+
* request holds tranche SHARES: the withdrawal NFT's `sharesAmount`,
|
|
72
|
+
* accepted shares taken off. So only a withdrawal is converted, at the
|
|
73
|
+
* tranche's current share price; a deposit passes through unchanged —
|
|
74
|
+
* pricing it as shares overstated it by the share price.
|
|
75
|
+
*/
|
|
76
|
+
private requestedAmountInAssets;
|
|
63
77
|
convertSharesToAssets(sharesAmount: string, totalAssets: string, totalSupply: string): string;
|
|
64
78
|
isClearingPending(poolId: string): Promise<boolean>;
|
|
65
79
|
isCancelable(status: string, lendingPoolId: string): Promise<boolean>;
|
|
@@ -1 +1,17 @@
|
|
|
1
1
|
export declare function filterArray<T>(array: T[], id_in?: string[]): T[];
|
|
2
|
+
/**
|
|
3
|
+
* A GraphQL VALIDATION error naming an entity, field or argument this
|
|
4
|
+
* deployment's subgraph does not have. A network error, a timeout or an
|
|
5
|
+
* indexing error is not one.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isMissingEntityError(error: unknown): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The only failure a history read (`getYieldHistory`, `getPoolTvlHistory`)
|
|
10
|
+
* turns into `[]`: a missing-schema error
|
|
11
|
+
* on a LITE deployment, whose subgraph may predate the entities. On a full
|
|
12
|
+
* deployment the entities are part of the schema, so the same error means a
|
|
13
|
+
* broken query or subgraph and THROWS — an empty chart there would hide it.
|
|
14
|
+
* Everything else (network, timeout, indexing) throws on every deployment, so
|
|
15
|
+
* a consumer can tell "no history here" from "history unavailable".
|
|
16
|
+
*/
|
|
17
|
+
export declare function isEmptyHistoryError(error: unknown, liteDeployment: boolean): boolean;
|
package/dist/services/shared.js
CHANGED
|
@@ -9,4 +9,34 @@ export function filterArray(array, id_in) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* A GraphQL VALIDATION error naming an entity, field or argument this
|
|
14
|
+
* deployment's subgraph does not have. A network error, a timeout or an
|
|
15
|
+
* indexing error is not one.
|
|
16
|
+
*/
|
|
17
|
+
export function isMissingEntityError(error) {
|
|
18
|
+
if (typeof error !== 'object' || error === null)
|
|
19
|
+
return false;
|
|
20
|
+
const response = error.response;
|
|
21
|
+
const errors = response === null || response === void 0 ? void 0 : response.errors;
|
|
22
|
+
if (!Array.isArray(errors) || errors.length === 0)
|
|
23
|
+
return false;
|
|
24
|
+
return errors.every((e) => {
|
|
25
|
+
const message = e === null || e === void 0 ? void 0 : e.message;
|
|
26
|
+
return (typeof message === 'string' &&
|
|
27
|
+
/has no field|cannot query field|unknown (type|field|argument)|no such (type|field)/i.test(message));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The only failure a history read (`getYieldHistory`, `getPoolTvlHistory`)
|
|
32
|
+
* turns into `[]`: a missing-schema error
|
|
33
|
+
* on a LITE deployment, whose subgraph may predate the entities. On a full
|
|
34
|
+
* deployment the entities are part of the schema, so the same error means a
|
|
35
|
+
* broken query or subgraph and THROWS — an empty chart there would hide it.
|
|
36
|
+
* Everything else (network, timeout, indexing) throws on every deployment, so
|
|
37
|
+
* a consumer can tell "no history here" from "history unavailable".
|
|
38
|
+
*/
|
|
39
|
+
export function isEmptyHistoryError(error, liteDeployment) {
|
|
40
|
+
return liteDeployment && isMissingEntityError(error);
|
|
41
|
+
}
|
|
12
42
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAI,KAAU,EAAE,KAAgB;IACvD,IAAG,CAAC,KAAK,EAAC,CAAC;QACP,OAAO,KAAK,CAAC;IACjB,CAAC;SACG,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACvB,MAAM,EAAE,EAAE,EAAE,GAAG,IAAsB,CAAC;YACtC,OAAO,KAAK,CAAC,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c,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC"}
|
package/package.json
CHANGED
package/src/domain/index.ts
CHANGED
|
@@ -188,6 +188,9 @@ export {
|
|
|
188
188
|
} from './wallet-errors';
|
|
189
189
|
export type { WalletFailure } from './wallet-errors';
|
|
190
190
|
|
|
191
|
+
export { poolTvl } from './pool-tvl';
|
|
192
|
+
export type { PoolTvlHistoryEntry } from './pool-tvl';
|
|
193
|
+
|
|
191
194
|
export { aggregateYieldHistory, epochTrancheYield } from './yield-history';
|
|
192
195
|
export type {
|
|
193
196
|
EpochLockShares,
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* The ONE definition of a pool's TVL: what lenders have lent on chain
|
|
8
|
+
* (`lendingPool.balance` in the subgraph) plus the off-chain amount the
|
|
9
|
+
* pool's `ExternalTVL` contract records (`externalTVLOfPool`).
|
|
10
|
+
*
|
|
11
|
+
* Both inputs, and the result, are in DISPLAY units of the deployment's own
|
|
12
|
+
* stable token (USDC on Base and XDC USDC, AUDD on XDC AUDD) — `'1.5'` is
|
|
13
|
+
* one and a half tokens, not 1.5 minor units. Convert before formatting as
|
|
14
|
+
* USD.
|
|
15
|
+
*
|
|
16
|
+
* `getPoolOverview` (its `totalValueLocked.total`) and `getPoolTvlHistory`
|
|
17
|
+
* (every point) both call this, so the chart and the figure above it cannot
|
|
18
|
+
* be computed two ways.
|
|
19
|
+
*/
|
|
20
|
+
export function poolTvl(onChainBalance: string, offChainTvl: string): number {
|
|
21
|
+
return parseFloat(onChainBalance) + parseFloat(offChainTvl);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One point of a pool's TVL history.
|
|
26
|
+
*
|
|
27
|
+
* - `kind: 'clearing'` — the TVL as it stood at the end of the block in which
|
|
28
|
+
* that epoch's clearing finished (`LendingPoolClearing.endBlockNumber`):
|
|
29
|
+
* accepted deposits and withdrawals and the applied interest included.
|
|
30
|
+
* - `kind: 'current'` — the closing "as of now" point, from two sources: the
|
|
31
|
+
* subgraph's latest balance (and its latest block time) and
|
|
32
|
+
* `externalTVLOfPool` at `latest` on the history provider. It equals
|
|
33
|
+
* today's `PoolOverview.totalValueLocked.total` when both that call's reads
|
|
34
|
+
* and these succeed; `getPoolOverview` falls back to an off-chain 0 when its
|
|
35
|
+
* own read fails, and the figure can move between the two calls.
|
|
36
|
+
*/
|
|
37
|
+
export interface PoolTvlHistoryEntry {
|
|
38
|
+
/**
|
|
39
|
+
* The epoch (cycle) number, in the chain's numbering
|
|
40
|
+
* (`SystemVariables.currentEpochNumber`).
|
|
41
|
+
*
|
|
42
|
+
* A clearing point carries the epoch that clearing closed. The `current`
|
|
43
|
+
* point carries the CURRENT epoch — which may equal the newest clearing's
|
|
44
|
+
* epoch, because a clearing runs before its epoch rolls over. Epoch
|
|
45
|
+
* numbers can jump (a pool that did not clear for a while, or a
|
|
46
|
+
* deployment whose first clearing is numbered far below the next one), so
|
|
47
|
+
* plot by `timestamp`, never by `epochId`.
|
|
48
|
+
*/
|
|
49
|
+
epochId: number;
|
|
50
|
+
/**
|
|
51
|
+
* Unix SECONDS. A clearing point: the time of the block its clearing
|
|
52
|
+
* finished in (`endTimestamp`). The `current` point: the time of the
|
|
53
|
+
* subgraph's latest indexed block. Clearings that finished in the same
|
|
54
|
+
* block (a pool catching up several epochs at once) share a timestamp and
|
|
55
|
+
* a `tvl`.
|
|
56
|
+
*/
|
|
57
|
+
timestamp: number;
|
|
58
|
+
/**
|
|
59
|
+
* TVL in DISPLAY units of the deployment's own stable token (USDC on Base
|
|
60
|
+
* and XDC USDC, AUDD on XDC AUDD): `poolTvl(onChain, offChain)` at that
|
|
61
|
+
* block. Convert before formatting as USD.
|
|
62
|
+
*/
|
|
63
|
+
tvl: number;
|
|
64
|
+
/** `'clearing'` for a cycle boundary; `'current'` for the closing point. */
|
|
65
|
+
kind: 'clearing' | 'current';
|
|
66
|
+
}
|
package/src/domain/requests.ts
CHANGED
|
@@ -82,10 +82,13 @@ export interface RequestState {
|
|
|
82
82
|
statusCode: RequestStatusCode;
|
|
83
83
|
kind: RequestKind;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* `
|
|
85
|
+
* `UserRequest.requestedAmount`, in assets: the amount still OUTSTANDING,
|
|
86
|
+
* which the subgraph reduces as parts are accepted or rejected (0 once a
|
|
87
|
+
* request is fully resolved). A cancelled request has it zeroed by the
|
|
88
|
+
* subgraph, so for a cancellation it is the `Cancelled` event's amount —
|
|
89
|
+
* what was outstanding when cancelled, top-ups included — falling back to
|
|
90
|
+
* the `Initiated` event (see `initiatedAmount`) only when that event
|
|
91
|
+
* carries none.
|
|
89
92
|
*/
|
|
90
93
|
requestedAmount: number;
|
|
91
94
|
/**
|
|
@@ -287,16 +290,24 @@ const initiatedEvent = (
|
|
|
287
290
|
): UserRequestEvent | undefined =>
|
|
288
291
|
events.find((e) => e.requestType === 'Initiated');
|
|
289
292
|
|
|
293
|
+
/** `assetAmount` of the `Initiated` event, or 0 when there is none. */
|
|
294
|
+
const initiatedAmountOf = (events: UserRequestEvent[]): number => {
|
|
295
|
+
const initiated = initiatedEvent(events);
|
|
296
|
+
return initiated ? Number(initiated.assetAmount || '0') : 0;
|
|
297
|
+
};
|
|
298
|
+
|
|
290
299
|
/**
|
|
291
300
|
* Subgraph behaviour: when a request is cancelled, the on-request
|
|
292
301
|
* `requestedAmount` field is reset to 0 (the lender's effective balance is
|
|
293
|
-
* restored). The
|
|
294
|
-
* `assetAmount
|
|
295
|
-
*
|
|
302
|
+
* restored). The amount cancelled survives on the `Cancelled` event's
|
|
303
|
+
* `assetAmount` — everything still outstanding at the cancel, top-ups
|
|
304
|
+
* included. Only when that event carries no figure does this fall back to the
|
|
305
|
+
* `Initiated` event, which holds the FIRST submission alone and so misses
|
|
306
|
+
* every top-up.
|
|
296
307
|
*/
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
return
|
|
308
|
+
const cancelledAmountOf = (events: UserRequestEvent[]): number => {
|
|
309
|
+
const cancelledEvent = events.find((e) => e.requestType === 'Cancelled');
|
|
310
|
+
return num(cancelledEvent?.assetAmount) || initiatedAmountOf(events);
|
|
300
311
|
};
|
|
301
312
|
|
|
302
313
|
/**
|
|
@@ -332,17 +343,15 @@ const numOrNull = (str: string | null | undefined): number | null => {
|
|
|
332
343
|
* Convert a `UserRequest` into a `RequestState`. Pure — no clock, no network,
|
|
333
344
|
* no copy.
|
|
334
345
|
*
|
|
335
|
-
* BRANCH ORDER (this IS the behaviour
|
|
336
|
-
* `deriveTransactionView` check for check):
|
|
346
|
+
* BRANCH ORDER (this IS the behaviour):
|
|
337
347
|
*
|
|
338
348
|
* 1. a `Cancelled` event → `cancelled`, neutral, 0
|
|
339
349
|
* 2. a withdrawal with a `Forced` event → `forced`, outflow, −accepted
|
|
340
350
|
* 3. a reallocated deposit → `reallocated`, inflow, +accepted
|
|
341
|
-
* 4. a withdrawal partly filled
|
|
342
|
-
* remainder (cycle
|
|
351
|
+
* 4. a withdrawal partly filled (paid > 0) with
|
|
352
|
+
* a LIVE remainder (queued > 0, cycle open) → `partial`, outflow, −accepted
|
|
343
353
|
* 5. resolved (`status === 'Processed'`):
|
|
344
|
-
* withdrawal
|
|
345
|
-
* withdrawal, fully filled → `complete`, outflow, −accepted
|
|
354
|
+
* withdrawal (nothing left queued) → `complete`, outflow, −accepted
|
|
346
355
|
* deposit, nothing accepted → `rejected`, neutral, 0
|
|
347
356
|
* deposit, part rejected → `partial`, inflow, +accepted
|
|
348
357
|
* deposit, fully accepted → `complete`, inflow, +accepted
|
|
@@ -369,10 +378,10 @@ export function deriveRequestState(request: UserRequest): RequestState {
|
|
|
369
378
|
const isWithdrawal = request.requestType === 'Withdrawal';
|
|
370
379
|
const cancelled = isCancelled(request.events);
|
|
371
380
|
// Cancelled requests have `requestedAmount` zeroed on the request itself;
|
|
372
|
-
//
|
|
373
|
-
//
|
|
381
|
+
// take the amount from the Cancelled event so the row still carries
|
|
382
|
+
// "1500 cancelled" (1000 + a 500 top-up) instead of "0 cancelled".
|
|
374
383
|
const requested = cancelled
|
|
375
|
-
? num(request.requestedAmount) ||
|
|
384
|
+
? num(request.requestedAmount) || cancelledAmountOf(request.events)
|
|
376
385
|
: num(request.requestedAmount);
|
|
377
386
|
const accepted = num(request.acceptedAmount);
|
|
378
387
|
const rejected = num(request.rejectedAmount);
|
|
@@ -441,11 +450,14 @@ export function deriveRequestState(request: UserRequest): RequestState {
|
|
|
441
450
|
|
|
442
451
|
// 4. Withdrawal partly filled with a LIVE remainder: the request returns
|
|
443
452
|
// to the queue with a live Cancel. Checked BEFORE the resolved branch and
|
|
444
|
-
// via `isCycleClosed`, never via the sticky raw status.
|
|
453
|
+
// via `isCycleClosed`, never via the sticky raw status. `requested` is
|
|
454
|
+
// what is still OUTSTANDING, so "partly filled" is "something paid AND
|
|
455
|
+
// something still queued" — never a comparison of the two, which would
|
|
456
|
+
// turn on whether more was paid than is left.
|
|
445
457
|
if (
|
|
446
458
|
isWithdrawal &&
|
|
447
459
|
accepted > 0 &&
|
|
448
|
-
|
|
460
|
+
requested > 0 &&
|
|
449
461
|
!isCycleClosed(request)
|
|
450
462
|
) {
|
|
451
463
|
return {
|
|
@@ -458,13 +470,15 @@ export function deriveRequestState(request: UserRequest): RequestState {
|
|
|
458
470
|
|
|
459
471
|
// 5. Resolved — a rejection IS a resolution.
|
|
460
472
|
if (request.status === UserRequestStatus.PROCESSED) {
|
|
473
|
+
// A withdrawal is resolved only once nothing is left queued — a
|
|
474
|
+
// partly filled one returns to the queue (branch 4), and one cancelled
|
|
475
|
+
// with a remainder is branch 1 — so a resolved withdrawal is complete.
|
|
461
476
|
if (isWithdrawal) {
|
|
462
|
-
const partly = accepted < requested;
|
|
463
477
|
return {
|
|
464
478
|
...base,
|
|
465
479
|
kind: 'outflow',
|
|
466
480
|
amount: -accepted,
|
|
467
|
-
statusCode:
|
|
481
|
+
statusCode: 'complete',
|
|
468
482
|
};
|
|
469
483
|
}
|
|
470
484
|
|
|
@@ -15,6 +15,29 @@ const XDC_RPC_URLS: string[] = [
|
|
|
15
15
|
'https://rpc.primenumbers.xyz/',
|
|
16
16
|
];
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* XDC RPCs that serve PAST state, for `getPoolTvlHistory` (each verified
|
|
20
|
+
* with `externalTVLOfPool` at old blocks, CORS `*`), in fallback order. Not
|
|
21
|
+
* `rpc.xdcrpc.com`, which refuses older blocks, and never `rpc.xdc.org` /
|
|
22
|
+
* `erpc.xdc.org`. Public and rate-limited.
|
|
23
|
+
*/
|
|
24
|
+
const XDC_HISTORY_RPC_URLS: string[] = [
|
|
25
|
+
'https://rpc.primenumbers.xyz/',
|
|
26
|
+
'https://rpc.ankr.com/xdc',
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Base RPCs that serve PAST state, in fallback order (each verified with
|
|
31
|
+
* `externalTVLOfPool` at old blocks; all answer CORS). Not
|
|
32
|
+
* `base-rpc.publicnode.com`, the default read RPC, which refuses old state.
|
|
33
|
+
* Public and rate-limited.
|
|
34
|
+
*/
|
|
35
|
+
const BASE_HISTORY_RPC_URLS: string[] = [
|
|
36
|
+
'https://mainnet.base.org',
|
|
37
|
+
'https://base.drpc.org',
|
|
38
|
+
'https://1rpc.io/base',
|
|
39
|
+
];
|
|
40
|
+
|
|
18
41
|
/**
|
|
19
42
|
* Built-in chain configurations for Kasu-supported networks.
|
|
20
43
|
*
|
|
@@ -59,6 +82,7 @@ export const CHAIN_CONFIGS: Record<'base' | 'xdc' | 'xdc-usdc' | 'plume', ChainC
|
|
|
59
82
|
'https://base-rpc.publicnode.com',
|
|
60
83
|
'https://mainnet.base.org',
|
|
61
84
|
],
|
|
85
|
+
historyRpcUrls: BASE_HISTORY_RPC_URLS,
|
|
62
86
|
blockExplorerUrl: 'https://basescan.org',
|
|
63
87
|
},
|
|
64
88
|
|
|
@@ -100,6 +124,7 @@ export const CHAIN_CONFIGS: Record<'base' | 'xdc' | 'xdc-usdc' | 'plume', ChainC
|
|
|
100
124
|
currencyCode: 'AUD',
|
|
101
125
|
},
|
|
102
126
|
rpcUrls: XDC_RPC_URLS,
|
|
127
|
+
historyRpcUrls: XDC_HISTORY_RPC_URLS,
|
|
103
128
|
blockExplorerUrl: 'https://xdcscan.com',
|
|
104
129
|
},
|
|
105
130
|
|
|
@@ -134,6 +159,7 @@ export const CHAIN_CONFIGS: Record<'base' | 'xdc' | 'xdc-usdc' | 'plume', ChainC
|
|
|
134
159
|
currencyCode: 'USD',
|
|
135
160
|
},
|
|
136
161
|
rpcUrls: XDC_RPC_URLS,
|
|
162
|
+
historyRpcUrls: XDC_HISTORY_RPC_URLS,
|
|
137
163
|
blockExplorerUrl: 'https://xdcscan.com',
|
|
138
164
|
},
|
|
139
165
|
|
package/src/facade/kasu.ts
CHANGED
|
@@ -65,17 +65,21 @@ export class Kasu {
|
|
|
65
65
|
* of pools than the read-only one it came from.
|
|
66
66
|
*/
|
|
67
67
|
private readonly _configOverrides: Partial<SdkConfigOptions>;
|
|
68
|
+
/** The caller's own history provider, kept so `connect` keeps it too. */
|
|
69
|
+
private readonly _historyProvider: Provider | undefined;
|
|
68
70
|
|
|
69
71
|
private constructor(
|
|
70
72
|
sdk: KasuSdk,
|
|
71
73
|
chainConfig: ChainConfigEntry,
|
|
72
74
|
signerOrProvider: Provider | Signer,
|
|
73
75
|
configOverrides: Partial<SdkConfigOptions>,
|
|
76
|
+
historyProvider: Provider | undefined,
|
|
74
77
|
) {
|
|
75
78
|
this._sdk = sdk;
|
|
76
79
|
this._chainConfig = chainConfig;
|
|
77
80
|
this._signerOrProvider = signerOrProvider;
|
|
78
81
|
this._configOverrides = configOverrides;
|
|
82
|
+
this._historyProvider = historyProvider;
|
|
79
83
|
|
|
80
84
|
this.strategies = new StrategiesFacade(
|
|
81
85
|
sdk.DataService,
|
|
@@ -168,6 +172,9 @@ export class Kasu {
|
|
|
168
172
|
stableAssetDecimals:
|
|
169
173
|
overrides.stableAssetDecimals ??
|
|
170
174
|
stableAssetOf(chainConfig)?.decimals,
|
|
175
|
+
historyRpcUrls:
|
|
176
|
+
overrides.historyRpcUrls ?? chainConfig.historyRpcUrls,
|
|
177
|
+
chainId: overrides.chainId ?? chainConfig.chainId,
|
|
171
178
|
});
|
|
172
179
|
|
|
173
180
|
const signerOrProvider =
|
|
@@ -179,8 +186,18 @@ export class Kasu {
|
|
|
179
186
|
: chainConfig.name,
|
|
180
187
|
);
|
|
181
188
|
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
// An explicit history provider wins; otherwise DataService builds
|
|
190
|
+
// them from `historyRpcUrls`, pinned to `chainId` (the one place).
|
|
191
|
+
const sdk = new KasuSdk(sdkConfig, signerOrProvider, {
|
|
192
|
+
historyProvider: options.historyProvider,
|
|
193
|
+
});
|
|
194
|
+
return new Kasu(
|
|
195
|
+
sdk,
|
|
196
|
+
chainConfig,
|
|
197
|
+
signerOrProvider,
|
|
198
|
+
overrides,
|
|
199
|
+
options.historyProvider,
|
|
200
|
+
);
|
|
184
201
|
}
|
|
185
202
|
|
|
186
203
|
/**
|
|
@@ -201,6 +218,7 @@ export class Kasu {
|
|
|
201
218
|
chain: this._chainConfig,
|
|
202
219
|
signerOrProvider: signer,
|
|
203
220
|
configOverrides: this._configOverrides,
|
|
221
|
+
historyProvider: this._historyProvider,
|
|
204
222
|
});
|
|
205
223
|
}
|
|
206
224
|
|
package/src/facade/strategies.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { PoolTvlHistoryEntry } from '../domain/pool-tvl';
|
|
1
2
|
import { selectVisiblePools } from '../domain/pools';
|
|
2
3
|
import { pickShortDescription } from '../domain/strategy-summary';
|
|
3
4
|
import { DataService } from '../services/DataService/data-service';
|
|
5
|
+
import { PoolTvlHistoryOptions } from '../services/DataService/tvl-history';
|
|
4
6
|
import {
|
|
5
7
|
PoolDelegateProfileAndHistory,
|
|
6
8
|
PoolOverview,
|
|
@@ -149,6 +151,30 @@ export class StrategiesFacade {
|
|
|
149
151
|
return await this._dataService.getPerformanceFee();
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
/**
|
|
155
|
+
* The strategy's TVL (total lent by everyone) at every cycle boundary,
|
|
156
|
+
* then as of now — the data behind a TVL chart. Ascending in time; the
|
|
157
|
+
* last point (`kind: 'current'`) equals `strategy.tvl.total` when both
|
|
158
|
+
* calls' reads succeed (see `PoolTvlHistoryEntry`).
|
|
159
|
+
*
|
|
160
|
+
* `tvl` is in display units of the deployment's OWN stable token (USDC on
|
|
161
|
+
* Base and XDC USDC, AUDD on XDC AUDD); `timestamp` is unix SECONDS.
|
|
162
|
+
* `{ count }` = the newest `count` epochs, `{ fromEpoch }` = from that
|
|
163
|
+
* epoch on; `timeoutMs` (default 30 s) and `signal` bound the call. A
|
|
164
|
+
* malformed option throws before any network read. See
|
|
165
|
+
* `DataService.getPoolTvlHistory` for the reads, the cost and the errors.
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* const points = await kasu.strategies.getPoolTvlHistory(poolId, { count: 52 });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
async getPoolTvlHistory(
|
|
172
|
+
poolId: string,
|
|
173
|
+
options: PoolTvlHistoryOptions = {},
|
|
174
|
+
): Promise<PoolTvlHistoryEntry[]> {
|
|
175
|
+
return await this._dataService.getPoolTvlHistory(poolId, options);
|
|
176
|
+
}
|
|
177
|
+
|
|
152
178
|
/**
|
|
153
179
|
* Fetch a single strategy by pool ID. Returns `null` if not found.
|
|
154
180
|
*/
|
package/src/facade/types.ts
CHANGED
|
@@ -70,6 +70,16 @@ export interface ChainConfigEntry {
|
|
|
70
70
|
* Empty on a retired deployment, which has no read-only default.
|
|
71
71
|
*/
|
|
72
72
|
rpcUrls: string[];
|
|
73
|
+
/**
|
|
74
|
+
* RPCs that SERVE PAST STATE (archive nodes), tried IN ORDER on failure,
|
|
75
|
+
* used only by `getPoolTvlHistory` to read the off-chain TVL at old
|
|
76
|
+
* blocks. Pruned nodes refuse those reads — some answer as if the call
|
|
77
|
+
* reverted — so these are never `rpcUrls[0]` by assumption. Public and
|
|
78
|
+
* RATE-LIMITED: an integrator should pass its own archive
|
|
79
|
+
* `KasuOptions.historyProvider`, which wins over them. Absent on a
|
|
80
|
+
* retired deployment.
|
|
81
|
+
*/
|
|
82
|
+
historyRpcUrls?: string[];
|
|
73
83
|
/**
|
|
74
84
|
* Origin of the chain's block explorer, `https://…` with NO trailing
|
|
75
85
|
* slash (`https://basescan.org`). Never append a path to it by hand: build
|
|
@@ -101,6 +111,16 @@ export interface KasuOptions {
|
|
|
101
111
|
| import('@ethersproject/providers').Provider;
|
|
102
112
|
/** Override any default config value. */
|
|
103
113
|
configOverrides?: Partial<SdkConfigOptions>;
|
|
114
|
+
/**
|
|
115
|
+
* A provider that SERVES PAST STATE (an archive RPC), for
|
|
116
|
+
* `kasu.strategies.getPoolTvlHistory`. OPTIONAL: without one, the SDK
|
|
117
|
+
* builds one `StaticJsonRpcProvider` per
|
|
118
|
+
* `configOverrides.historyRpcUrls ?? chainConfig.historyRpcUrls` entry
|
|
119
|
+
* (tried in order, 10 s per call). The built-in URLs are public and
|
|
120
|
+
* rate-limited, so pass your own archive provider in production. Kept
|
|
121
|
+
* across `connect(signer)`.
|
|
122
|
+
*/
|
|
123
|
+
historyProvider?: import('@ethersproject/providers').Provider;
|
|
104
124
|
}
|
|
105
125
|
|
|
106
126
|
// ---------------------------------------------------------------------------
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Core SDK class (low-level service access)
|
|
3
3
|
// ---------------------------------------------------------------------------
|
|
4
4
|
export { KasuSdk } from './kasu-sdk';
|
|
5
|
+
export type { KasuSdkOptions } from './kasu-sdk';
|
|
5
6
|
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
8
|
// Re-export config types
|
|
@@ -44,6 +45,14 @@ export type {
|
|
|
44
45
|
|
|
45
46
|
export type { YieldHistoryOptions } from './services/Portfolio/yield-history';
|
|
46
47
|
|
|
48
|
+
export type { PoolTvlHistoryOptions } from './services/DataService/tvl-history';
|
|
49
|
+
export {
|
|
50
|
+
PastStateUnavailableError,
|
|
51
|
+
PoolTvlHistoryAbortedError,
|
|
52
|
+
PoolTvlHistoryTimeoutError,
|
|
53
|
+
} from './services/DataService/tvl-history';
|
|
54
|
+
export { NO_HISTORY_PROVIDER_MESSAGE } from './services/DataService/data-service';
|
|
55
|
+
|
|
47
56
|
export type {
|
|
48
57
|
UserLock,
|
|
49
58
|
UserBonusData,
|
package/src/kasu-sdk.ts
CHANGED
|
@@ -9,6 +9,15 @@ import { Portfolio } from './services/Portfolio/portfolio';
|
|
|
9
9
|
import { Swapper } from './services/Swapper/swapper';
|
|
10
10
|
import { UserLending } from './services/UserLending/user-lending';
|
|
11
11
|
|
|
12
|
+
/** Optional providers beyond the main signer-or-provider. */
|
|
13
|
+
export interface KasuSdkOptions {
|
|
14
|
+
/**
|
|
15
|
+
* A provider that SERVES PAST STATE (an archive RPC), for
|
|
16
|
+
* `DataService.getPoolTvlHistory`. Wins over `SdkConfig.historyRpcUrls`.
|
|
17
|
+
*/
|
|
18
|
+
historyProvider?: Provider;
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
export class KasuSdk {
|
|
13
22
|
private readonly _graphClient: GraphQLClient;
|
|
14
23
|
public readonly Locking: KSULocking;
|
|
@@ -16,11 +25,19 @@ export class KasuSdk {
|
|
|
16
25
|
public readonly UserLending: UserLending;
|
|
17
26
|
public readonly Portfolio: Portfolio;
|
|
18
27
|
public readonly Swapper: Swapper;
|
|
19
|
-
constructor(
|
|
28
|
+
constructor(
|
|
29
|
+
config: SdkConfig,
|
|
30
|
+
signerOrProvider: Provider | Signer,
|
|
31
|
+
options: KasuSdkOptions = {},
|
|
32
|
+
) {
|
|
20
33
|
this._graphClient = new GraphQLClient(config.subgraphUrl);
|
|
21
34
|
this.Locking = new KSULocking(config, signerOrProvider);
|
|
22
35
|
this.UserLending = new UserLending(config, signerOrProvider);
|
|
23
|
-
this.DataService = new DataService(
|
|
36
|
+
this.DataService = new DataService(
|
|
37
|
+
config,
|
|
38
|
+
signerOrProvider,
|
|
39
|
+
options.historyProvider,
|
|
40
|
+
);
|
|
24
41
|
this.Portfolio = new Portfolio(config, signerOrProvider);
|
|
25
42
|
this.Swapper = new Swapper();
|
|
26
43
|
}
|