@kasufinance/kasu-sdk 2.12.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 +26 -1
- package/dist/bundle.cjs.js +871 -41
- package/dist/bundle.esm.js +868 -43
- 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/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/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/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/shared.ts +38 -1
|
@@ -537,38 +537,5 @@ export function buildYieldHistory(
|
|
|
537
537
|
);
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
* deployment's subgraph does not have. A network error, a timeout or an
|
|
543
|
-
* indexing error is not one.
|
|
544
|
-
*/
|
|
545
|
-
export function isMissingEntityError(error: unknown): boolean {
|
|
546
|
-
if (typeof error !== 'object' || error === null) return false;
|
|
547
|
-
const response = (error as { response?: { errors?: unknown } }).response;
|
|
548
|
-
const errors = response?.errors;
|
|
549
|
-
if (!Array.isArray(errors) || errors.length === 0) return false;
|
|
550
|
-
return errors.every((e: unknown) => {
|
|
551
|
-
const message = (e as { message?: unknown } | null)?.message;
|
|
552
|
-
return (
|
|
553
|
-
typeof message === 'string' &&
|
|
554
|
-
/has no field|cannot query field|unknown (type|field|argument)|no such (type|field)/i.test(
|
|
555
|
-
message,
|
|
556
|
-
)
|
|
557
|
-
);
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* The only failure `getYieldHistory` turns into `[]`: a missing-schema error
|
|
563
|
-
* on a LITE deployment, whose subgraph may predate the entities. On a full
|
|
564
|
-
* deployment the entities are part of the schema, so the same error means a
|
|
565
|
-
* broken query or subgraph and THROWS — an empty chart there would hide it.
|
|
566
|
-
* Everything else (network, timeout, indexing) throws on every deployment, so
|
|
567
|
-
* a consumer can tell "no history here" from "history unavailable".
|
|
568
|
-
*/
|
|
569
|
-
export function isEmptyHistoryError(
|
|
570
|
-
error: unknown,
|
|
571
|
-
liteDeployment: boolean,
|
|
572
|
-
): boolean {
|
|
573
|
-
return liteDeployment && isMissingEntityError(error);
|
|
574
|
-
}
|
|
540
|
+
// Shared with `getPoolTvlHistory`: one Lite-vs-full rule for every history.
|
|
541
|
+
export { isEmptyHistoryError, isMissingEntityError } from '../shared';
|
package/src/services/shared.ts
CHANGED
|
@@ -8,4 +8,41 @@ export function filterArray<T>(array: T[], id_in?: string[]): T[] {
|
|
|
8
8
|
return id_in.includes(id);
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A GraphQL VALIDATION error naming an entity, field or argument this
|
|
15
|
+
* deployment's subgraph does not have. A network error, a timeout or an
|
|
16
|
+
* indexing error is not one.
|
|
17
|
+
*/
|
|
18
|
+
export function isMissingEntityError(error: unknown): boolean {
|
|
19
|
+
if (typeof error !== 'object' || error === null) return false;
|
|
20
|
+
const response = (error as { response?: { errors?: unknown } }).response;
|
|
21
|
+
const errors = response?.errors;
|
|
22
|
+
if (!Array.isArray(errors) || errors.length === 0) return false;
|
|
23
|
+
return errors.every((e: unknown) => {
|
|
24
|
+
const message = (e as { message?: unknown } | null)?.message;
|
|
25
|
+
return (
|
|
26
|
+
typeof message === 'string' &&
|
|
27
|
+
/has no field|cannot query field|unknown (type|field|argument)|no such (type|field)/i.test(
|
|
28
|
+
message,
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The only failure a history read (`getYieldHistory`, `getPoolTvlHistory`)
|
|
36
|
+
* turns into `[]`: a missing-schema error
|
|
37
|
+
* on a LITE deployment, whose subgraph may predate the entities. On a full
|
|
38
|
+
* deployment the entities are part of the schema, so the same error means a
|
|
39
|
+
* broken query or subgraph and THROWS — an empty chart there would hide it.
|
|
40
|
+
* Everything else (network, timeout, indexing) throws on every deployment, so
|
|
41
|
+
* a consumer can tell "no history here" from "history unavailable".
|
|
42
|
+
*/
|
|
43
|
+
export function isEmptyHistoryError(
|
|
44
|
+
error: unknown,
|
|
45
|
+
liteDeployment: boolean,
|
|
46
|
+
): boolean {
|
|
47
|
+
return liteDeployment && isMissingEntityError(error);
|
|
48
|
+
}
|