@kasufinance/kasu-sdk 2.4.2 → 2.5.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/LICENSE +21 -0
- package/README.md +189 -253
- package/dist/bundle.cjs.js +4775 -1794
- package/dist/bundle.esm.js +4764 -1816
- package/dist/domain/deposit-bounds.d.ts +62 -0
- package/dist/domain/deposit-bounds.js +84 -0
- package/dist/domain/deposit-bounds.js.map +1 -0
- package/dist/domain/deposit-bounds.test.js +135 -0
- package/dist/domain/deposit-bounds.test.js.map +1 -0
- package/dist/domain/index.d.ts +26 -0
- package/dist/domain/index.js +23 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/partners.d.ts +34 -0
- package/dist/domain/partners.js +43 -0
- package/dist/domain/partners.js.map +1 -0
- package/dist/domain/partners.test.d.ts +1 -0
- package/dist/domain/partners.test.js +53 -0
- package/dist/domain/partners.test.js.map +1 -0
- package/dist/domain/pools.d.ts +70 -0
- package/dist/domain/pools.js +134 -0
- package/dist/domain/pools.js.map +1 -0
- package/dist/domain/pools.test.d.ts +1 -0
- package/dist/domain/pools.test.js +184 -0
- package/dist/domain/pools.test.js.map +1 -0
- package/dist/domain/rates.d.ts +83 -0
- package/dist/domain/rates.js +120 -0
- package/dist/domain/rates.js.map +1 -0
- package/dist/domain/rates.test.d.ts +1 -0
- package/dist/domain/rates.test.js +181 -0
- package/dist/domain/rates.test.js.map +1 -0
- package/dist/domain/tranche-display-name.d.ts +17 -0
- package/dist/domain/tranche-display-name.js +30 -0
- package/dist/domain/tranche-display-name.js.map +1 -0
- package/dist/domain/tranche-display-name.test.d.ts +1 -0
- package/dist/domain/tranche-display-name.test.js +58 -0
- package/dist/domain/tranche-display-name.test.js.map +1 -0
- package/dist/domain/tranches.d.ts +89 -0
- package/dist/domain/tranches.js +150 -0
- package/dist/domain/tranches.js.map +1 -0
- package/dist/domain/tranches.test.d.ts +1 -0
- package/dist/domain/tranches.test.js +206 -0
- package/dist/domain/tranches.test.js.map +1 -0
- package/dist/facade/chain-configs.js +54 -0
- package/dist/facade/chain-configs.js.map +1 -1
- package/dist/facade/config.test.d.ts +1 -0
- package/dist/facade/config.test.js +216 -0
- package/dist/facade/config.test.js.map +1 -0
- package/dist/facade/deposits.d.ts +22 -1
- package/dist/facade/deposits.js +24 -1
- package/dist/facade/deposits.js.map +1 -1
- package/dist/facade/facade.test.d.ts +1 -0
- package/dist/{tests → facade}/facade.test.js +10 -5
- package/dist/facade/facade.test.js.map +1 -0
- package/dist/facade/index.d.ts +2 -1
- package/dist/facade/index.js +2 -0
- package/dist/facade/index.js.map +1 -1
- package/dist/facade/kasu.d.ts +49 -8
- package/dist/facade/kasu.js +117 -13
- package/dist/facade/kasu.js.map +1 -1
- package/dist/facade/strategies.d.ts +25 -0
- package/dist/facade/strategies.js +36 -0
- package/dist/facade/strategies.js.map +1 -1
- package/dist/facade/types.d.ts +57 -2
- package/dist/facade/unused-pool-ids.d.ts +31 -0
- package/dist/facade/unused-pool-ids.js +57 -0
- package/dist/facade/unused-pool-ids.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/sdk-config.d.ts +11 -0
- package/dist/sdk-config.js +8 -1
- package/dist/sdk-config.js.map +1 -1
- package/dist/services/DataService/data-service.d.ts +5 -0
- package/dist/services/DataService/data-service.js +7 -2
- package/dist/services/DataService/data-service.js.map +1 -1
- package/dist/services/Locking/calculate-apy.test.d.ts +1 -0
- package/dist/services/Locking/calculate-apy.test.js +41 -0
- package/dist/services/Locking/calculate-apy.test.js.map +1 -0
- package/dist/services/Locking/locking.d.ts +14 -0
- package/dist/services/Locking/locking.js +16 -2
- package/dist/services/Locking/locking.js.map +1 -1
- package/dist/tests/sample.test.js +46 -25
- package/dist/tests/sample.test.js.map +1 -1
- package/package.json +43 -12
- package/src/domain/deposit-bounds.test.ts +200 -0
- package/src/domain/deposit-bounds.ts +118 -0
- package/src/domain/index.ts +70 -0
- package/src/domain/partners.test.ts +83 -0
- package/src/domain/partners.ts +66 -0
- package/src/domain/pools.test.ts +260 -0
- package/src/domain/pools.ts +150 -0
- package/src/domain/rates.test.ts +254 -0
- package/src/domain/rates.ts +120 -0
- package/src/domain/tranche-display-name.test.ts +96 -0
- package/src/domain/tranche-display-name.ts +34 -0
- package/src/domain/tranches.test.ts +300 -0
- package/src/domain/tranches.ts +177 -0
- package/src/facade/chain-configs.ts +55 -0
- package/src/facade/config.test.ts +265 -0
- package/src/facade/deposits.ts +25 -0
- package/src/{tests → facade}/facade.test.ts +10 -5
- package/src/facade/index.ts +4 -0
- package/src/facade/kasu.ts +155 -12
- package/src/facade/strategies.ts +36 -0
- package/src/facade/types.ts +60 -2
- package/src/facade/unused-pool-ids.ts +59 -0
- package/src/index.ts +6 -0
- package/src/sdk-config.ts +19 -1
- package/src/services/DataService/data-service.ts +7 -2
- package/src/services/Locking/calculate-apy.test.ts +52 -0
- package/src/services/Locking/locking.ts +16 -2
- package/src/tests/sample.test.ts +54 -33
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -90
- package/.github/workflows/ci.yml +0 -39
- package/.github/workflows/gitleaks.yml +0 -22
- package/.github/workflows/main.yml +0 -41
- package/.gitleaksignore +0 -19
- package/.prettierignore +0 -3
- package/.prettierrc +0 -28
- package/CLAUDE.md +0 -410
- package/copy-abi.ps1 +0 -15
- package/dist/tests/facade.test.js.map +0 -1
- package/index.ts +0 -2
- package/jest-config.ts +0 -9
- package/jest.config.js +0 -8
- package/rollup.config.js +0 -45
- package/tsconfig.json +0 -27
- /package/dist/{tests/facade.test.d.ts → domain/deposit-bounds.test.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposits.js","sourceRoot":"","sources":["../../src/facade/deposits.ts"],"names":[],"mappings":";;;;;;;;;AAMA;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACvB,YACY,YAAyB,EACzB,QAAgB;
|
|
1
|
+
{"version":3,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AAY,CAAC,oBAAoB,CAC/C,MAAM,EACN,SAAS,EACT,WAAW,CACd,CAAC;QACN,CAAC;KAAA;IAED;;;;;OAKG;IACH,cAAc,CAAC,WAA0B;QACrC,OAAO,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAC5C,WAAW,EACX,IAAI,CAAC,QAAQ,CAChB,CAAC;IACN,CAAC;IAED;;;OAGG;IACG,iBAAiB,CAAC,MAAc;;YAClC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;KAAA;IAED;;OAEG;IACG,eAAe;;YACjB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;QACrD,CAAC;KAAA;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Offline facade specs — a mock provider and pure helpers, no network. Moved
|
|
3
|
+
* here from `src/tests/` so it runs beside the code it covers, and so the
|
|
4
|
+
* opt-in `LIVE_TESTS` gate on `src/tests/` does not take it out of CI.
|
|
5
|
+
*/
|
|
6
|
+
import { CHAIN_CONFIGS } from './chain-configs';
|
|
7
|
+
import { DepositsFacade } from './deposits';
|
|
8
|
+
import { Kasu } from './kasu';
|
|
9
|
+
import { StrategiesFacade } from './strategies';
|
|
10
|
+
import { PortfolioFacade } from './user-portfolio';
|
|
6
11
|
// ---------------------------------------------------------------------------
|
|
7
12
|
// Chain configs
|
|
8
13
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facade.test.js","sourceRoot":"","sources":["../../src/facade/facade.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MA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E9E,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QACxD,uEAAuE;QACvE,iCAAiC;QACjC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3B,MAAM,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;QACvC,MAAM,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,CAAC,eAAe,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,4EAA4E;AAC5E,SAAS,WAAW,CAAC,GAIpB;IACG,OAAO;QACH,EAAE,EAAE,QAAQ;QACZ,IAAI,EAAE,cAAc;QACpB,GAAG,EAAE,IAAI;QACT,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;QACZ,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,iBAAiB,EAAE,GAAG,CAAC,YAAY;QACnC,gBAAgB,EAAE,EAAE;QACpB,IAAI,kCACG,GAAG,KACN,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,EAAE,GACtB;KACK,CAAC;AACf,CAAC"}
|
package/dist/facade/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { StrategiesFacade } from './strategies';
|
|
|
3
3
|
export { DepositsFacade } from './deposits';
|
|
4
4
|
export { PortfolioFacade } from './user-portfolio';
|
|
5
5
|
export { CHAIN_CONFIGS } from './chain-configs';
|
|
6
|
-
export
|
|
6
|
+
export { fetchUnusedPoolIds } from './unused-pool-ids';
|
|
7
|
+
export type { SupportedChain, ChainConfigEntry, StableAsset, KasuOptions, Strategy, StrategyTranche, FixedTermOption, DepositParams, WithdrawParams, DepositLimits, KycParams, UserPositions, PlatformStats, } from './types';
|
package/dist/facade/index.js
CHANGED
|
@@ -6,4 +6,6 @@ export { DepositsFacade } from './deposits';
|
|
|
6
6
|
export { PortfolioFacade } from './user-portfolio';
|
|
7
7
|
// Chain configurations
|
|
8
8
|
export { CHAIN_CONFIGS } from './chain-configs';
|
|
9
|
+
// Directus-backed helpers (I/O — not part of `domain/`)
|
|
10
|
+
export { fetchUnusedPoolIds } from './unused-pool-ids';
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/dist/facade/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/facade/index.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,gDAAgD;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,uBAAuB;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/facade/index.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,gDAAgD;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,uBAAuB;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wDAAwD;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/facade/kasu.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Provider } from '@ethersproject/providers';
|
|
2
|
+
import { Signer } from 'ethers';
|
|
1
3
|
import { KasuSdk } from '../kasu-sdk';
|
|
2
4
|
import { DepositsFacade } from './deposits';
|
|
3
5
|
import { StrategiesFacade } from './strategies';
|
|
@@ -12,15 +14,15 @@ import { PortfolioFacade } from './user-portfolio';
|
|
|
12
14
|
* ```ts
|
|
13
15
|
* import { Kasu } from '@kasufinance/kasu-sdk';
|
|
14
16
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* // Browse strategies
|
|
17
|
+
* // Read-only — no wallet needed, uses the chain's default RPC
|
|
18
|
+
* const kasu = Kasu.create({ chain: 'base' });
|
|
18
19
|
* const strategies = await kasu.strategies.getAll();
|
|
19
20
|
*
|
|
20
|
-
* //
|
|
21
|
-
* const
|
|
21
|
+
* // Writable — same config, bound to a signer
|
|
22
|
+
* const signed = kasu.connect(signer);
|
|
23
|
+
* const tx = await signed.deposits.deposit({ poolId, trancheId, amount, kycSignature });
|
|
22
24
|
*
|
|
23
|
-
* // User positions
|
|
25
|
+
* // User positions (read-only is enough)
|
|
24
26
|
* const positions = await kasu.portfolio.getPositions(userAddress);
|
|
25
27
|
* ```
|
|
26
28
|
*/
|
|
@@ -33,13 +35,23 @@ export declare class Kasu {
|
|
|
33
35
|
readonly portfolio: PortfolioFacade;
|
|
34
36
|
private readonly _sdk;
|
|
35
37
|
private readonly _chainConfig;
|
|
38
|
+
private readonly _signerOrProvider;
|
|
39
|
+
/**
|
|
40
|
+
* Kept so `connect(signer)` can rebuild an identical instance. A connected
|
|
41
|
+
* instance that silently dropped the overrides would query a different set
|
|
42
|
+
* of pools than the read-only one it came from.
|
|
43
|
+
*/
|
|
44
|
+
private readonly _configOverrides;
|
|
36
45
|
private constructor();
|
|
37
46
|
/**
|
|
38
47
|
* Create a Kasu instance with built-in chain config.
|
|
39
48
|
*
|
|
49
|
+
* `signerOrProvider` is optional: without one the instance is READ-ONLY on
|
|
50
|
+
* `chainConfig.rpcUrls[0]`. Use `connect(signer)` when a wallet arrives.
|
|
51
|
+
*
|
|
40
52
|
* ```ts
|
|
41
|
-
* // Minimal setup —
|
|
42
|
-
* const kasu = Kasu.create({ chain: 'base'
|
|
53
|
+
* // Minimal setup — read-only, built-in Base mainnet config
|
|
54
|
+
* const kasu = Kasu.create({ chain: 'base' });
|
|
43
55
|
*
|
|
44
56
|
* // Custom config override
|
|
45
57
|
* const kasu = Kasu.create({
|
|
@@ -56,6 +68,20 @@ export declare class Kasu {
|
|
|
56
68
|
* ```
|
|
57
69
|
*/
|
|
58
70
|
static create(options: KasuOptions): Kasu;
|
|
71
|
+
/**
|
|
72
|
+
* A NEW instance bound to `signer`, with the same chain config and the same
|
|
73
|
+
* `configOverrides` — the writable counterpart of a read-only instance.
|
|
74
|
+
*
|
|
75
|
+
* Named after `contract.connect(signer)` in ethers, and behaves the same
|
|
76
|
+
* way: the receiver is not mutated, so a read-only `Kasu` stays read-only
|
|
77
|
+
* and can keep serving public data after a wallet connects.
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* const kasu = Kasu.create({ chain: 'base' }); // read-only
|
|
81
|
+
* const signed = kasu.connect(await getSigner()); // writable
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
connect(signer: Signer): Kasu;
|
|
59
85
|
/**
|
|
60
86
|
* Access the underlying `KasuSdk` services for advanced use cases.
|
|
61
87
|
*
|
|
@@ -68,4 +94,19 @@ export declare class Kasu {
|
|
|
68
94
|
get chainConfig(): ChainConfigEntry;
|
|
69
95
|
/** Whether this deployment has KSU token / locking features. */
|
|
70
96
|
get isLiteDeployment(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* True when this instance was built from a Provider rather than a Signer,
|
|
99
|
+
* so every read works and every write is refused. Call `connect(signer)`
|
|
100
|
+
* for a writable instance.
|
|
101
|
+
*/
|
|
102
|
+
get isReadOnly(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* The provider this instance reads through — the signer's own provider when
|
|
105
|
+
* it was created from a signer.
|
|
106
|
+
*
|
|
107
|
+
* Throws for a signer with no provider attached (an offline signer can sign
|
|
108
|
+
* but cannot read), because there is no provider to hand back and returning
|
|
109
|
+
* `undefined` would only move the failure somewhere less obvious.
|
|
110
|
+
*/
|
|
111
|
+
get provider(): Provider;
|
|
71
112
|
}
|
package/dist/facade/kasu.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { providers, Signer } from 'ethers';
|
|
1
2
|
import { KasuSdk } from '../kasu-sdk';
|
|
2
3
|
import { SdkConfig } from '../sdk-config';
|
|
3
4
|
import { CHAIN_CONFIGS } from './chain-configs';
|
|
@@ -13,32 +14,37 @@ import { PortfolioFacade } from './user-portfolio';
|
|
|
13
14
|
* ```ts
|
|
14
15
|
* import { Kasu } from '@kasufinance/kasu-sdk';
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* // Browse strategies
|
|
17
|
+
* // Read-only — no wallet needed, uses the chain's default RPC
|
|
18
|
+
* const kasu = Kasu.create({ chain: 'base' });
|
|
19
19
|
* const strategies = await kasu.strategies.getAll();
|
|
20
20
|
*
|
|
21
|
-
* //
|
|
22
|
-
* const
|
|
21
|
+
* // Writable — same config, bound to a signer
|
|
22
|
+
* const signed = kasu.connect(signer);
|
|
23
|
+
* const tx = await signed.deposits.deposit({ poolId, trancheId, amount, kycSignature });
|
|
23
24
|
*
|
|
24
|
-
* // User positions
|
|
25
|
+
* // User positions (read-only is enough)
|
|
25
26
|
* const positions = await kasu.portfolio.getPositions(userAddress);
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
28
29
|
export class Kasu {
|
|
29
|
-
constructor(sdk, chainConfig) {
|
|
30
|
+
constructor(sdk, chainConfig, signerOrProvider, configOverrides) {
|
|
30
31
|
this._sdk = sdk;
|
|
31
32
|
this._chainConfig = chainConfig;
|
|
33
|
+
this._signerOrProvider = signerOrProvider;
|
|
34
|
+
this._configOverrides = configOverrides;
|
|
32
35
|
this.strategies = new StrategiesFacade(sdk.DataService, sdk.UserLending);
|
|
33
|
-
this.deposits = new DepositsFacade(sdk.UserLending, chainConfig.chainId.toString());
|
|
36
|
+
this.deposits = new DepositsFacade(sdk.UserLending, chainConfig.chainId.toString(), !Signer.isSigner(signerOrProvider));
|
|
34
37
|
this.portfolio = new PortfolioFacade(sdk.DataService, sdk.UserLending, sdk.Portfolio);
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
37
40
|
* Create a Kasu instance with built-in chain config.
|
|
38
41
|
*
|
|
42
|
+
* `signerOrProvider` is optional: without one the instance is READ-ONLY on
|
|
43
|
+
* `chainConfig.rpcUrls[0]`. Use `connect(signer)` when a wallet arrives.
|
|
44
|
+
*
|
|
39
45
|
* ```ts
|
|
40
|
-
* // Minimal setup —
|
|
41
|
-
* const kasu = Kasu.create({ chain: 'base'
|
|
46
|
+
* // Minimal setup — read-only, built-in Base mainnet config
|
|
47
|
+
* const kasu = Kasu.create({ chain: 'base' });
|
|
42
48
|
*
|
|
43
49
|
* // Custom config override
|
|
44
50
|
* const kasu = Kasu.create({
|
|
@@ -55,7 +61,7 @@ export class Kasu {
|
|
|
55
61
|
* ```
|
|
56
62
|
*/
|
|
57
63
|
static create(options) {
|
|
58
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
59
65
|
const chainConfig = resolveChainConfig(options.chain);
|
|
60
66
|
const overrides = (_a = options.configOverrides) !== null && _a !== void 0 ? _a : {};
|
|
61
67
|
const sdkConfig = new SdkConfig({
|
|
@@ -66,9 +72,36 @@ export class Kasu {
|
|
|
66
72
|
UNUSED_LENDING_POOL_IDS: (_e = overrides.UNUSED_LENDING_POOL_IDS) !== null && _e !== void 0 ? _e : chainConfig.unusedPoolIds,
|
|
67
73
|
isLiteDeployment: (_f = overrides.isLiteDeployment) !== null && _f !== void 0 ? _f : chainConfig.isLiteDeployment,
|
|
68
74
|
poolMetadataMapping: (_g = overrides.poolMetadataMapping) !== null && _g !== void 0 ? _g : chainConfig.poolMetadataMapping,
|
|
75
|
+
// Follow the chain's own token rather than `SdkConfig`'s default
|
|
76
|
+
// of 6. Every live deployment happens to be 6dp today, so the
|
|
77
|
+
// default was right by luck; the next one need not be.
|
|
78
|
+
stableAssetDecimals: (_h = overrides.stableAssetDecimals) !== null && _h !== void 0 ? _h : (_j = stableAssetOf(chainConfig)) === null || _j === void 0 ? void 0 : _j.decimals,
|
|
79
|
+
});
|
|
80
|
+
const signerOrProvider = (_k = options.signerOrProvider) !== null && _k !== void 0 ? _k : defaultProvider(chainConfig, typeof options.chain === 'string'
|
|
81
|
+
? options.chain
|
|
82
|
+
: chainConfig.name);
|
|
83
|
+
const sdk = new KasuSdk(sdkConfig, signerOrProvider);
|
|
84
|
+
return new Kasu(sdk, chainConfig, signerOrProvider, overrides);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A NEW instance bound to `signer`, with the same chain config and the same
|
|
88
|
+
* `configOverrides` — the writable counterpart of a read-only instance.
|
|
89
|
+
*
|
|
90
|
+
* Named after `contract.connect(signer)` in ethers, and behaves the same
|
|
91
|
+
* way: the receiver is not mutated, so a read-only `Kasu` stays read-only
|
|
92
|
+
* and can keep serving public data after a wallet connects.
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* const kasu = Kasu.create({ chain: 'base' }); // read-only
|
|
96
|
+
* const signed = kasu.connect(await getSigner()); // writable
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
connect(signer) {
|
|
100
|
+
return Kasu.create({
|
|
101
|
+
chain: this._chainConfig,
|
|
102
|
+
signerOrProvider: signer,
|
|
103
|
+
configOverrides: this._configOverrides,
|
|
69
104
|
});
|
|
70
|
-
const sdk = new KasuSdk(sdkConfig, options.signerOrProvider);
|
|
71
|
-
return new Kasu(sdk, chainConfig);
|
|
72
105
|
}
|
|
73
106
|
/**
|
|
74
107
|
* Access the underlying `KasuSdk` services for advanced use cases.
|
|
@@ -88,10 +121,81 @@ export class Kasu {
|
|
|
88
121
|
get isLiteDeployment() {
|
|
89
122
|
return this._chainConfig.isLiteDeployment;
|
|
90
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* True when this instance was built from a Provider rather than a Signer,
|
|
126
|
+
* so every read works and every write is refused. Call `connect(signer)`
|
|
127
|
+
* for a writable instance.
|
|
128
|
+
*/
|
|
129
|
+
get isReadOnly() {
|
|
130
|
+
return !Signer.isSigner(this._signerOrProvider);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The provider this instance reads through — the signer's own provider when
|
|
134
|
+
* it was created from a signer.
|
|
135
|
+
*
|
|
136
|
+
* Throws for a signer with no provider attached (an offline signer can sign
|
|
137
|
+
* but cannot read), because there is no provider to hand back and returning
|
|
138
|
+
* `undefined` would only move the failure somewhere less obvious.
|
|
139
|
+
*/
|
|
140
|
+
get provider() {
|
|
141
|
+
if (Signer.isSigner(this._signerOrProvider)) {
|
|
142
|
+
const provider = this._signerOrProvider.provider;
|
|
143
|
+
if (!provider) {
|
|
144
|
+
throw new Error('Kasu: the signer this instance was created with has no provider attached');
|
|
145
|
+
}
|
|
146
|
+
return provider;
|
|
147
|
+
}
|
|
148
|
+
return this._signerOrProvider;
|
|
149
|
+
}
|
|
91
150
|
}
|
|
92
151
|
// ---------------------------------------------------------------------------
|
|
93
152
|
// Helpers
|
|
94
153
|
// ---------------------------------------------------------------------------
|
|
154
|
+
// `stableAsset` and `rpcUrls` are REQUIRED on `ChainConfigEntry`, so every
|
|
155
|
+
// built-in config and every entry written against 2.5.0 carries them. A custom
|
|
156
|
+
// entry hand-built against an older release does not, and a consumer bumping to
|
|
157
|
+
// 2.5.0 must not crash on `undefined.decimals` before TypeScript has told them
|
|
158
|
+
// what to add (kasu-app-admin builds one for base-sepolia). Both readers below
|
|
159
|
+
// take the field as possibly absent and fall back: the stable-asset decimals to
|
|
160
|
+
// `SdkConfig`'s own default of 6, the RPC list to empty — which makes a
|
|
161
|
+
// read-only `create` throw the same clear message a retired chain does.
|
|
162
|
+
function stableAssetOf(chainConfig) {
|
|
163
|
+
return chainConfig.stableAsset;
|
|
164
|
+
}
|
|
165
|
+
function rpcUrlsOf(chainConfig) {
|
|
166
|
+
var _a;
|
|
167
|
+
return (_a = chainConfig.rpcUrls) !== null && _a !== void 0 ? _a : [];
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The read-only provider used when the caller passes no `signerOrProvider`.
|
|
171
|
+
*
|
|
172
|
+
* `StaticJsonRpcProvider` rather than `JsonRpcProvider`: the chain id is known
|
|
173
|
+
* from the config, so it skips the `eth_chainId` round trip on every call and
|
|
174
|
+
* never re-detects the network — the right choice for an endpoint that serves
|
|
175
|
+
* exactly one chain.
|
|
176
|
+
*
|
|
177
|
+
* Only `rpcUrls[0]` is used. The list is a starting preference, not a failover
|
|
178
|
+
* strategy: an app that needs failover builds its own provider and passes it
|
|
179
|
+
* in, and baking a retry policy in here would hide outages from the app that
|
|
180
|
+
* has to report them.
|
|
181
|
+
*
|
|
182
|
+
* Constructed through the `ethers` namespace rather than by importing
|
|
183
|
+
* `StaticJsonRpcProvider` from `@ethersproject/providers` directly. `ethers` is
|
|
184
|
+
* the only provider package the rollup config marks external, so this picks up
|
|
185
|
+
* the CONSUMER's build — the Node one under Node, the browser one in a browser.
|
|
186
|
+
* Importing the class directly would inline the browser transport into the
|
|
187
|
+
* bundle, and its `fetch` call carries `referrer: 'client'`, which Node rejects
|
|
188
|
+
* outright ("Referrer \"client\" is not a valid URL"). It would also give the
|
|
189
|
+
* SDK a second provider implementation, so `instanceof` against the consumer's
|
|
190
|
+
* ethers would quietly fail.
|
|
191
|
+
*/
|
|
192
|
+
function defaultProvider(chainConfig, chainLabel) {
|
|
193
|
+
const url = rpcUrlsOf(chainConfig)[0];
|
|
194
|
+
if (!url) {
|
|
195
|
+
throw new Error(`Kasu.create: chain "${chainLabel}" has no default RPC (retired); pass signerOrProvider`);
|
|
196
|
+
}
|
|
197
|
+
return new providers.StaticJsonRpcProvider(url, chainConfig.chainId);
|
|
198
|
+
}
|
|
95
199
|
function resolveChainConfig(chain) {
|
|
96
200
|
if (typeof chain === 'string') {
|
|
97
201
|
return CHAIN_CONFIGS[chain];
|
package/dist/facade/kasu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kasu.js","sourceRoot":"","sources":["../../src/facade/kasu.ts"],"names":[],"mappings":"
|
|
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,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,IAAI;IAkBb,YACI,GAAY,EACZ,WAA6B,EAC7B,gBAAmC,EACnC,eAA0C;QAE1C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;QAC1C,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QAExC,IAAI,CAAC,UAAU,GAAG,IAAI,gBAAgB,CAClC,GAAG,CAAC,WAAW,EACf,GAAG,CAA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AAC;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;CACJ;AAED,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,2EAA2E;AAC3E,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,wEAAwE;AACxE,wEAAwE;AACxE,SAAS,aAAa,CAClB,WAA6B;IAE7B,OAAQ,WAA6C,CAAC,WAAW,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,WAA6B;;IAC5C,OAAO,MAAC,WAAsC,CAAC,OAAO,mCAAI,EAAE,CAAC;AACjE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAS,eAAe,CACpB,WAA6B,EAC7B,UAAkB;IAElB,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,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"}
|
|
@@ -18,6 +18,31 @@ export declare class StrategiesFacade {
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
getAll(poolIds?: string[]): Promise<Strategy[]>;
|
|
21
|
+
/**
|
|
22
|
+
* The strategies a lender should actually see: active, not oversubscribed,
|
|
23
|
+
* with the ones that still have capacity first and the highest max APY
|
|
24
|
+
* next. `getAll` returns everything the subgraph knows about, including
|
|
25
|
+
* pools that are wound down.
|
|
26
|
+
*
|
|
27
|
+
* The filter runs on the raw `PoolOverview[]` BEFORE mapping, so `_raw` on
|
|
28
|
+
* every returned `Strategy` is the untouched pool object.
|
|
29
|
+
*/
|
|
30
|
+
getVisible(poolIds?: string[]): Promise<Strategy[]>;
|
|
31
|
+
/**
|
|
32
|
+
* The chain's performance fee.
|
|
33
|
+
*
|
|
34
|
+
* ⚠️ A PERCENTAGE IN 0..100 (`10` means ten percent), NOT a fraction —
|
|
35
|
+
* feed it to `netEffectiveApy` as-is. Treating it as `0.10` computes a
|
|
36
|
+
* nonsense negative rate that still renders as a plausible-looking
|
|
37
|
+
* percentage, which is why the units are stated here and in
|
|
38
|
+
* `netEffectiveApy`'s own JSDoc.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const feePercent = await kasu.strategies.getPerformanceFeePercent();
|
|
42
|
+
* const net = netEffectiveApy(strategy.tranches[0].apy, feePercent);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
getPerformanceFeePercent(): Promise<number>;
|
|
21
46
|
/**
|
|
22
47
|
* Fetch a single strategy by pool ID. Returns `null` if not found.
|
|
23
48
|
*/
|
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { selectVisiblePools } from '../domain/pools';
|
|
10
11
|
/**
|
|
11
12
|
* High-level facade for browsing Kasu lending strategies (pools).
|
|
12
13
|
*
|
|
@@ -31,6 +32,41 @@ export class StrategiesFacade {
|
|
|
31
32
|
return pools.map((pool) => this.mapPoolToStrategy(pool));
|
|
32
33
|
});
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The strategies a lender should actually see: active, not oversubscribed,
|
|
37
|
+
* with the ones that still have capacity first and the highest max APY
|
|
38
|
+
* next. `getAll` returns everything the subgraph knows about, including
|
|
39
|
+
* pools that are wound down.
|
|
40
|
+
*
|
|
41
|
+
* The filter runs on the raw `PoolOverview[]` BEFORE mapping, so `_raw` on
|
|
42
|
+
* every returned `Strategy` is the untouched pool object.
|
|
43
|
+
*/
|
|
44
|
+
getVisible(poolIds) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const epochId = yield this._userLending.getCurrentEpoch();
|
|
47
|
+
const pools = yield this._dataService.getPoolOverview(epochId, poolIds);
|
|
48
|
+
return selectVisiblePools(pools).map((pool) => this.mapPoolToStrategy(pool));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The chain's performance fee.
|
|
53
|
+
*
|
|
54
|
+
* ⚠️ A PERCENTAGE IN 0..100 (`10` means ten percent), NOT a fraction —
|
|
55
|
+
* feed it to `netEffectiveApy` as-is. Treating it as `0.10` computes a
|
|
56
|
+
* nonsense negative rate that still renders as a plausible-looking
|
|
57
|
+
* percentage, which is why the units are stated here and in
|
|
58
|
+
* `netEffectiveApy`'s own JSDoc.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* const feePercent = await kasu.strategies.getPerformanceFeePercent();
|
|
62
|
+
* const net = netEffectiveApy(strategy.tranches[0].apy, feePercent);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
getPerformanceFeePercent() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
return yield this._dataService.getPerformanceFee();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
34
70
|
/**
|
|
35
71
|
* Fetch a single strategy by pool ID. Returns `null` if not found.
|
|
36
72
|
*/
|
|
@@ -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":";;;;;;;;;AAAA,OAAO,EAAE,kBAAk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c,EAAE,CAAC,CAAC,cAAc;YAChC,iBAAiB,EAAE,CAAC,CAAC,YAAY;YACjC,gBAAgB,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG,CACnC,CAAC,GAAG,EAAmB,EAAE,CAAC,CAAC;gBACvB,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC;gBACxB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;aAC3C,CAAC,CACL;YACD,IAAI,EAAE,CAAC;SACV,CAAC,CAAC,CAAC;QAEJ,OAAO;YACH,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,EAAE,IAAI,CAAC,gBAAgB;YAC1B,iBAAiB,EAAE,IAAI,CAAC,YAAY;YACpC,mBAAmB,EAAE,IAAI,CAAC,sBAAsB;YAChD,QAAQ;YACR,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,gBAAgB;YACnC,YAAY,EAAE,IAAI,CAAC,iBAAiB;YACpC,SAAS,EAAE,IAAI,CAAC,cAAc;YAC9B,IAAI,EAAE,IAAI;SACb,CAAC;IACN,CAAC;CACJ"}
|
package/dist/facade/types.d.ts
CHANGED
|
@@ -3,6 +3,33 @@ import { ContractAddresses, SdkConfigOptions } from '../sdk-config';
|
|
|
3
3
|
import { LendingTotals, PoolOverview, TrancheData } from '../services/DataService/types';
|
|
4
4
|
import { PortfolioLendingPool, PortfolioSummary } from '../services/Portfolio/types';
|
|
5
5
|
export type SupportedChain = 'base' | 'xdc' | 'xdc-usdc' | 'plume';
|
|
6
|
+
/**
|
|
7
|
+
* The single stable token a deployment lends in. There is exactly ONE per
|
|
8
|
+
* deployment and it never changes: a different stable token is a separate full
|
|
9
|
+
* deployment (the XDC AUDD / XDC USDC pattern), never a companion vault on an
|
|
10
|
+
* existing one. That is why this is a plain object on the chain config rather
|
|
11
|
+
* than a list.
|
|
12
|
+
*/
|
|
13
|
+
export interface StableAsset {
|
|
14
|
+
/** ERC-20 address of the stable token on this chain. */
|
|
15
|
+
address: string;
|
|
16
|
+
/** Ticker as the token contract reports it (`USDC`, `AUDD`, `pUSD`). */
|
|
17
|
+
symbol: string;
|
|
18
|
+
/** Token name as the contract reports it (`USD Coin`). */
|
|
19
|
+
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* Token decimals. Feeds `SdkConfig.stableAssetDecimals`, so every
|
|
22
|
+
* `parseUnits`/`formatUnits` in the SDK follows the chain rather than the
|
|
23
|
+
* hard-coded default of 6.
|
|
24
|
+
*/
|
|
25
|
+
decimals: number;
|
|
26
|
+
/**
|
|
27
|
+
* ISO-4217 code of the fiat currency the token tracks (`USD`, `AUD`).
|
|
28
|
+
* A CODE, not copy: consumers pick their own symbol and locale from it.
|
|
29
|
+
* Nothing in this SDK formats it.
|
|
30
|
+
*/
|
|
31
|
+
currencyCode: string;
|
|
32
|
+
}
|
|
6
33
|
export interface ChainConfigEntry {
|
|
7
34
|
chainId: number;
|
|
8
35
|
name: string;
|
|
@@ -10,15 +37,43 @@ export interface ChainConfigEntry {
|
|
|
10
37
|
contracts: ContractAddresses;
|
|
11
38
|
subgraphUrl: string;
|
|
12
39
|
directusUrl: string;
|
|
40
|
+
/**
|
|
41
|
+
* Pools to hide. An EMPTY array is normalised to `['']` by `SdkConfig` —
|
|
42
|
+
* the subgraph reads `id_not_in: []` as "match nothing" and returns zero
|
|
43
|
+
* pools. See `SdkConfigOptions.UNUSED_LENDING_POOL_IDS`.
|
|
44
|
+
*/
|
|
13
45
|
unusedPoolIds: string[];
|
|
14
46
|
poolMetadataMapping?: Record<string, string>;
|
|
47
|
+
/** The one stable token this deployment lends in. */
|
|
48
|
+
stableAsset: StableAsset;
|
|
49
|
+
/**
|
|
50
|
+
* Public RPC endpoints for read-only use, in STARTING preference order
|
|
51
|
+
* only. Apps are expected to override with their own paid/keyed endpoints
|
|
52
|
+
* and their own failover; `Kasu.create` uses `rpcUrls[0]` and nothing else
|
|
53
|
+
* when no `signerOrProvider` is passed.
|
|
54
|
+
*
|
|
55
|
+
* Empty on a retired deployment, which has no read-only default.
|
|
56
|
+
*/
|
|
57
|
+
rpcUrls: string[];
|
|
58
|
+
/**
|
|
59
|
+
* True for a wound-down deployment kept only as frozen history. It has no
|
|
60
|
+
* default RPC, so a read-only `Kasu.create` on it throws.
|
|
61
|
+
*/
|
|
62
|
+
retired?: boolean;
|
|
15
63
|
}
|
|
16
64
|
/** Options passed to `Kasu.create()`. */
|
|
17
65
|
export interface KasuOptions {
|
|
18
66
|
/** A supported chain name or a custom `ChainConfigEntry`. */
|
|
19
67
|
chain: SupportedChain | ChainConfigEntry;
|
|
20
|
-
/**
|
|
21
|
-
|
|
68
|
+
/**
|
|
69
|
+
* ethers Signer (for transactions) or Provider (read-only).
|
|
70
|
+
*
|
|
71
|
+
* OPTIONAL. When omitted, `Kasu.create` builds a read-only
|
|
72
|
+
* `StaticJsonRpcProvider` on `chainConfig.rpcUrls[0]`, so browsing
|
|
73
|
+
* strategies and platform stats needs no wallet at all. Get a writable
|
|
74
|
+
* instance later with `kasu.connect(signer)`.
|
|
75
|
+
*/
|
|
76
|
+
signerOrProvider?: import('ethers').Signer | import('@ethersproject/providers').Provider;
|
|
22
77
|
/** Override any default config value. */
|
|
23
78
|
configOverrides?: Partial<SdkConfigOptions>;
|
|
24
79
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pool ids that are configured but NOT enabled — the ones every query
|
|
3
|
+
* should exclude.
|
|
4
|
+
*
|
|
5
|
+
* "Enabled" is editorial state, held in Directus rather than on-chain: a pool
|
|
6
|
+
* exists in the subgraph from the moment it is deployed, and stays hidden
|
|
7
|
+
* until content has been written for it. Every consumer has been hard-coding
|
|
8
|
+
* this list; reading it means a pool goes live without a frontend release.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const kasu = Kasu.create({
|
|
12
|
+
* chain: 'base',
|
|
13
|
+
* configOverrides: { UNUSED_LENDING_POOL_IDS: await fetchUnusedPoolIds() },
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* May legitimately return an empty array (every pool enabled). Pass it
|
|
18
|
+
* straight through: `SdkConfig` normalises an empty list to the `['']`
|
|
19
|
+
* sentinel, because the subgraph reads `id_not_in: []` as "match nothing" and
|
|
20
|
+
* would hide every pool.
|
|
21
|
+
*
|
|
22
|
+
* Uses the global `fetch`, so it needs Node 18+ or a browser. This is I/O and
|
|
23
|
+
* deliberately not part of `domain/`.
|
|
24
|
+
*
|
|
25
|
+
* @param directusUrl base URL of the Directus instance, with or without a
|
|
26
|
+
* trailing slash.
|
|
27
|
+
* @throws when the request fails or Directus answers with a non-2xx status —
|
|
28
|
+
* never silently returns `[]`, which would be indistinguishable from "every
|
|
29
|
+
* pool is enabled" and would un-hide pools that have no content.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fetchUnusedPoolIds(directusUrl?: string): Promise<string[]>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/** Directus instance holding Kasu's pool editorial content. */
|
|
11
|
+
const DEFAULT_DIRECTUS_URL = 'https://kasu-finance.directus.app/';
|
|
12
|
+
/**
|
|
13
|
+
* The pool ids that are configured but NOT enabled — the ones every query
|
|
14
|
+
* should exclude.
|
|
15
|
+
*
|
|
16
|
+
* "Enabled" is editorial state, held in Directus rather than on-chain: a pool
|
|
17
|
+
* exists in the subgraph from the moment it is deployed, and stays hidden
|
|
18
|
+
* until content has been written for it. Every consumer has been hard-coding
|
|
19
|
+
* this list; reading it means a pool goes live without a frontend release.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const kasu = Kasu.create({
|
|
23
|
+
* chain: 'base',
|
|
24
|
+
* configOverrides: { UNUSED_LENDING_POOL_IDS: await fetchUnusedPoolIds() },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* May legitimately return an empty array (every pool enabled). Pass it
|
|
29
|
+
* straight through: `SdkConfig` normalises an empty list to the `['']`
|
|
30
|
+
* sentinel, because the subgraph reads `id_not_in: []` as "match nothing" and
|
|
31
|
+
* would hide every pool.
|
|
32
|
+
*
|
|
33
|
+
* Uses the global `fetch`, so it needs Node 18+ or a browser. This is I/O and
|
|
34
|
+
* deliberately not part of `domain/`.
|
|
35
|
+
*
|
|
36
|
+
* @param directusUrl base URL of the Directus instance, with or without a
|
|
37
|
+
* trailing slash.
|
|
38
|
+
* @throws when the request fails or Directus answers with a non-2xx status —
|
|
39
|
+
* never silently returns `[]`, which would be indistinguishable from "every
|
|
40
|
+
* pool is enabled" and would un-hide pools that have no content.
|
|
41
|
+
*/
|
|
42
|
+
export function fetchUnusedPoolIds() {
|
|
43
|
+
return __awaiter(this, arguments, void 0, function* (directusUrl = DEFAULT_DIRECTUS_URL) {
|
|
44
|
+
var _a;
|
|
45
|
+
const base = directusUrl.endsWith('/') ? directusUrl : `${directusUrl}/`;
|
|
46
|
+
const url = `${base}items/PoolOverview?filter[enabled][_neq]=true`;
|
|
47
|
+
const response = yield fetch(url);
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
throw new Error(`fetchUnusedPoolIds: Directus responded ${String(response.status)} ${response.statusText} for ${url}`);
|
|
50
|
+
}
|
|
51
|
+
const body = (yield response.json());
|
|
52
|
+
return ((_a = body.data) !== null && _a !== void 0 ? _a : [])
|
|
53
|
+
.map((row) => row.id)
|
|
54
|
+
.filter((id) => typeof id === 'string' && id.length > 0);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=unused-pool-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unused-pool-ids.js","sourceRoot":"","sources":["../../src/facade/unused-pool-ids.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+DAA+D;AAC/D,MAAM,oBAAoB,GAAG,oCAAoC,CAAC;AAUlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAgB,kBAAkB;yDACpC,cAAsB,oBAAoB;;QAE1C,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,GAAG,CAAC;QACzE,MAAM,GAAG,GAAG,GAAG,IAAI,+CAA+C,CAAC;QAEnE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACX,0CAA0C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,UAAU,QAAQ,GAAG,EAAE,CACxG,CAAC;QACN,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA2B,CAAC;QAC/D,OAAO,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC;aACnB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;aACpB,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/E,CAAC;CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export type { PortfolioSummary, PortfolioLendingPool, PortfolioTranche, Portfoli
|
|
|
7
7
|
export type { UserLock, UserBonusData, LockPeriod, GQLGetLockingPeriods, SystemVariables, } from './services/Locking/types';
|
|
8
8
|
export type { PoolOverviewDirectus, PlatformOverviewDirectus, } from './services/DataService/directus-types';
|
|
9
9
|
export * from './facade';
|
|
10
|
+
export * from './domain';
|